I am creating a new chest but have a problem with it. Whenever I click a slot part of the inventory or hotbar, I receive this crash in the console and am disconnected from the game with an Internal Server Error:
WARNING: Failed to handle packet: java.lang.IndexOutOfBoundsException: Index: 51, Size: 45
java.lang.IndexOutOfBoundsException: Index: 51, Size: 45
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at net.minecraft.src.Container.slotClick(Container.java:191)
at net.minecraft.src.NetServerHandler.handleWindowClick(NetServerHandler.java:815)
at net.minecraft.src.Packet102WindowClick.processPacket(Packet102WindowClick.java:42)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:70)
at net.minecraft.src.NetServerHandler.networkTick(NetServerHandler.java:73)
at net.minecraft.src.NetworkListenThread.networkTick(NetworkListenThread.java:45)
at net.minecraft.src.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:98)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:638)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:553)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:122)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:462)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)
I have been trying to figure it out for quite some time but can't find where the issue is.
Code:
mod_AdvChest:
package net.minecraft.src;
import java.util.List;
import net.minecraft.client.Minecraft;public class mod_AdvChest extends BaseMod
{
public static final Block advChest = new ADCBlockChest(200).setHardness(2.5F).setStepSound(Block.soundWoodFootstep).setBlockName("advChest").setRequiresSelfNotify();
public void load()
{
ModLoader.registerBlock(advChest);
ModLoader.addName(advChest, "Advanced Chest"); ADCTileEntityChestRenderer chestRenderer = new ADCTileEntityChestRenderer();
ModLoader.registerTileEntity(ADCTileEntityChest.class, "advancedChest", chestRenderer);
}
public String getVersion()
{
return "1.3.1";
}
}
ADCBlockChest:
package net.minecraft.src;
import java.util.Iterator;
import java.util.Random;public class ADCBlockChest extends BlockContainer
{
private Random random = new Random();
protected ADCBlockChest(int par1)
{
super(par1, Material.wood);
this.blockIndexInTexture = 26;
this.setCreativeTab(CreativeTabs.tabDeco);
} /**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
} /**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 22;
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
super.onBlockAdded(par1World, par2, par3, par4);
this.unifyAdjacentChests(par1World, par2, par3, par4);
int var5 = par1World.getBlockId(par2, par3, par4 - 1);
int var6 = par1World.getBlockId(par2, par3, par4 + 1);
int var7 = par1World.getBlockId(par2 - 1, par3, par4);
int var8 = par1World.getBlockId(par2 + 1, par3, par4); if (var5 == this.blockID)
{
this.unifyAdjacentChests(par1World, par2, par3, par4 - 1);
}
if (var6 == this.blockID)
{
this.unifyAdjacentChests(par1World, par2, par3, par4 + 1);
} if (var7 == this.blockID)
{
this.unifyAdjacentChests(par1World, par2 - 1, par3, par4);
}
if (var8 == this.blockID)
{
this.unifyAdjacentChests(par1World, par2 + 1, par3, par4);
}
} /**
* Called when the block is placed in the world.
*/
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = par1World.getBlockId(par2, par3, par4 - 1);
int var7 = par1World.getBlockId(par2, par3, par4 + 1);
int var8 = par1World.getBlockId(par2 - 1, par3, par4);
int var9 = par1World.getBlockId(par2 + 1, par3, par4);
byte var10 = 0;
int var11 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (var11 == 0)
{
var10 = 2;
} if (var11 == 1)
{
var10 = 5;
}
if (var11 == 2)
{
var10 = 3;
} if (var11 == 3)
{
var10 = 4;
}
if (var6 != this.blockID && var7 != this.blockID && var8 != this.blockID && var9 != this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
else
{
if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5))
{
if (var6 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
} par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3))
{
if (var8 == this.blockID)
{
par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
}
else
{
par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
} par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
}
}
}
/**
* Turns the adjacent chests to a double chest.
*/
public void unifyAdjacentChests(World par1World, int par2, int par3, int par4)
{
if (!par1World.isRemote)
{
int var5 = par1World.getBlockId(par2, par3, par4 - 1);
int var6 = par1World.getBlockId(par2, par3, par4 + 1);
int var7 = par1World.getBlockId(par2 - 1, par3, par4);
int var8 = par1World.getBlockId(par2 + 1, par3, par4);
boolean var9 = true;
int var10;
int var11;
boolean var12;
byte var13;
int var14; if (var5 != this.blockID && var6 != this.blockID)
{
if (var7 != this.blockID && var8 != this.blockID)
{
var13 = 3;
if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
{
var13 = 3;
} if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
{
var13 = 2;
}
if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
{
var13 = 5;
} if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
{
var13 = 4;
}
}
else
{
var10 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 - 1);
var11 = par1World.getBlockId(var7 == this.blockID ? par2 - 1 : par2 + 1, par3, par4 + 1);
var13 = 3;
var12 = true;
if (var7 == this.blockID)
{
var14 = par1World.getBlockMetadata(par2 - 1, par3, par4);
}
else
{
var14 = par1World.getBlockMetadata(par2 + 1, par3, par4);
} if (var14 == 2)
{
var13 = 2;
}
if ((Block.opaqueCubeLookup[var5] || Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var11])
{
var13 = 3;
} if ((Block.opaqueCubeLookup[var6] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var10])
{
var13 = 2;
}
}
}
else
{
var10 = par1World.getBlockId(par2 - 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
var11 = par1World.getBlockId(par2 + 1, par3, var5 == this.blockID ? par4 - 1 : par4 + 1);
var13 = 5;
var12 = true;
if (var5 == this.blockID)
{
var14 = par1World.getBlockMetadata(par2, par3, par4 - 1);
}
else
{
var14 = par1World.getBlockMetadata(par2, par3, par4 + 1);
} if (var14 == 4)
{
var13 = 4;
}
if ((Block.opaqueCubeLookup[var7] || Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var11])
{
var13 = 5;
} if ((Block.opaqueCubeLookup[var8] || Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var10])
{
var13 = 4;
}
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var13);
}
} /**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return 4;
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
public int getBlockTextureFromSide(int par1)
{
return 4;
} /**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = 0;
if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID)
{
++var5;
} if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID)
{
++var5;
}
if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID)
{
++var5;
} if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)
{
++var5;
}
return var5 > 1 ? false : (this.isThereANeighborChest(par1World, par2 - 1, par3, par4) ? false : (this.isThereANeighborChest(par1World, par2 + 1, par3, par4) ? false : (this.isThereANeighborChest(par1World, par2, par3, par4 - 1) ? false : !this.isThereANeighborChest(par1World, par2, par3, par4 + 1))));
} /**
* Checks the neighbor blocks to see if there is a chest there. Args: world, x, y, z
*/
private boolean isThereANeighborChest(World par1World, int par2, int par3, int par4)
{
return par1World.getBlockId(par2, par3, par4) != this.blockID ? false : (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID ? true : (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID ? true : (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID ? true : par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)));
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
ADCTileEntityChest var6 = (ADCTileEntityChest)par1World.getBlockTileEntity(par2, par3, par4); if (var6 != null)
{
var6.updateContainingBlockInfo();
}
}
/**
* ejects contained items into the world, and notifies neighbours of an update, as appropriate
*/
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
{
ADCTileEntityChest var7 = (ADCTileEntityChest)par1World.getBlockTileEntity(par2, par3, par4); if (var7 != null)
{
for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
{
ItemStack var9 = var7.getStackInSlot(var8);
if (var9 != null)
{
float var10 = this.random.nextFloat() * 0.8F + 0.1F;
float var11 = this.random.nextFloat() * 0.8F + 0.1F;
EntityItem var14; for (float var12 = this.random.nextFloat() * 0.8F + 0.1F; var9.stackSize > 0; par1World.spawnEntityInWorld(var14))
{
int var13 = this.random.nextInt(21) + 10;
if (var13 > var9.stackSize)
{
var13 = var9.stackSize;
} var9.stackSize -= var13;
var14 = new EntityItem(par1World, (double)((float)par2 + var10), (double)((float)par3 + var11), (double)((float)par4 + var12), new ItemStack(var9.itemID, var13, var9.getItemDamage()));
float var15 = 0.05F;
var14.motionX = (double)((float)this.random.nextGaussian() * var15);
var14.motionY = (double)((float)this.random.nextGaussian() * var15 + 0.2F);
var14.motionZ = (double)((float)this.random.nextGaussian() * var15);
if (var9.hasTagCompound())
{
var14.item.setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
}
}
}
}
} super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
/**
* 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)
{
Object var10 = (ADCTileEntityChest)par1World.getBlockTileEntity(par2, par3, par4); if (var10 == null)
{
return true;
}
else if (par1World.isBlockNormalCube(par2, par3 + 1, par4))
{
return true;
}
else if (isOcelotBlockingChest(par1World, par2, par3, par4))
{
return true;
}
else if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 - 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 - 1, par3, par4)))
{
return true;
}
else if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 + 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 + 1, par3, par4)))
{
return true;
}
else if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 - 1) || isOcelotBlockingChest(par1World, par2, par3, par4 - 1)))
{
return true;
}
else if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 + 1) || isOcelotBlockingChest(par1World, par2, par3, par4 + 1)))
{
return true;
}
else
{
if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID)
{
var10 = new InventoryLargeChest("container.advChestDouble", (ADCTileEntityChest)par1World.getBlockTileEntity(par2 - 1, par3, par4), (IInventory)var10);
}
if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID)
{
var10 = new InventoryLargeChest("container.advChestDouble", (IInventory)var10, (ADCTileEntityChest)par1World.getBlockTileEntity(par2 + 1, par3, par4));
} if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID)
{
var10 = new InventoryLargeChest("container.advChestDouble", (ADCTileEntityChest)par1World.getBlockTileEntity(par2, par3, par4 - 1), (IInventory)var10);
}
if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)
{
var10 = new InventoryLargeChest("container.advChestDouble", (IInventory)var10, (ADCTileEntityChest)par1World.getBlockTileEntity(par2, par3, par4 + 1));
} if (par1World.isRemote)
{
return true;
}
else
{
displayGUIADCChest((IInventory)var10);
return true;
}
}
}
public void displayGUIADCChest(IInventory par1IInventory)
{
ModLoader.getMinecraftInstance().displayGuiScreen(new ADCGuiChest(ModLoader.getMinecraftInstance().thePlayer.inventory, par1IInventory));
}
/**
* each class overrdies this to return a new <className>
*/
public TileEntity createNewTileEntity(World par1World)
{
return new ADCTileEntityChest();
} /**
* Looks for a sitting ocelot within certain bounds. Such an ocelot is considered to be blocking access to the
* chest.
*/
private static boolean isOcelotBlockingChest(World par0World, int par1, int par2, int par3)
{
Iterator var4 = par0World.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)par1, (double)(par2 + 1), (double)par3, (double)(par1 + 1), (double)(par2 + 2), (double)(par3 + 1))).iterator();
EntityOcelot var6;
do
{
if (!var4.hasNext())
{
return false;
} EntityOcelot var5 = (EntityOcelot)var4.next();
var6 = (EntityOcelot)var5;
}
while (!var6.isSitting());
return true;
}
}
ADCContainerChest:
package net.minecraft.src;
public class ADCContainerChest extends Container
{
private IInventory lowerChestInventory;
private int numRows; public ADCContainerChest(IInventory par1IInventory, IInventory par2IInventory)
{
this.lowerChestInventory = par2IInventory;
this.numRows = par2IInventory.getSizeInventory() / 9;
par2IInventory.openChest();
int var3 = (this.numRows - 4) * 18;
int var4;
int var5;
for (var4 = 0; var4 < this.numRows; ++var4)
{
for (var5 = 0; var5 < 9; ++var5)
{
this.addSlotToContainer(new Slot(par2IInventory, var5 + var4 * 9, 8 + var5 * 18, 18 + var4 * 18));
}
} for (var4 = 0; var4 < 3; ++var4)
{
for (var5 = 0; var5 < 9; ++var5)
{
this.addSlotToContainer(new Slot(par1IInventory, var5 + var4 * 9 + 9, 8 + var5 * 18, 103 + var4 * 18 + var3));
}
}
for (var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(par1IInventory, var4, 8 + var4 * 18, 161 + var3));
}
} public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.lowerChestInventory.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
ItemStack var2 = null;
Slot var3 = (Slot)this.inventorySlots.get(par1); if (var3 != null && var3.getHasStack())
{
ItemStack var4 = var3.getStack();
var2 = var4.copy();
if (par1 < this.numRows * 9)
{
if (!this.mergeItemStack(var4, this.numRows * 9, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(var4, 0, this.numRows * 9, false))
{
return null;
} if (var4.stackSize == 0)
{
var3.putStack((ItemStack)null);
}
else
{
var3.onSlotChanged();
}
}
return var2;
} /**
* Callback for when the crafting gui is closed.
*/
public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
{
super.onCraftGuiClosed(par1EntityPlayer);
this.lowerChestInventory.closeChest();
}
}
ADCTileEntityChest:
package net.minecraft.src;
public class ADCTileEntityChest extends TileEntity implements IInventory
{
private ItemStack[] chestContents = new ItemStack[36]; /** Determines if the check for adjacent chests has taken place. */
public boolean adjacentChestChecked = false;
/** Contains the chest tile located adjacent to this one (if any) */
public ADCTileEntityChest adjacentChestZNeg; /** Contains the chest tile located adjacent to this one (if any) */
public ADCTileEntityChest adjacentChestXPos;
/** Contains the chest tile located adjacent to this one (if any) */
public ADCTileEntityChest adjacentChestXNeg; /** Contains the chest tile located adjacent to this one (if any) */
public ADCTileEntityChest adjacentChestZPosition;
/** The current angle of the lid (between 0 and 1) */
public float lidAngle; /** The angle of the lid last tick */
public float prevLidAngle;
/** The number of players currently using this chest */
public int numUsingPlayers; /** Server sync counter (once per 20 ticks) */
private int ticksSinceSync;
/**
* Returns the number of slots in the inventory.
*/
public int getSizeInventory()
{
return 27;
} /**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.chestContents[par1];
}
/**
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
* new stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.chestContents[par1] != null)
{
ItemStack var3; if (this.chestContents[par1].stackSize <= par2)
{
var3 = this.chestContents[par1];
this.chestContents[par1] = null;
this.onInventoryChanged();
return var3;
}
else
{
var3 = this.chestContents[par1].splitStack(par2);
if (this.chestContents[par1].stackSize == 0)
{
this.chestContents[par1] = null;
} this.onInventoryChanged();
return var3;
}
}
else
{
return null;
}
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
* like when you close a workbench GUI.
*/
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.chestContents[par1] != null)
{
ItemStack var2 = this.chestContents[par1];
this.chestContents[par1] = null;
return var2;
}
else
{
return null;
}
} /**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.chestContents[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
} this.onInventoryChanged();
}
/**
* Returns the name of the inventory.
*/
public String getInvName()
{
return "container.chest";
} /**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
this.chestContents = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
int var5 = var4.getByte("Slot") & 255; if (var5 >= 0 && var5 < this.chestContents.length)
{
this.chestContents[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.chestContents.length; ++var3)
{
if (this.chestContents[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte)var3);
this.chestContents[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
par1NBTTagCompound.setTag("Items", var2);
} /**
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
* this more of a set than a get?*
*/
public int getInventoryStackLimit()
{
return 64;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*/
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
} /**
* Causes the TileEntity to reset all it's cached values for it's container block, blockID, metaData and in the case
* of chests, the adjcacent chest check
*/
public void updateContainingBlockInfo()
{
super.updateContainingBlockInfo();
this.adjacentChestChecked = false;
}
/**
* Performs the check for adjacent chests to determine if this chest is double or not.
*/
public void checkForAdjacentChests()
{
if (!this.adjacentChestChecked)
{
this.adjacentChestChecked = true;
this.adjacentChestZNeg = null;
this.adjacentChestXPos = null;
this.adjacentChestXNeg = null;
this.adjacentChestZPosition = null; if (this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) == mod_AdvChest.advChest.blockID)
{
this.adjacentChestXNeg = (ADCTileEntityChest)this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
}
if (this.worldObj.getBlockId(this.xCoord + 1, this.yCoord, this.zCoord) == mod_AdvChest.advChest.blockID)
{
this.adjacentChestXPos = (ADCTileEntityChest)this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
} if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord - 1) == mod_AdvChest.advChest.blockID)
{
this.adjacentChestZNeg = (ADCTileEntityChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
}
if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord + 1) == mod_AdvChest.advChest.blockID)
{
this.adjacentChestZPosition = (ADCTileEntityChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
} if (this.adjacentChestZNeg != null)
{
this.adjacentChestZNeg.updateContainingBlockInfo();
}
if (this.adjacentChestZPosition != null)
{
this.adjacentChestZPosition.updateContainingBlockInfo();
} if (this.adjacentChestXPos != null)
{
this.adjacentChestXPos.updateContainingBlockInfo();
}
if (this.adjacentChestXNeg != null)
{
this.adjacentChestXNeg.updateContainingBlockInfo();
}
}
} /**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
* ticks and creates a new spawn inside its implementation.
*/
public void updateEntity()
{
super.updateEntity();
this.checkForAdjacentChests();
if (++this.ticksSinceSync % 20 * 4 == 0)
{
;
} this.prevLidAngle = this.lidAngle;
float var1 = 0.1F;
double var4;
if (this.numUsingPlayers > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
{
double var2 = (double)this.xCoord + 0.5D;
var4 = (double)this.zCoord + 0.5D; if (this.adjacentChestZPosition != null)
{
var4 += 0.5D;
}
if (this.adjacentChestXPos != null)
{
var2 += 0.5D;
} this.worldObj.playSoundEffect(var2, (double)this.yCoord + 0.5D, var4, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.numUsingPlayers == 0 && this.lidAngle > 0.0F || this.numUsingPlayers > 0 && this.lidAngle < 1.0F)
{
float var8 = this.lidAngle; if (this.numUsingPlayers > 0)
{
this.lidAngle += var1;
}
else
{
this.lidAngle -= var1;
}
if (this.lidAngle > 1.0F)
{
this.lidAngle = 1.0F;
} float var3 = 0.5F;
if (this.lidAngle < var3 && var8 >= var3 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
{
var4 = (double)this.xCoord + 0.5D;
double var6 = (double)this.zCoord + 0.5D; if (this.adjacentChestZPosition != null)
{
var6 += 0.5D;
}
if (this.adjacentChestXPos != null)
{
var4 += 0.5D;
} this.worldObj.playSoundEffect(var4, (double)this.yCoord + 0.5D, var6, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.lidAngle < 0.0F)
{
this.lidAngle = 0.0F;
}
}
} /**
* Called when a client event is received with the event number and argument, see World.sendClientEvent
*/
public void receiveClientEvent(int par1, int par2)
{
if (par1 == 1)
{
this.numUsingPlayers = par2;
}
}
public void openChest()
{
++this.numUsingPlayers;
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, mod_AdvChest.advChest.blockID, 1, this.numUsingPlayers);
} public void closeChest()
{
--this.numUsingPlayers;
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, mod_AdvChest.advChest.blockID, 1, this.numUsingPlayers);
}
/**
* invalidates a tile entity
*/
public void invalidate()
{
this.updateContainingBlockInfo();
this.checkForAdjacentChests();
super.invalidate();
}
}
ADCGuiChest:
package net.minecraft.src;
import java.util.List;import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class ADCGuiChest extends GuiContainer
{
private IInventory upperChestInventory;
private IInventory lowerChestInventory; /**
* window height is calculated with this values, the more rows, the heigher
*/
private int inventoryRows;
public ADCGuiChest(IInventory par1IInventory, IInventory par2IInventory)
{
super(new ADCContainerChest(par1IInventory, par2IInventory));
inventoryRows = 0;
upperChestInventory = par1IInventory;
lowerChestInventory = par2IInventory;
allowUserInput = false;
char c = '\336';
int i = c - 108;
inventoryRows = par2IInventory.getSizeInventory() / 9;
ySize = i + inventoryRows * 18;
xSize = 256;
} public GuiButton options;
public void initGui()
{
super.initGui();
controlList.clear();
options = new GuiButton(0, width / 2 + 50, height / 2 - 100, 50, 20, "Options");
//controlList.add(options);
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer()
{
fontRenderer.drawString("Advanced Chest", 8, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString("***", 185, 6, 0x404040);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
drawDefaultBackground();
int i = mc.renderEngine.getTexture("/advChests/container.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, inventoryRows * 18 + 17);
drawTexturedModalRect(j, k + inventoryRows * 18 + 17, 0, 126, xSize, 96);
}
}
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I am getting the exact same issues. Have you found a solution?
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
It was working fine for me in 1.2.5. No crashes whatsoever.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
From what I can tell, it is crashing because the slot you are clicking on has an ID of 51, but the chest's inventory has only 45 slots. Is the chest any larger than a normal chest?
The chest is the same size. It is doing exactly what you said jabermony; using the chests slots as the inventory.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I have been trying to figure it out for quite some time but can't find where the issue is.
Code:
mod_AdvChest:
ADCBlockChest:
ADCContainerChest:
ADCTileEntityChest:
ADCGuiChest:
together they are powerful beyond imagination."
together they are powerful beyond imagination."
together they are powerful beyond imagination."
together they are powerful beyond imagination."