Advertisement
Guest User

Untitled

a guest
Feb 15th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. package pirate.common;
  2. import net.minecraft.entity.player.EntityPlayer;
  3. import net.minecraft.entity.player.InventoryPlayer;
  4. import net.minecraft.inventory.Container;
  5. import net.minecraft.inventory.Slot;
  6. import net.minecraft.item.ItemStack;
  7.  
  8. public class ContainerBigChest extends Container {
  9.    
  10.     private TileEntityBigChest tileEntity;
  11.      
  12.         public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest)
  13.         {
  14.             this.tileEntity = teChest;
  15.            
  16.             for(int i = 0; i < 6; )
  17.             {
  18.                 for(int j = 0; j < 9; )
  19.                 {
  20.                     this.addSlotToContainer(new Slot(teChest, j   * 9, 8   * 18, 18   * 18));
  21.                 }
  22.             }
  23.             this.bindPlayerInventory(playerInventory);
  24.         }
  25.        
  26.         private void bindPlayerInventory(InventoryPlayer playerInventory)
  27.         {
  28.             int i;
  29.             for(i = 0; i < 3; )
  30.             {
  31.                 for(int j = 0; j < 9; )
  32.                 {
  33.                     this.addSlotToContainer(new Slot(playerInventory, j   * 9  , 8   * 18, 103   * 18  ));
  34.                 }
  35.             }
  36.      
  37.             for(i = 0; i < 9; )
  38.             {
  39.                 this.addSlotToContainer(new Slot(playerInventory, i, 8   * 18, 161  ));
  40.             }
  41.         }
  42.      
  43.         @Override
  44.         public boolean canInteractWith(EntityPlayer player)
  45.         {
  46.             return tileEntity.isUseableByPlayer(player);
  47.         }
  48.      
  49.         public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
  50.         {
  51.             ItemStack itemstack = null;
  52.             Slot slot = (Slot)this.inventorySlots.get(slotId);
  53.      
  54.             if(slot != null && slot.getHasStack())
  55.             {
  56.                 ItemStack itemstack1 = slot.getStack();
  57.                 itemstack = itemstack1.copy();
  58.      
  59.                 if(slotId < 9)
  60.                 {
  61.                     if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
  62.                     {
  63.                         return null;
  64.                     }
  65.                 }
  66.                 else if(!this.mergeItemStack(itemstack1, 0, 9, false))
  67.                 {
  68.                     return null;
  69.                 }
  70.      
  71.                 if(itemstack1.stackSize == 0)
  72.                 {
  73.                     slot.putStack((ItemStack)null);
  74.                 }
  75.                 else
  76.                 {
  77.                     slot.onSlotChanged();
  78.                 }
  79.             }
  80.             return itemstack;
  81.         }
  82.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement