Guest User

Container

a guest
Apr 5th, 2016
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dmz.icefeeling.ivi.tests;
  2.  
  3. import net.minecraft.client.resources.I18n;
  4. import net.minecraft.entity.item.EntityItem;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.entity.player.InventoryPlayer;
  7. import net.minecraft.inventory.Container;
  8. import net.minecraft.inventory.ContainerBrewingStand;
  9. import net.minecraft.inventory.ICrafting;
  10. import net.minecraft.inventory.IInventory;
  11. import net.minecraft.inventory.InventoryCrafting;
  12. import net.minecraft.inventory.Slot;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.item.crafting.FurnaceRecipes;
  15. import net.minecraft.tileentity.TileEntityFurnace;
  16. import net.minecraft.world.World;
  17. import net.minecraftforge.fml.relauncher.Side;
  18. import net.minecraftforge.fml.relauncher.SideOnly;
  19.  
  20. public class ContainerObsidianAnvil extends Container {
  21.    
  22. private TileEntityObsidianAnvil TEO;
  23.  
  24. public ContainerObsidianAnvil(IInventory playerIn, TileEntityObsidianAnvil TEO) {
  25.         this.TEO = TEO;
  26.  
  27.         this.addSlotToContainer(new Slot(TEO, 0, 1+9, 2+8));
  28.         //Player Inventory
  29.        /* for (int y = 0; y < 3; ++y) {
  30.             for (int x = 0; x < 9; ++x) {
  31.                 this.addSlotToContainer(new Slot(playerIn, x + y * 9 + 9, 8 + x * 18, 41 + y * 18));
  32.             }
  33.         }
  34.         //Player Hotbar
  35.         for (int x = 0; x < 9; ++x) {
  36.             this.addSlotToContainer(new Slot(playerIn, x, 8 + x * 18, 99));
  37.         }*/
  38.         for (int i = 0; i < 3; ++i)
  39.         {
  40.             for (int j = 0; j < 9; ++j)
  41.             {
  42.                 this.addSlotToContainer(new Slot(playerIn, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
  43.             }
  44.         }
  45.  
  46.         for (int k = 0; k < 9; ++k)
  47.         {
  48.             this.addSlotToContainer(new Slot(playerIn, k, 8 + k * 18, 142));
  49.         }
  50. }
  51.     @Override
  52.     public boolean canInteractWith(EntityPlayer playerIn) {
  53.         return this.TEO.isUseableByPlayer(playerIn);
  54.     }
  55.     @Override
  56.     public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
  57.         {
  58.             ItemStack previous = null;
  59.             Slot slot = (Slot) this.inventorySlots.get(fromSlot);
  60.  
  61.             if (slot != null && slot.getHasStack()) {
  62.                 ItemStack current = slot.getStack();
  63.                 previous = current.copy();
  64.  
  65.                 if (fromSlot < 9) {
  66.                     // From TE Inventory to Player Inventory
  67.                     if (!this.mergeItemStack(current, 9, 45, true))
  68.                         return null;
  69.                 } else {
  70.                     // From Player Inventory to TE Inventory
  71.                     if (!this.mergeItemStack(current, 0, 9, false))
  72.                         return null;
  73.                 }
  74.  
  75.                 if (current.stackSize == 0)
  76.                     slot.putStack((ItemStack) null);
  77.                 else
  78.                     slot.onSlotChanged();
  79.  
  80.                 if (current.stackSize == previous.stackSize)
  81.                     return null;
  82.                 slot.onPickupFromSlot(playerIn, current);
  83.             }
  84.             return previous;
  85.         }
  86.     }
  87. }
RAW Paste Data