gt:                     for (int var7 = 0; var7 < var4.size(); ++var7)
context: package net.minecraft.inventory;
  
  import java.util.List;
  import java.util.Random;
  import net.minecraft.enchantment.EnchantmentData;
  import net.minecraft.enchantment.EnchantmentHelper;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.entity.player.InventoryPlayer;
  import net.minecraft.init.Blocks;
  import net.minecraft.init.Items;
  import net.minecraft.item.ItemStack;
  import net.minecraft.world.World;
  
  public class ContainerEnchantment extends Container
  {
      /** SlotEnchantmentTable object with ItemStack to be enchanted */
      public IInventory tableInventory = new InventoryBasic("Enchant", true, 1)
      {
          private static final String __OBFID = "CL_00001746";
          public int getInventoryStackLimit()
          {
              return 1;
          }
          public void onInventoryChanged()
          {
              super.onInventoryChanged();
              ContainerEnchantment.this.onCraftMatrixChanged(this);
          }
      };
  
      /** current world (for bookshelf counting) */
      private World worldPointer;
      private int posX;
      private int posY;
      private int posZ;
      private Random rand = new Random();
  
      /** used as seed for EnchantmentNameParts (see GuiEnchantment) */
      public long nameSeed;
  
      /** 3-member array storing the enchantment levels of each slot */
      public int[] enchantLevels = new int[3];
      private static final String __OBFID = "CL_00001745";
  
      public ContainerEnchantment(InventoryPlayer p_i1811_1_, World p_i1811_2_, int p_i1811_3_, int p_i1811_4_, int p_i1811_5_)
      {
          this.worldPointer = p_i1811_2_;
          this.posX = p_i1811_3_;
          this.posY = p_i1811_4_;
          this.posZ = p_i1811_5_;
          this.addSlotToContainer(new Slot(this.tableInventory, 0, 25, 47)
          {
              private static final String __OBFID = "CL_00001747";
              public boolean isItemValid(ItemStack p_75214_1_)
              {
                  return true;
              }
          });
          int var6;
  
          for (var6 = 0; var6 < 3; ++var6)
          {
              for (int var7 = 0; var7 < 9; ++var7)
              {
                  this.addSlotToContainer(new Slot(p_i1811_1_, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18));
              }
          }
  
          for (var6 = 0; var6 < 9; ++var6)
          {
              this.addSlotToContainer(new Slot(p_i1811_1_, var6, 8 + var6 * 18, 142));
          }
      }
  
      public void onCraftGuiOpened(ICrafting p_75132_1_)
      {
          super.onCraftGuiOpened(p_75132_1_);
          p_75132_1_.sendProgressBarUpdate(this, 0, this.enchantLevels[0]);
          p_75132_1_.sendProgressBarUpdate(this, 1, this.enchantLevels[1]);
          p_75132_1_.sendProgressBarUpdate(this, 2, this.enchantLevels[2]);
      }
  
      /**
       * Looks for changes made in the container, sends them to every listener.
       */
      public void detectAndSendChanges()
      {
          super.detectAndSendChanges();
  
          for (int var1 = 0; var1 < this.crafters.size(); ++var1)
          {
              ICrafting var2 = (ICrafting)this.crafters.get(var1);
              var2.sendProgressBarUpdate(this, 0, this.enchantLevels[0]);
              var2.sendProgressBarUpdate(this, 1, this.enchantLevels[1]);
              var2.sendProgressBarUpdate(this, 2, this.enchantLevels[2]);
          }
      }
  
      /**
       * Callback for when the crafting matrix is changed.
       */
      public void onCraftMatrixChanged(IInventory p_75130_1_)
      {
          if (p_75130_1_ == this.tableInventory)
          {
              ItemStack var2 = p_75130_1_.getStackInSlot(0);
              int var3;
  
              if (var2 != null && var2.isItemEnchantable())
              {
                  this.nameSeed = this.rand.nextLong();
  
                  if (!this.worldPointer.isClient)
                  {
                      var3 = 0;
                      int var4;
  
                      for (var4 = -1; var4 <= 1; ++var4)
                      {
                          for (int var5 = -1; var5 <= 1; ++var5)
                          {
                              if ((var4 != 0 || var5 != 0) && this.worldPointer.isAirBlock(this.posX + var5, this.posY, this.posZ + var4) && this.worldPointer.isAirBlock(this.posX + var5, this.posY + 1, this.posZ + var4))
                              {
                                  if (this.worldPointer.getBlock(this.posX + var5 * 2, this.posY, this.posZ + var4 * 2) == Blocks.bookshelf)
                                  {
                                      ++var3;
                                  }
  
                                  if (this.worldPointer.getBlock(this.posX + var5 * 2, this.posY + 1, this.posZ + var4 * 2) == Blocks.bookshelf)
                                  {
                                      ++var3;
                                  }
  
                                  if (var5 != 0 && var4 != 0)
                                  {
                                      if (this.worldPointer.getBlock(this.posX + var5 * 2, this.posY, this.posZ + var4) == Blocks.bookshelf)
                                      {
                                          ++var3;
                                      }
  
                                      if (this.worldPointer.getBlock(this.posX + var5 * 2, this.posY + 1, this.posZ + var4) == Blocks.bookshelf)
                                      {
                                          ++var3;
                                      }
  
                                      if (this.worldPointer.getBlock(this.posX + var5, this.posY, this.posZ + var4 * 2) == Blocks.bookshelf)
                                      {
                                          ++var3;
                                      }
  
                                      if (this.worldPointer.getBlock(this.posX + var5, this.posY + 1, this.posZ + var4 * 2) == Blocks.bookshelf)
                                      {
                                          ++var3;
                                      }
                                  }
                              }
                          }
                      }
  
                      for (var4 = 0; var4 < 3; ++var4)
                      {
                          this.enchantLevels[var4] = EnchantmentHelper.calcItemStackEnchantability(this.rand, var4, var3, var2);
                      }
  
                      this.detectAndSendChanges();
                  }
              }
              else
              {
                  for (var3 = 0; var3 < 3; ++var3)
                  {
                      this.enchantLevels[var3] = 0;
                  }
              }
          }
      }
  
      /**
       * enchants the item on the table using the specified slot; also deducts XP from player
       */
      public boolean enchantItem(EntityPlayer p_75140_1_, int p_75140_2_)
      {
          ItemStack var3 = this.tableInventory.getStackInSlot(0);
  
          if (this.enchantLevels[p_75140_2_] > 0 && var3 != null && (p_75140_1_.experienceLevel >= this.enchantLevels[p_75140_2_] || p_75140_1_.capabilities.isCreativeMode))
          {
              if (!this.worldPointer.isClient)
              {
                  List var4 = EnchantmentHelper.buildEnchantmentList(this.rand, var3, this.enchantLevels[p_75140_2_]);
                  boolean var5 = var3.getItem() == Items.book;
  
                  if (var4 != null)
                  {
                      p_75140_1_.addExperienceLevel(-this.enchantLevels[p_75140_2_]);
  
                      if (var5)
                      {
                          var3.func_150996_a(Items.enchanted_book);
                      }
  
                      int var6 = var5 && var4.size() > 1 ? this.rand.nextInt(var4.size()) : -1;
  
  