diff options
| author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2020-05-22 20:23:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-22 20:23:55 +0800 |
| commit | 56689ec7b67c46c882d49da4742770e3397a4e9f (patch) | |
| tree | 879a3372906ec2c5f2a53a4ac46f7dde860a654f /src/main/java/common/container/Container_ItemProxyEndpoint.java | |
| parent | bc19f3ab32c9bccbf936bbeffcc8ddad967ffffd (diff) | |
| parent | 306a0822c27c59cdbd0a61698939a2dfc02068d2 (diff) | |
| download | GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.tar.gz GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.tar.bz2 GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.zip | |
Merge pull request #1 from kekzdealer/master
5/22
Diffstat (limited to 'src/main/java/common/container/Container_ItemProxyEndpoint.java')
| -rw-r--r-- | src/main/java/common/container/Container_ItemProxyEndpoint.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/common/container/Container_ItemProxyEndpoint.java b/src/main/java/common/container/Container_ItemProxyEndpoint.java new file mode 100644 index 0000000000..63f836e001 --- /dev/null +++ b/src/main/java/common/container/Container_ItemProxyEndpoint.java @@ -0,0 +1,68 @@ +package common.container; + +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; +import net.minecraft.tileentity.TileEntity; + +public class Container_ItemProxyEndpoint extends Container { + + private final IInventory teInventory; + + private int slotID = 0; + + public Container_ItemProxyEndpoint(TileEntity te, EntityPlayer player) { + this.teInventory = (IInventory) te; + + // Source Slot + addSlotToContainer(new Slot(teInventory, slotID++, 80, 35)); + // Config slot + addSlotToContainer(new Slot(teInventory, slotID++, 100, 35)); + + //Inventory + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + // Hotbar + for (int i = 0; i < 9; i++) { + addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { + ItemStack stack = null; + final Slot slot = (Slot) inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) { + final ItemStack stackInSlot = slot.getStack(); + stack = stackInSlot.copy(); + + if (slotRaw < 3 * 9) { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { + return null; + } + + if (stackInSlot.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + return stack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return teInventory.isUseableByPlayer(player); + } + +} + |
