gt:                 ItemStack itemstack = tileentitychest.getStackInSlot(j1);
context: package com.Whatsmename.OaGP.block.storage;
  
  import cpw.mods.fml.relauncher.Side;
  import cpw.mods.fml.relauncher.SideOnly;
  import java.util.Iterator;
  import java.util.Random;
  
  import com.Whatsmename.OaGP.OaGP;
  import com.Whatsmename.OaGP.container.ModBlockContainer;
  import com.Whatsmename.OaGP.entity.TileEntityLegacyChest;
  import com.Whatsmename.OaGP.lib.BlockIDs;
  import com.Whatsmename.OaGP.lib.Reference;
  import com.Whatsmename.OaGP.lib.Strings;
  
  import net.minecraft.block.Block;
  import net.minecraft.block.material.Material;
  import net.minecraft.client.renderer.texture.IconRegister;
  import net.minecraft.entity.EntityLiving;
  import net.minecraft.entity.item.EntityItem;
  import net.minecraft.entity.passive.EntityOcelot;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.inventory.Container;
  import net.minecraft.inventory.IInventory;
  import net.minecraft.inventory.InventoryLargeChest;
  import net.minecraft.item.ItemStack;
  import net.minecraft.nbt.NBTTagCompound;
  import net.minecraft.tileentity.TileEntity;
  import net.minecraft.util.AxisAlignedBB;
  import net.minecraft.util.MathHelper;
  import net.minecraft.world.IBlockAccess;
  import net.minecraft.world.World;
  
  import static net.minecraftforge.common.ForgeDirection.*;
  
  public class LegacyChest extends ModBlockContainer {
      private final Random random = new Random();
  	public int isTrapped;
  
      public LegacyChest(int par1) {
          super(par1, Material.rock);
          this.setCreativeTab(OaGP.TabOaGP);
          this.setResistance(3);
          this.setHardness(60);
          this.setUnlocalizedName(Strings.CHESTLEGACY_NAME);
          this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
      }
  
      /**
       * 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;
      }
  
      /**
       * Updates the blocks bounds based on its current state. Args: world, x, y, z
       */
      public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
      {
          if (par1IBlockAccess.getBlockId(par2, par3, par4 - 1) == BlockIDs.CHESTLEGACY_ID)
          {
              this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
          }
          else if (par1IBlockAccess.getBlockId(par2, par3, par4 + 1) == BlockIDs.CHESTLEGACY_ID)
          {
              this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
          }
          else if (par1IBlockAccess.getBlockId(par2 - 1, par3, par4) == BlockIDs.CHESTLEGACY_ID)
          {
              this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
          }
          else if (par1IBlockAccess.getBlockId(par2 + 1, par3, par4) == BlockIDs.CHESTLEGACY_ID)
          {
              this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
          }
          else
          {
              this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
          }
      }
  
      /**
       * 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 l = par1World.getBlockId(par2, par3, par4 - 1);
          int i1 = par1World.getBlockId(par2, par3, par4 + 1);
          int j1 = par1World.getBlockId(par2 - 1, par3, par4);
          int k1 = par1World.getBlockId(par2 + 1, par3, par4);
  
          if (l == BlockIDs.CHESTLEGACY_ID)
          {
              this.unifyAdjacentChests(par1World, par2, par3, par4 - 1);
          }
  
          if (i1 == BlockIDs.CHESTLEGACY_ID)
          {
              this.unifyAdjacentChests(par1World, par2, par3, par4 + 1);
          }
  
          if (j1 == BlockIDs.CHESTLEGACY_ID)
          {
              this.unifyAdjacentChests(par1World, par2 - 1, par3, par4);
          }
  
          if (k1 == BlockIDs.CHESTLEGACY_ID)
          {
              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, ItemStack par6ItemStack)
      {
          int l = par1World.getBlockId(par2, par3, par4 - 1);
          int i1 = par1World.getBlockId(par2, par3, par4 + 1);
          int j1 = par1World.getBlockId(par2 - 1, par3, par4);
          int k1 = par1World.getBlockId(par2 + 1, par3, par4);
          byte b0 = 0;
          int l1 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  
          if (l1 == 0)
          {
              b0 = 2;
          }
  
          if (l1 == 1)
          {
              b0 = 5;
          }
  
          if (l1 == 2)
          {
              b0 = 3;
          }
  
          if (l1 == 3)
          {
              b0 = 4;
          }
  
          if (l != BlockIDs.CHESTLEGACY_ID && i1 != BlockIDs.CHESTLEGACY_ID && j1 != BlockIDs.CHESTLEGACY_ID && k1 != BlockIDs.CHESTLEGACY_ID)
          {
              par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 3);
          }
          else
          {
              if ((l == BlockIDs.CHESTLEGACY_ID || i1 == BlockIDs.CHESTLEGACY_ID) && (b0 == 4 || b0 == 5))
              {
                  if (l == BlockIDs.CHESTLEGACY_ID)
                  {
                      par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, b0, 3);
                  }
                  else
                  {
                      par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, b0, 3);
                  }
  
                  par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 3);
              }
  
              if ((j1 == BlockIDs.CHESTLEGACY_ID || k1 == BlockIDs.CHESTLEGACY_ID) && (b0 == 2 || b0 == 3))
              {
                  if (j1 == BlockIDs.CHESTLEGACY_ID)
                  {
                      par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, b0, 3);
                  }
                  else
                  {
                      par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, b0, 3);
                  }
  
                  par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 3);
              }
          }
  
          if (par6ItemStack.hasDisplayName())
          {
              ((TileEntityLegacyChest)par1World.getBlockTileEntity(par2, par3, par4)).func_94043_a(par6ItemStack.getDisplayName());
          }
      }
  
      /**
       * Turns the adjacent chests to a double chest.
       */
      public void unifyAdjacentChests(World par1World, int par2, int par3, int par4)
      {
          if (!par1World.isRemote)
          {
              int l = par1World.getBlockId(par2, par3, par4 - 1);
              int i1 = par1World.getBlockId(par2, par3, par4 + 1);
              int j1 = par1World.getBlockId(par2 - 1, par3, par4);
              int k1 = par1World.getBlockId(par2 + 1, par3, par4);
              int l1;
              int i2;
              byte b0;
              int j2;
  
              if (l != BlockIDs.CHESTLEGACY_ID && i1 != BlockIDs.CHESTLEGACY_ID)
              {
                  if (j1 != BlockIDs.CHESTLEGACY_ID && k1 != BlockIDs.CHESTLEGACY_ID)
                  {
                      b0 = 3;
  
                      if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])
                      {
                          b0 = 3;
                      }
  
                      if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])
                      {
                          b0 = 2;
                      }
  
                      if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])
                      {
                          b0 = 5;
                      }
  
                      if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])
                      {
                          b0 = 4;
                      }
                  }
                  else
                  {
                      l1 = par1World.getBlockId(j1 == BlockIDs.CHESTLEGACY_ID ? par2 - 1 : par2 + 1, par3, par4 - 1);
                      i2 = par1World.getBlockId(j1 == BlockIDs.CHESTLEGACY_ID ? par2 - 1 : par2 + 1, par3, par4 + 1);
                      b0 = 3;
                      if (j1 == BlockIDs.CHESTLEGACY_ID)
                      {
                          j2 = par1World.getBlockMetadata(par2 - 1, par3, par4);
                      }
                      else
                      {
                          j2 = par1World.getBlockMetadata(par2 + 1, par3, par4);
                      }
  
                      if (j2 == 2)
                      {
                          b0 = 2;
                      }
  
                      if ((Block.opaqueCubeLookup[l] || Block.opaqueCubeLookup[l1]) && !Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[i2])
                      {
                          b0 = 3;
                      }
  
                      if ((Block.opaqueCubeLookup[i1] || Block.opaqueCubeLookup[i2]) && !Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[l1])
                      {
                          b0 = 2;
                      }
                  }
              }
              else
              {
                  l1 = par1World.getBlockId(par2 - 1, par3, l == BlockIDs.CHESTLEGACY_ID ? par4 - 1 : par4 + 1);
                  i2 = par1World.getBlockId(par2 + 1, par3, l == BlockIDs.CHESTLEGACY_ID ? par4 - 1 : par4 + 1);
                  b0 = 5;
                  if (l == BlockIDs.CHESTLEGACY_ID)
                  {
                      j2 = par1World.getBlockMetadata(par2, par3, par4 - 1);
                  }
                  else
                  {
                      j2 = par1World.getBlockMetadata(par2, par3, par4 + 1);
                  }
  
                  if (j2 == 4)
                  {
                      b0 = 4;
                  }
  
                  if ((Block.opaqueCubeLookup[j1] || Block.opaqueCubeLookup[l1]) && !Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[i2])
                  {
                      b0 = 5;
                  }
  
                  if ((Block.opaqueCubeLookup[k1] || Block.opaqueCubeLookup[i2]) && !Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[l1])
                  {
                      b0 = 4;
                  }
              }
  
              par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 3);
          }
      }
  
      /**
       * 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 l = 0;
  
          if (par1World.getBlockId(par2 - 1, par3, par4) == BlockIDs.CHESTLEGACY_ID)
          {
              ++l;
          }
  
          if (par1World.getBlockId(par2 + 1, par3, par4) == BlockIDs.CHESTLEGACY_ID)
          {
              ++l;
          }
  
          if (par1World.getBlockId(par2, par3, par4 - 1) == BlockIDs.CHESTLEGACY_ID)
          {
              ++l;
          }
  
          if (par1World.getBlockId(par2, par3, par4 + 1) == BlockIDs.CHESTLEGACY_ID)
          {
              ++l;
          }
  
          return l > 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) != BlockIDs.CHESTLEGACY_ID ? false : (par1World.getBlockId(par2 - 1, par3, par4) == BlockIDs.CHESTLEGACY_ID ? true : (par1World.getBlockId(par2 + 1, par3, par4) == BlockIDs.CHESTLEGACY_ID ? true : (par1World.getBlockId(par2, par3, par4 - 1) == BlockIDs.CHESTLEGACY_ID ? true : par1World.getBlockId(par2, par3, par4 + 1) == BlockIDs.CHESTLEGACY_ID)));
      }
  
      /**
       * 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);
          TileEntityLegacyChest tileentitychest = (TileEntityLegacyChest)par1World.getBlockTileEntity(par2, par3, par4);
  
          if (tileentitychest != null)
          {
              tileentitychest.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)
      {
      	TileEntityLegacyChest tileentitychest = (TileEntityLegacyChest)par1World.getBlockTileEntity(par2, par3, par4);
  
          if (tileentitychest != null)
          {
              for (int j1 = 0; j1 < tileentitychest.getSizeInventory(); ++j1)
              {
  