Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContainerDeck extends Container
- {
- private final int numRows;
- public ContainerDeck(InventoryPlayer playerInv, EntityPlayer player)
- {
- this.numRows = 2;
- for(int y = 0; y < this.numRows; y++)
- {
- for(int x = 0; x < 9; x++)
- {
- this.addSlotToContainer(new SlotItemInv(player.getHeldItemMainhand().getCapability(DeckDataCapability.CAPABILITY, null), x + y * 9, 8 + x * 18, (16 * y + 16) + y * 2));
- }
- }
- for (int i = 0; i < 3; ++i)
- {
- for (int j = 0; j < 9; ++j)
- {
- this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
- for (int k = 0; k < 9; ++k)
- {
- this.addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142));
- }
- }
- /**
- * Take a stack from the specified inventory slot.
- */
- @Nullable
- public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot) this.inventorySlots.get(index);
- if (slot != null && slot.getHasStack())
- {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if (index < this.numRows * 9)
- {
- if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true))
- {
- return null;
- }
- } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false))
- {
- return null;
- }
- if (itemstack1.stackSize == 0)
- {
- slot.putStack((ItemStack) null);
- } else
- {
- slot.onSlotChanged();
- }
- if (itemstack1.stackSize == itemstack.stackSize)
- {
- return null;
- }
- slot.onPickupFromSlot(playerIn, itemstack1);
- }
- return itemstack;
- }
- @Override
- public boolean canInteractWith(EntityPlayer playerIn)
- {
- return true;
- }
- @Override
- public ItemStack slotClick(int slot, int button, ClickType clickTypeIn, EntityPlayer player)
- {
- if (slot >= 0 && getSlot(slot) != null
- && getSlot(slot).getStack() == player.getHeldItemMainhand())
- {
- return null;
- }
- return super.slotClick(slot, button, clickTypeIn, player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement