Assembly Line Release 0.1.5
Full log here: http://calclavia.com/universalelectricity/?m=18&p=changelog
This commit is contained in:
parent
d311e58311
commit
6ef0840fdb
12 changed files with 497 additions and 35 deletions
|
@ -1 +1 @@
|
|||
16
|
||||
18
|
||||
|
|
1
info.txt
1
info.txt
|
@ -12,3 +12,4 @@ Minecraft 1.4.2
|
|||
@ AssemblyLine_v0.1.3.11.jar AssemblyLine_v0.1.3.11_api.zip
|
||||
* AssemblyLine_v0.1.3.13.jar AssemblyLine_v0.1.3.13_api.zip
|
||||
* AssemblyLine_v0.1.4.14.jar AssemblyLine_v0.1.4.14_api.zip
|
||||
* AssemblyLine_v0.1.5.18.jar AssemblyLine_v0.1.5.18_api.zip
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.1.4
|
||||
0.1.5
|
1
recommendedversion.txt
Normal file
1
recommendedversion.txt
Normal file
|
@ -0,0 +1 @@
|
|||
0.1.5
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"modid" : "AssemblyLine",
|
||||
"name" : "Assembly Line",
|
||||
"version" : "0.1.4",
|
||||
"version" : "0.1.5",
|
||||
"url" : "http://calclavia.com/universalelectricity/?m=18",
|
||||
"credits" : "",
|
||||
"authors": [
|
||||
|
|
|
@ -6,11 +6,13 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import assemblyline.client.gui.GuiSorter;
|
||||
import assemblyline.client.render.RenderConveyorBelt;
|
||||
import assemblyline.client.render.RenderCrate;
|
||||
import assemblyline.client.render.RenderHelper;
|
||||
import assemblyline.client.render.RenderManipulator;
|
||||
import assemblyline.client.render.RenderSorter;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.CommonProxy;
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||
|
@ -30,11 +32,10 @@ public class ClientProxy extends CommonProxy
|
|||
public void init()
|
||||
{
|
||||
super.init();
|
||||
// ClientRegistry.registerTileEntity(TileEntityConveyorBelt.class,
|
||||
// "belt", new RenderConveyorBelt());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, new RenderConveyorBelt());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
124
src/minecraft/assemblyline/client/render/RenderCrate.java
Normal file
124
src/minecraft/assemblyline/client/render/RenderCrate.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class RenderCrate extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8)
|
||||
{
|
||||
TileEntityCrate tileEntity = (TileEntityCrate) var1;
|
||||
|
||||
for (int side = 2; side < 6; side++)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPolygonOffset(-10, -10);
|
||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
float dx = 1F / 16;
|
||||
float dz = 1F / 16;
|
||||
float displayWidth = 1 - 2F / 16;
|
||||
float displayHeight = 1 - 2F / 16;
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 0:
|
||||
GL11.glTranslatef(1, 1, 0);
|
||||
GL11.glRotatef(180, 1, 0, 0);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef(0, 1, 0);
|
||||
GL11.glRotatef(0, 0, 1, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
GL11.glTranslatef(1, 1, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
|
||||
break;
|
||||
case 5:
|
||||
GL11.glTranslatef(0, 1, 1);
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
|
||||
break;
|
||||
case 4:
|
||||
GL11.glTranslatef(1, 1, 0);
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
|
||||
GL11.glRotatef(-90, 1, 0, 0);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
FontRenderer fontRenderer = this.getFontRenderer();
|
||||
int maxWidth = 1;
|
||||
|
||||
String itemName = "Empty";
|
||||
String amount = "";
|
||||
|
||||
if (tileEntity.getStackInSlot(0) != null)
|
||||
{
|
||||
itemName = tileEntity.getStackInSlot(0).getDisplayName();
|
||||
amount = tileEntity.getStackInSlot(0).stackSize + "";
|
||||
|
||||
}
|
||||
|
||||
maxWidth = Math.max(fontRenderer.getStringWidth(itemName), maxWidth);
|
||||
maxWidth = Math.max(fontRenderer.getStringWidth(amount), maxWidth);
|
||||
maxWidth += 4;
|
||||
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
||||
int requiredHeight = lineHeight * 1;
|
||||
float scaleX = displayWidth / maxWidth;
|
||||
float scaleY = displayHeight / requiredHeight;
|
||||
float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
|
||||
GL11.glScalef(scale, -scale, scale);
|
||||
GL11.glDepthMask(false);
|
||||
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
int realHeight = (int) Math.floor(displayHeight / scale);
|
||||
int realWidth = (int) Math.floor(displayWidth / scale);
|
||||
|
||||
if (scaleX < scaleY)
|
||||
{
|
||||
offsetX = 2 + 5;
|
||||
offsetY = (realHeight - requiredHeight) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
offsetX = (realWidth - maxWidth) / 2 + 2 + 5;
|
||||
offsetY = 0;
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
fontRenderer.drawString(itemName, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
|
||||
fontRenderer.drawString(amount, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,13 +13,12 @@ import universalelectricity.prefab.UETab;
|
|||
import universalelectricity.prefab.UpdateNotifier;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.common.block.BlockArchitectTable;
|
||||
import assemblyline.common.block.BlockCrate;
|
||||
import assemblyline.common.block.ItemBlockCrate;
|
||||
import assemblyline.common.machine.BlockMulti;
|
||||
import assemblyline.common.machine.ItemBlockMulti;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.BlockMulti.MachineType;
|
||||
import assemblyline.common.machine.ItemBlockMulti;
|
||||
import assemblyline.common.machine.belt.BlockConveyorBelt;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
|
@ -45,7 +44,7 @@ public class AssemblyLine
|
|||
|
||||
public static final String NAME = "Assembly Line";
|
||||
|
||||
public static final String VERSION = "0.1.4";
|
||||
public static final String VERSION = "0.1.5";
|
||||
|
||||
public static final String CHANNEL = "AssemblyLine";
|
||||
|
||||
|
@ -62,22 +61,25 @@ public class AssemblyLine
|
|||
public static Block blockConveyorBelt;
|
||||
public static Block blockInteraction;
|
||||
public static Block blockArchitectTable;
|
||||
public static Block blockCrate;
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
UniversalElectricity.register(this, 1, 1, 3, false);
|
||||
UniversalElectricity.register(this, 1, 2, 0, false);
|
||||
instance = this;
|
||||
|
||||
CONFIGURATION.load();
|
||||
blockConveyorBelt = new BlockConveyorBelt(CONFIGURATION.getBlock("Conveyor Belt", BLOCK_ID_PREFIX).getInt());
|
||||
blockInteraction = new BlockMulti(CONFIGURATION.getBlock("Machine", BLOCK_ID_PREFIX + 1).getInt());
|
||||
blockArchitectTable = new BlockArchitectTable(CONFIGURATION.getBlock("Architect's Table", BLOCK_ID_PREFIX + 2).getInt());
|
||||
blockCrate = new BlockCrate(CONFIGURATION.getBlock("Crate", BLOCK_ID_PREFIX + 3).getInt());
|
||||
CONFIGURATION.save();
|
||||
|
||||
NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
|
||||
GameRegistry.registerBlock(blockConveyorBelt);
|
||||
GameRegistry.registerBlock(blockArchitectTable);
|
||||
GameRegistry.registerBlock(blockCrate, ItemBlockCrate.class);
|
||||
GameRegistry.registerBlock(blockInteraction, ItemBlockMulti.class);
|
||||
|
||||
UpdateNotifier.INSTANCE.checkUpdate(NAME, VERSION, "http://calclavia.com/downloads/al/recommendedversion.txt");
|
||||
|
|
|
@ -3,6 +3,7 @@ package assemblyline.common;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
import assemblyline.common.machine.ContainerSorter;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
|
@ -21,9 +22,10 @@ public class CommonProxy implements IGuiHandler
|
|||
|
||||
public void init()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, "ConveyorBelt");
|
||||
GameRegistry.registerTileEntity(TileEntityRejector.class, "Sorter");
|
||||
GameRegistry.registerTileEntity(TileEntityManipulator.class, "Manipulator");
|
||||
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, "ALConveyorBelt");
|
||||
GameRegistry.registerTileEntity(TileEntityRejector.class, "ALSorter");
|
||||
GameRegistry.registerTileEntity(TileEntityManipulator.class, "ALManipulator");
|
||||
GameRegistry.registerTileEntity(TileEntityCrate.class, "ALCrate");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,48 +2,131 @@ package assemblyline.common.block;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
import universalelectricity.prefab.UETab;
|
||||
|
||||
/**
|
||||
* A block that allows the placement of mass amount of a specific item within it.
|
||||
* It will be allowed to go on Conveyor Belts
|
||||
* A block that allows the placement of mass amount of a specific item within it. It will be allowed
|
||||
* to go on Conveyor Belts
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class BlockCrate extends Block
|
||||
public class BlockCrate extends BlockMachine
|
||||
{
|
||||
public BlockCrate(int par1)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
this.blockIndexInTexture = 59;
|
||||
this.setBlockName("create");
|
||||
super("crate", par1, UniversalElectricity.machine);
|
||||
this.blockIndexInTexture = Block.blockSteel.blockIndexInTexture;
|
||||
this.setCreativeTab(UETab.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block texture based on the side being looked at. Args: side
|
||||
*/
|
||||
public int getBlockTextureFromSide(int par1)
|
||||
{
|
||||
return par1 == 1 ? this.blockIndexInTexture - 16 : (par1 == 0 ? Block.planks.getBlockTextureFromSide(0) : (par1 != 2 && par1 != 4 ? this.blockIndexInTexture : this.blockIndexInTexture + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par1World.isRemote)
|
||||
if (world.getBlockTileEntity(x, y, z) != null)
|
||||
{
|
||||
return true;
|
||||
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = par5EntityPlayer.getCurrentEquippedItem();
|
||||
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (tileEntity.containingItems[0] != null)
|
||||
{
|
||||
if (tileEntity.containingItems[0].isItemEqual(itemStack))
|
||||
{
|
||||
tileEntity.containingItems[0].stackSize += itemStack.stackSize;
|
||||
|
||||
if (tileEntity.containingItems[0].stackSize > tileEntity.getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = tileEntity.containingItems[0].stackSize - tileEntity.getInventoryStackLimit();
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemStack.isStackable())
|
||||
{
|
||||
tileEntity.containingItems[0] = itemStack;
|
||||
itemStack.stackSize = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize <= 0)
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
|
||||
|
||||
}
|
||||
else if (tileEntity.containingItems[0] != null)
|
||||
{
|
||||
int amountToTake = Math.min(tileEntity.containingItems[0].stackSize, 64);
|
||||
ItemStack newStack = tileEntity.containingItems[0].copy();
|
||||
newStack.stackSize = amountToTake;
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, newStack);
|
||||
tileEntity.containingItems[0].stackSize -= amountToTake;
|
||||
|
||||
if (tileEntity.containingItems[0].stackSize <= 0)
|
||||
{
|
||||
tileEntity.containingItems[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the crate as a block that stores items within it.
|
||||
*/
|
||||
@Override
|
||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.getBlockTileEntity(x, y, z) != null)
|
||||
{
|
||||
par5EntityPlayer.displayGUIWorkbench(par2, par3, par4);
|
||||
return true;
|
||||
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity.containingItems[0] != null)
|
||||
{
|
||||
if (tileEntity.containingItems[0].stackSize > 0)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
float var6 = 0.7F;
|
||||
double var7 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
|
||||
double var9 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
|
||||
double var11 = (double) (world.rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
|
||||
ItemStack dropStack = new ItemStack(this, 1);
|
||||
ItemBlockCrate.setContainingItemStack(dropStack, tileEntity.containingItems[0]);
|
||||
EntityItem var13 = new EntityItem(world, (double) x + var7, (double) y + var9, (double) z + var11, dropStack);
|
||||
var13.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(var13);
|
||||
tileEntity.containingItems[0] = null;
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityCrate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
76
src/minecraft/assemblyline/common/block/ItemBlockCrate.java
Normal file
76
src/minecraft/assemblyline/common/block/ItemBlockCrate.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package assemblyline.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemBlockCrate extends ItemBlock
|
||||
{
|
||||
public ItemBlockCrate(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
ItemStack containingStack = getContainingItemStack(itemStack);
|
||||
|
||||
if (containingStack != null)
|
||||
{
|
||||
par3List.add(containingStack.getDisplayName());
|
||||
par3List.add("Amount: " + containingStack.stackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("Empty");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void setContainingItemStack(ItemStack itemStack, ItemStack containingStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
containingStack.writeToNBT(itemStack.getTagCompound());
|
||||
}
|
||||
|
||||
public static ItemStack getContainingItemStack(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return ItemStack.loadItemStackFromNBT(itemStack.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
|
||||
{
|
||||
ItemStack containingItem = getContainingItemStack(stack);
|
||||
|
||||
if (world.getBlockTileEntity(x, y, z) != null && containingItem != null)
|
||||
{
|
||||
if (containingItem.stackSize > 0)
|
||||
{
|
||||
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
||||
tileEntity.containingItems[0] = containingItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
172
src/minecraft/assemblyline/common/block/TileEntityCrate.java
Normal file
172
src/minecraft/assemblyline/common/block/TileEntityCrate.java
Normal file
|
@ -0,0 +1,172 @@
|
|||
package assemblyline.common.block;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
|
||||
public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory
|
||||
{
|
||||
public ItemStack[] containingItems = new ItemStack[1];
|
||||
|
||||
/**
|
||||
* Inventory functions.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int par1)
|
||||
{
|
||||
return this.containingItems[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var3;
|
||||
|
||||
if (this.containingItems[par1].stackSize <= par2)
|
||||
{
|
||||
var3 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
var3 = this.containingItems[par1].splitStack(par2);
|
||||
|
||||
if (this.containingItems[par1].stackSize == 0)
|
||||
{
|
||||
this.containingItems[par1] = null;
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var2 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
this.containingItems[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* NBT Data
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagList var2 = nbt.getTagList("Items");
|
||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
||||
{
|
||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
|
||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
||||
{
|
||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
||||
{
|
||||
if (this.containingItems[var3] != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
this.containingItems[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
nbt.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return "Crate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventorySide(ForgeDirection side)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue