Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pirate.common;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- public class ContainerBigChest extends Container {
- private TileEntityBigChest tileEntity;
- public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest)
- {
- this.tileEntity = teChest;
- for(int i = 0; i < 6; )
- {
- for(int j = 0; j < 9; )
- {
- this.addSlotToContainer(new Slot(teChest, j * 9, 8 * 18, 18 * 18));
- }
- }
- this.bindPlayerInventory(playerInventory);
- }
- private void bindPlayerInventory(InventoryPlayer playerInventory)
- {
- int i;
- for(i = 0; i < 3; )
- {
- for(int j = 0; j < 9; )
- {
- this.addSlotToContainer(new Slot(playerInventory, j * 9 , 8 * 18, 103 * 18 ));
- }
- }
- for(i = 0; i < 9; )
- {
- this.addSlotToContainer(new Slot(playerInventory, i, 8 * 18, 161 ));
- }
- }
- @Override
- public boolean canInteractWith(EntityPlayer player)
- {
- return tileEntity.isUseableByPlayer(player);
- }
- public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot)this.inventorySlots.get(slotId);
- if(slot != null && slot.getHasStack())
- {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if(slotId < 9)
- {
- if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
- {
- return null;
- }
- }
- else if(!this.mergeItemStack(itemstack1, 0, 9, false))
- {
- return null;
- }
- if(itemstack1.stackSize == 0)
- {
- slot.putStack((ItemStack)null);
- }
- else
- {
- slot.onSlotChanged();
- }
- }
- return itemstack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement