Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tristanvo.mod.gui;
- import com.tristanvo.mod.blocks.moriumWorkbench;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- public class ContainerModTileEntity extends Container{
- private moriumWorkbench te;
- public ContainerModTileEntity(IInventory inventory, moriumWorkbench te)
- {
- this.te = te;
- for(int y = 0; y < 3; ++y)
- {
- for(int x = 0; x < 3; ++x)
- {
- this.addSlotToContainer(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
- }
- }
- for(int y = 0; y < 3; ++y)
- {
- for(int x = 0; x < 9; ++x)
- {
- this.addSlotToContainer(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
- }
- }
- for(int x = 0; x < 9; ++x)
- {
- this.addSlotToContainer(new Slot(inventory, x, 8 + x * 18, 142));
- }
- }
- @Override
- public boolean canInteractWith(EntityPlayer player) {
- return ((IInventory) this.te).isUseableByPlayer(player);
- }
- @Override
- public ItemStack transferStackInSlot(EntityPlayer player, int fromSlot) {
- ItemStack previous = null;
- Slot slot = (Slot) this.inventorySlots.get(fromSlot);
- if (slot != null && slot.getHasStack())
- {
- ItemStack current = slot.getStack();
- previous = current.copy();
- if (fromSlot < 9)
- {
- if (!this.mergeItemStack(current, 9, 45, true))
- return null;
- }
- else
- {
- if(!this.mergeItemStack(current, 0, 9, false))
- return null;
- }
- if (current.stackSize == 0)
- slot.putStack((ItemStack) null);
- else
- slot.onSlotChanged();
- if (current.stackSize == previous.stackSize)
- return null;
- slot.onPickupFromSlot(player, current);
- }
- return previous;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement