From fea89499d449a215b0b9ec3012b76c0ef35815f5 Mon Sep 17 00:00:00 2001 From: Christina Berchtold Date: Wed, 29 Apr 2020 10:23:20 +0200 Subject: split gui-/containers into client/common packages --- .../container/Container_ModularNuclearReactor.java | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/main/java/common/container/Container_ModularNuclearReactor.java (limited to 'src/main/java/common/container/Container_ModularNuclearReactor.java') diff --git a/src/main/java/common/container/Container_ModularNuclearReactor.java b/src/main/java/common/container/Container_ModularNuclearReactor.java new file mode 100644 index 0000000000..2b19cc4052 --- /dev/null +++ b/src/main/java/common/container/Container_ModularNuclearReactor.java @@ -0,0 +1,87 @@ +package common.container; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import reactor.ButtonSlot; + +public class Container_ModularNuclearReactor extends Container { + + private int nextSlotID = 0; + private final Slot[] REACTOR_SLOTS = new Slot[54]; + private final Slot SLOT_CONFIGURATION; + private final Slot BUTTON_EU_MODE; + private final Slot BUTTON_FLUID_MODE; + private final Slot BUTTON_CONDITION; + private final Slot BUTTON_CONFIGURE; + private final Slot BUTTON_RESET; + + + public Container_ModularNuclearReactor(IGregTechTileEntity te, EntityPlayer player) { + + // Add the reactor chamber + for(int x = 0; x < 9; x++) { + for(int y = 0; y < 6; y++){ + REACTOR_SLOTS[nextSlotID] = super.addSlotToContainer(new Slot(te, getNextSlotID(), (16 + 67 * x), (16 + 67 * y))); + } + } + // Add the configuration slot + SLOT_CONFIGURATION = super.addSlotToContainer(new Slot(te, getNextSlotID(), 0, 0)); + + // Add buttons (they're also slots) + BUTTON_EU_MODE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0)); + BUTTON_FLUID_MODE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0)); + BUTTON_CONDITION = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0)); + BUTTON_CONFIGURE = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0)); + BUTTON_RESET = super.addSlotToContainer(new ButtonSlot(te, getNextSlotID(), 0, 0)); + + } + + private int getNextSlotID() { + nextSlotID++; + return nextSlotID - 1; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) + { + ItemStack stack = null; + Slot slot = (Slot)inventorySlots.get(slotRaw); + + if (slot != null && slot.getHasStack()) + { + 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 p_75145_1_) { + return true; + } + +} -- cgit From a90d13e848293cf664774168f14772c4a63ced00 Mon Sep 17 00:00:00 2001 From: kekzdealer Date: Thu, 7 May 2020 20:19:46 +0200 Subject: code formatting --- .../container/Container_ModularNuclearReactor.java | 37 ++++++++-------------- 1 file changed, 14 insertions(+), 23 deletions(-) (limited to 'src/main/java/common/container/Container_ModularNuclearReactor.java') diff --git a/src/main/java/common/container/Container_ModularNuclearReactor.java b/src/main/java/common/container/Container_ModularNuclearReactor.java index 2b19cc4052..f5430351e5 100644 --- a/src/main/java/common/container/Container_ModularNuclearReactor.java +++ b/src/main/java/common/container/Container_ModularNuclearReactor.java @@ -43,36 +43,27 @@ public class Container_ModularNuclearReactor extends Container { nextSlotID++; return nextSlotID - 1; } - + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) - { + public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw) { ItemStack stack = null; - Slot slot = (Slot)inventorySlots.get(slotRaw); - - if (slot != null && slot.getHasStack()) - { - ItemStack stackInSlot = slot.getStack(); + 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)) - { + + if (slotRaw < 3 * 9) { + if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true)) { return null; } - } - else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) - { + } else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false)) { return null; } - - if (stackInSlot.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { + + if (stackInSlot.stackSize == 0) { + slot.putStack(null); + } else { slot.onSlotChanged(); } } -- cgit