From 15a270851304fd3204bfbc2cf2c6268f3a6b06c8 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 30 May 2016 07:53:03 +1000 Subject: +Cleaned up Helium Generator GUI +Rewrote portions of the HG from scratch --- .../miscutil/core/handler/InvSlotRadiation.java | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Java/miscutil/core/handler/InvSlotRadiation.java (limited to 'src/Java/miscutil/core/handler/InvSlotRadiation.java') diff --git a/src/Java/miscutil/core/handler/InvSlotRadiation.java b/src/Java/miscutil/core/handler/InvSlotRadiation.java new file mode 100644 index 0000000000..cafb71f00c --- /dev/null +++ b/src/Java/miscutil/core/handler/InvSlotRadiation.java @@ -0,0 +1,73 @@ +package miscutil.core.handler; + +import ic2.core.block.invslot.InvSlot; +import miscutil.core.tileentities.TileEntityHeliumGenerator; +import net.minecraft.item.ItemStack; + +public class InvSlotRadiation extends InvSlot +{ + public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count) + { + super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); + + setStackSizeLimit(1); + } + + public boolean accepts(ItemStack itemStack) + { + return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true); + } + + public int size() + { + return ((TileEntityHeliumGenerator)this.base).getReactorSize() * 6; + } + + public int rawSize() + { + return super.size(); + } + + public ItemStack get(int index) + { + return super.get(mapIndex(index)); + } + + public ItemStack get(int x, int y) + { + return super.get(y * 9 + x); + } + + public void put(int index, ItemStack content) + { + super.put(mapIndex(index), content); + } + + public void put(int x, int y, ItemStack content) + { + super.put(y * 9 + x, content); + } + + private int mapIndex(int index) + { + int size = size(); + int cols = size / 6; + if (index < size) + { + int row = index / cols; + int col = index % cols; + + return row * 9 + col; + } + index -= size; + int remCols = 9 - cols; + + int row = index / remCols; + int col = cols + index % remCols; + + return row * 9 + col; + } + + private final int rows = 6; + private final int maxCols = 9; +} -- cgit