diff options
Diffstat (limited to 'src/main/java/gregtech/common/gui')
46 files changed, 1727 insertions, 3103 deletions
diff --git a/src/main/java/gregtech/common/gui/GT_ContainerVolumetricFlask.java b/src/main/java/gregtech/common/gui/GT_ContainerVolumetricFlask.java deleted file mode 100644 index 2f8fd2a356..0000000000 --- a/src/main/java/gregtech/common/gui/GT_ContainerVolumetricFlask.java +++ /dev/null @@ -1,20 +0,0 @@ -package gregtech.common.gui; - -import gregtech.common.items.GT_VolumetricFlask; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; - -public final class GT_ContainerVolumetricFlask extends Container { - ItemStack flask; - - public GT_ContainerVolumetricFlask(InventoryPlayer inventoryPlayer) { - flask = inventoryPlayer.getCurrentItem(); - } - - @Override - public boolean canInteractWith(EntityPlayer p) { - return (flask != null) && (flask.stackSize > 0) && ((flask.getItem() instanceof GT_VolumetricFlask)); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_AdvDebugStructureWriter.java b/src/main/java/gregtech/common/gui/GT_Container_AdvDebugStructureWriter.java deleted file mode 100644 index 15837364f5..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_AdvDebugStructureWriter.java +++ /dev/null @@ -1,213 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.debug.GT_MetaTileEntity_AdvDebugStructureWriter; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_AdvDebugStructureWriter extends GT_ContainerMetaTile_Machine { - public short[] numbers = new short[6]; - public boolean transpose; - public boolean showHighlightBox; - - public Slot printSlot; - public Slot transposeSlot; - public Slot highlightSlot; - - public GT_Container_AdvDebugStructureWriter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 63, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 81, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 99, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 63, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 81, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 99, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 63, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 81, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 99, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 63, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 81, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 99, false, false, 1)); - - printSlot = addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 12, 129, false, false, 1)); - transposeSlot = addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 33, 129, false, false, 1)); - highlightSlot = addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 54, 129, false, false, 1)); - } - - public boolean doesBindPlayerInventory() { - return false; - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { - GT_MetaTileEntity_AdvDebugStructureWriter dsw = - (GT_MetaTileEntity_AdvDebugStructureWriter) mTileEntity.getMetaTileEntity(); - if (dsw.numbers == null) { - return null; - } - switch (aSlotIndex) { - case 0: - dsw.numbers[0] -= aShifthold == 1 ? 512 : 64; - return null; - case 1: - dsw.numbers[1] -= aShifthold == 1 ? 512 : 64; - return null; - case 2: - dsw.numbers[2] -= aShifthold == 1 ? 512 : 64; - return null; - case 3: - dsw.numbers[3] -= aShifthold == 1 ? 512 : 64; - return null; - case 4: - dsw.numbers[4] -= aShifthold == 1 ? 512 : 64; - return null; - case 5: - dsw.numbers[5] -= aShifthold == 1 ? 512 : 64; - return null; - case 6: - dsw.numbers[0] -= aShifthold == 1 ? 16 : 1; - return null; - case 7: - dsw.numbers[1] -= aShifthold == 1 ? 16 : 1; - return null; - case 8: - dsw.numbers[2] -= aShifthold == 1 ? 16 : 1; - return null; - case 9: - dsw.numbers[3] -= aShifthold == 1 ? 16 : 1; - return null; - case 10: - dsw.numbers[4] -= aShifthold == 1 ? 16 : 1; - return null; - case 11: - dsw.numbers[5] -= aShifthold == 1 ? 16 : 1; - return null; - case 12: - dsw.numbers[0] += aShifthold == 1 ? 512 : 64; - return null; - case 13: - dsw.numbers[1] += aShifthold == 1 ? 512 : 64; - return null; - case 14: - dsw.numbers[2] += aShifthold == 1 ? 512 : 64; - return null; - case 15: - dsw.numbers[3] += aShifthold == 1 ? 512 : 64; - return null; - case 16: - dsw.numbers[4] += aShifthold == 1 ? 512 : 64; - return null; - case 17: - dsw.numbers[5] += aShifthold == 1 ? 512 : 64; - return null; - case 18: - dsw.numbers[0] += aShifthold == 1 ? 16 : 1; - return null; - case 19: - dsw.numbers[1] += aShifthold == 1 ? 16 : 1; - return null; - case 20: - dsw.numbers[2] += aShifthold == 1 ? 16 : 1; - return null; - case 21: - dsw.numbers[3] += aShifthold == 1 ? 16 : 1; - return null; - case 22: - dsw.numbers[4] += aShifthold == 1 ? 16 : 1; - return null; - case 23: - dsw.numbers[5] += aShifthold == 1 ? 16 : 1; - return null; - - case 24: - if (dsw.getBaseMetaTileEntity().isServerSide()) { - dsw.printStructure(aPlayer); - } - return null; - case 25: - dsw.transpose = !dsw.transpose; - return null; - case 26: - dsw.showHighlightBox = !dsw.showHighlightBox; - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - GT_MetaTileEntity_AdvDebugStructureWriter dsw = - (GT_MetaTileEntity_AdvDebugStructureWriter) mTileEntity.getMetaTileEntity(); - if (numbers != null) { - System.arraycopy(dsw.numbers, 0, numbers, 0, dsw.numbers.length); - } - - transpose = dsw.transpose; - showHighlightBox = dsw.showHighlightBox; - - for (Object crafter : crafters) { - ICrafting var1 = (ICrafting) crafter; - if (numbers != null) { - var1.sendProgressBarUpdate(this, 100, numbers[0]); - var1.sendProgressBarUpdate(this, 101, numbers[1]); - var1.sendProgressBarUpdate(this, 102, numbers[2]); - var1.sendProgressBarUpdate(this, 103, numbers[3]); - var1.sendProgressBarUpdate(this, 104, numbers[4]); - var1.sendProgressBarUpdate(this, 105, numbers[5]); - var1.sendProgressBarUpdate(this, 106, transpose ? 1 : 0); - var1.sendProgressBarUpdate(this, 107, showHighlightBox ? 1 : 0); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - if (par1 == 106) { - transpose = par2 > 0; - } else if (par1 == 107) { - showHighlightBox = par2 > 0; - } else { - if (numbers != null && par1 >= 100 && par1 <= 105) { - numbers[par1 - 100] = (short) par2; - } - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java deleted file mode 100644 index a29e732f07..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java +++ /dev/null @@ -1,99 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - -public class GT_Container_Boiler extends GT_ContainerMetaTile_Machine { - public int mWaterAmount = 0; - public int mSteamAmount = 0; - public int mProcessingEnergy = 0; - public int mTemperature = 2; - - public GT_Container_Boiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); - addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); - } - - @Override - public int getSlotCount() { - return 4; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - - // GT_MetaTileEntity_Boiler.getCapacity() is used for both water and steam capacity. - int capacity = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).getCapacity(); - - this.mTemperature = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mTemperature; - this.mProcessingEnergy = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; - this.mSteamAmount = (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mSteam == null - ? 0 - : ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mSteam.amount); - this.mWaterAmount = (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid == null - ? 0 - : ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid.amount); - - this.mTemperature = Math.min( - 54, - Math.max( - 0, - this.mTemperature - * 54 - / (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - - 10))); - this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (capacity - 100))); - this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / (capacity - 100))); - this.mProcessingEnergy = - Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); - - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; - player.sendProgressBarUpdate(this, 100, this.mTemperature); - player.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); - player.sendProgressBarUpdate(this, 102, this.mSteamAmount); - player.sendProgressBarUpdate(this, 103, this.mWaterAmount); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - this.mTemperature = value; - break; - case 101: - this.mProcessingEnergy = value; - break; - case 102: - this.mSteamAmount = value; - break; - case 103: - this.mWaterAmount = value; - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_BronzeBlastFurnace.java b/src/main/java/gregtech/common/gui/GT_Container_BronzeBlastFurnace.java deleted file mode 100644 index ac2f18f561..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_BronzeBlastFurnace.java +++ /dev/null @@ -1,31 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Output; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -public class GT_Container_BronzeBlastFurnace extends GT_ContainerMetaTile_Machine { - public GT_Container_BronzeBlastFurnace(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(this.mTileEntity, 0, 34, 16)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 34, 34)); - addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 2, 86, 25)); - addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 3, 104, 25)); - } - - @Override - public int getSlotCount() { - return 4; - } - - @Override - public int getShiftClickSlotCount() { - return 2; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java deleted file mode 100644 index afa22a738b..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_ChestBuffer.java +++ /dev/null @@ -1,102 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.automation.GT_MetaTileEntity_ChestBuffer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_ChestBuffer extends GT_ContainerMetaTile_Machine { - public GT_Container_ChestBuffer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(this.mTileEntity, x + y * 9, 8 + x * 18, 5 + y * 18)); - } - } - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 62, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 27) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex == 27) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); - } - return null; - } - if (aSlotIndex == 28) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("118", "Emit Redstone if no Slot is free")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("119", "Don't emit Redstone")); - } - return null; - } - if (aSlotIndex == 29) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120", "Invert Redstone")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121", "Don't invert Redstone")); - } - return null; - } - if (aSlotIndex == 30) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans( - "217", - "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.")); - } else { - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans( - "218", - "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); - } - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 27; - } - - @Override - public int getShiftClickSlotCount() { - return 27; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_Filter.java b/src/main/java/gregtech/common/gui/GT_Container_Filter.java deleted file mode 100644 index d4aabe0cb4..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_Filter.java +++ /dev/null @@ -1,138 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.automation.GT_MetaTileEntity_Filter; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_Filter extends GT_ContainerMetaTile_Machine { - public GT_Container_Filter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(this.mTileEntity, 0, 98, 5)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 116, 5)); - addSlotToContainer(new Slot(this.mTileEntity, 2, 134, 5)); - addSlotToContainer(new Slot(this.mTileEntity, 3, 98, 23)); - addSlotToContainer(new Slot(this.mTileEntity, 4, 116, 23)); - addSlotToContainer(new Slot(this.mTileEntity, 5, 134, 23)); - addSlotToContainer(new Slot(this.mTileEntity, 6, 98, 41)); - addSlotToContainer(new Slot(this.mTileEntity, 7, 116, 41)); - addSlotToContainer(new Slot(this.mTileEntity, 8, 134, 41)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 9, 18, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 35, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 11, 52, 6, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 12, 18, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 13, 35, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 14, 52, 23, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 15, 18, 40, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 16, 35, 40, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 17, 52, 40, false, true, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 44, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 62, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 80, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 9) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex < 18) { - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack == null) { - tStack = tSlot.getStack(); - if (aMouseclick == 0) { - tSlot.putStack(null); - } else if (tStack != null) { - tStack = GT_Utility.copyAmountAndMetaData(tStack.stackSize, 32767, tStack); - if (GT_Utility.isStackInvalid(tStack)) { - tStack = null; - } - } - } else { - tSlot.putStack(GT_Utility.copyAmount(1L, new Object[] {tStack})); - } - return null; - } - if (aSlotIndex == 18) { - ((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); - } - return null; - } - if (aSlotIndex == 19) { - ((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = - (!((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); - if (((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { - GT_Utility.sendChatToPlayer( - aPlayer, GT_Utility.trans("122", "Emit Redstone if slots contain something")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("123", "Don't emit Redstone")); - } - return null; - } - if (aSlotIndex == 20) { - ((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvert = - (!((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvert); - if (((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvert) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120", "Invert Redstone")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121", "Don't invert Redstone")); - } - return null; - } - if (aSlotIndex == 21) { - ((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvertFilter = - (!((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvertFilter); - if (((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bInvertFilter) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("124", "Invert Filter")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("125", "Don't invert Filter")); - } - return null; - } - if (aSlotIndex == 22) { - ((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bIgnoreNBT = - (!((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bIgnoreNBT); - if (((GT_MetaTileEntity_Filter) this.mTileEntity.getMetaTileEntity()).bIgnoreNBT) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("126", "Ignore NBT")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("127", "NBT has to match")); - } - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 9; - } - - @Override - public int getShiftClickSlotCount() { - return 9; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_IndustrialApiary.java b/src/main/java/gregtech/common/gui/GT_Container_IndustrialApiary.java deleted file mode 100644 index 18cbee5d9c..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_IndustrialApiary.java +++ /dev/null @@ -1,249 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.ForestryAPI; -import forestry.api.core.IErrorState; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.gui.GT_Slot_Output; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_ApiaryUpgrade; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_IndustrialApiary; -import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -public class GT_Container_IndustrialApiary extends GT_ContainerMetaTile_Machine { - - GT_Slot_Holo slotItemTransferToggle; - GT_Slot_Holo slotSpeedToggle; - GT_Slot_Holo slotCancelProcess; - Slot slotBattery; - Slot slotSpecial; - ArrayList<Slot> slotUpgrade; - - boolean mItemTransfer; - boolean mStuttering; - - int mSpeed = 0; // scale 0 - 8 - boolean mLockedSpeed = true; - - ArrayList<String> mErrorStates = new ArrayList<>(50); - - public GT_Container_IndustrialApiary(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(slotItemTransferToggle = new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1)); - addSlotToContainer(slotSpeedToggle = new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1)); - addSlotToContainer(slotCancelProcess = new GT_Slot_Holo(mTileEntity, 0, 8, 27, false, true, 1)); - int tStartIndex = 5; - - addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 37, 22)); - addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 37, 42)); - - slotUpgrade = new ArrayList<>(4); - slotUpgrade.add(addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 62, 24))); - slotUpgrade.add(addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 80, 24))); - slotUpgrade.add(addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 62, 42))); - slotUpgrade.add(addSlotToContainer(new ApiarySlot(this.mTileEntity, tStartIndex++, 80, 42))); - - for (int i = 107; i <= 143; i += 18) - for (int j = 6; j <= 42; j += 18) - addSlotToContainer(new GT_Slot_Output(this.mTileEntity, tStartIndex++, i, j)); - - addSlotToContainer(slotBattery = new Slot(mTileEntity, 1, 80, 63)); - addSlotToContainer(slotSpecial = new Slot(mTileEntity, 3, 125, 63)); - } - - @Override - public ItemStack slotClick(int aSlotNumber, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (mTileEntity.getMetaTileEntity() == null) return null; - GT_MetaTileEntity_IndustrialApiary machine = getMachine(); - if (machine == null) return null; - switch (aSlotNumber) { - case 0: - machine.mItemTransfer = !machine.mItemTransfer; - return null; - case 1: - if (aMouseclick == 0) { - if (machine.mLockedSpeed) return null; - if (aShifthold == 0) { - machine.mSpeed++; - if (machine.mSpeed > machine.getMaxSpeed()) machine.mSpeed = 0; - } else if (aShifthold == 1) { - machine.mSpeed--; - if (machine.mSpeed < 0) machine.mSpeed = machine.getMaxSpeed(); - } - } else if (aMouseclick == 1) { - machine.mLockedSpeed = !machine.mLockedSpeed; - if (machine.mLockedSpeed) machine.mSpeed = machine.getMaxSpeed(); - } - return null; - case 2: - machine.cancelProcess(); - detectAndSendChanges(); - return null; - } - - if (!(aSlotNumber >= getSlotStartIndex() + 2 && aSlotNumber < getSlotStartIndex() + 2 + 4)) - return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - if (aShifthold == 5) return null; - if (aShifthold != 0) return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - if (aMouseclick > 1) return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - ItemStack s = aPlayer.inventory.getItemStack(); - if (s == null) return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - Slot slot = getSlot(aSlotNumber); - ItemStack slotstack = slot.getStack(); - if (slotstack != null && !GT_Utility.areStacksEqual(slotstack, s)) return null; // super would replace item - if (slotstack == null && !slot.isItemValid(s)) - return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - if (!GT_ApiaryUpgrade.isUpgrade(s)) return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - int max = GT_ApiaryUpgrade.getUpgrade(s).getMaxNumber(); - if (slotstack != null) max = Math.max(0, max - slotstack.stackSize); - max = Math.min(max, s.stackSize); - if (max == 0) return null; - if (aMouseclick == 1) max = 1; - if (max == s.stackSize) return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - ItemStack newstack = s.splitStack(s.stackSize - max); - ItemStack result = super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - aPlayer.inventory.setItemStack(newstack); - return result; - } - - @Override - public int getSlotStartIndex() { - return 3; - } - - @Override - public int getSlotCount() { - return 6 + 9 + 2; - } - - @Override - public int getShiftClickSlotCount() { - return 6; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - - this.mSpeed = getMachine().mSpeed; - this.mItemTransfer = getMachine().mItemTransfer; - this.mStuttering = getMachine().mStuttering; - this.mLockedSpeed = getMachine().mLockedSpeed; - - for (Object crafter : this.crafters) { - ICrafting var1 = (ICrafting) crafter; - var1.sendProgressBarUpdate(this, 100, this.mSpeed); - var1.sendProgressBarUpdate(this, 101, this.mItemTransfer ? 1 : 0); - var1.sendProgressBarUpdate(this, 102, 0); - for (IErrorState s : getMachine().mErrorStates) var1.sendProgressBarUpdate(this, 103, s.getID()); - var1.sendProgressBarUpdate(this, 104, this.mStuttering ? 1 : 0); - var1.sendProgressBarUpdate(this, 105, this.mLockedSpeed ? 1 : 0); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - this.mSpeed = par2; - break; - case 101: - this.mItemTransfer = par2 == 1; - break; - case 102: - this.mErrorStates.clear(); - break; - case 103: - this.mErrorStates.add(EnumChatFormatting.RED - + StatCollector.translateToLocal("for." - + ForestryAPI.errorStateRegistry - .getErrorState((short) par2) - .getDescription())); - break; - case 104: - this.mStuttering = par2 == 1; - break; - case 105: - this.mLockedSpeed = par2 == 1; - break; - } - } - - public GT_MetaTileEntity_IndustrialApiary getMachine() { - return (GT_MetaTileEntity_IndustrialApiary) mTileEntity.getMetaTileEntity(); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) { - Slot s = getSlot(aSlotIndex); - if (s == null) return super.transferStackInSlot(aPlayer, aSlotIndex); - if (!(s.inventory instanceof InventoryPlayer)) return super.transferStackInSlot(aPlayer, aSlotIndex); - ItemStack aStack = s.getStack(); - if (aStack == null) return super.transferStackInSlot(aPlayer, aSlotIndex); - if (!GT_ApiaryUpgrade.isUpgrade(aStack)) return super.transferStackInSlot(aPlayer, aSlotIndex); - for (int i = getSlotStartIndex() + 2; i < getSlotStartIndex() + 2 + 4; i++) { - Slot iSlot = getSlot(i); - ItemStack iStack = iSlot.getStack(); - if (iStack == null) { - if (!iSlot.isItemValid(aStack)) continue; - } else { - if (!GT_Utility.areStacksEqual(aStack, iStack)) continue; - } - int max = GT_ApiaryUpgrade.getUpgrade(aStack).getMaxNumber(); - if (iStack == null) { - max = Math.min(max, aStack.stackSize); - ItemStack newstack = aStack.splitStack(max); - iSlot.putStack(newstack); - } else { - max = Math.max(0, max - iStack.stackSize); - max = Math.min(max, aStack.stackSize); - iStack.stackSize += max; - aStack.stackSize -= max; - iSlot.onSlotChanged(); - } - if (aStack.stackSize == 0) s.putStack(null); - else s.onSlotChanged(); - break; - } - return null; - } - - private static class ApiarySlot extends Slot { - - public ApiarySlot(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - } - - @Override - public boolean isItemValid(ItemStack p_75214_1_) { - return this.inventory.isItemValidForSlot(this.getSlotIndex(), p_75214_1_); - } - - @Override - public void onSlotChanged() { - super.onSlotChanged(); - ((GT_MetaTileEntity_IndustrialApiary) ((IGregTechTileEntity) this.inventory).getMetaTileEntity()) - .onInventoryUpdate(this.getSlotIndex()); - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java deleted file mode 100644 index 58aff9ad08..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java +++ /dev/null @@ -1,121 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.gui.GT_Slot_Holo_ME; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine { - private static final int LEFT_OFFSET = 8; - private static final int TOP_OFFSET = 10; - private static final int SLOT_SIZE = 18; - public static final int CIRCUIT_SLOT = 32; - - public GT_Container_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - for (int y = 0; y < 4; ++y) - for (int x = 0; x < 4; ++x) - addSlotToContainer(new GT_Slot_Holo( - this.mTileEntity, - x + y * 4, - LEFT_OFFSET + x * SLOT_SIZE, - TOP_OFFSET + y * SLOT_SIZE, - false, - true, - 1)); - for (int y = 0; y < 4; ++y) - for (int x = 0; x < 4; ++x) { - GT_Slot_Holo_ME slot = new GT_Slot_Holo_ME( - this.mTileEntity, - x + y * 4 + 16, - LEFT_OFFSET + x * SLOT_SIZE + 90, - TOP_OFFSET + y * SLOT_SIZE, - false, - true); - addSlotToContainer(slot); - } - super.addSlots(aInventoryPlayer); - } - - private boolean containsSuchStack(ItemStack tStack) { - for (int i = 0; i < 16; ++i) { - Slot tSlot = (Slot) this.inventorySlots.get(i); - if (tSlot != null && GT_Utility.areStacksEqual(tSlot.getStack(), tStack, false)) return true; - } - return false; - } - - private static final int PROGRESS_PACKET_INDEX_OFFSET = 200; - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; - for (int i = 0; i < 16; ++i) { - ItemStack s = ((Slot) this.inventorySlots.get(i + 16)).getStack(); - if (s == null) continue; - player.sendProgressBarUpdate(this, PROGRESS_PACKET_INDEX_OFFSET + 2 * i, s.stackSize & 65535); - player.sendProgressBarUpdate(this, PROGRESS_PACKET_INDEX_OFFSET + 2 * i + 1, s.stackSize >>> 16); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - if (id >= PROGRESS_PACKET_INDEX_OFFSET && id < (PROGRESS_PACKET_INDEX_OFFSET + 32)) { - int index = (id - PROGRESS_PACKET_INDEX_OFFSET) / 2; - ItemStack s = ((Slot) this.inventorySlots.get(index + 16)).getStack(); - if (s != null) { - if ((id - PROGRESS_PACKET_INDEX_OFFSET) % 2 == 0) { - s.stackSize &= 0xFFFF0000; - s.stackSize += (value & 0xFFFF); - } else { - s.stackSize &= 0xFFFF; - s.stackSize += value << 16; - } - } - } - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex >= 0 && aSlotIndex < 16) { - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) return null; - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack == null) { - tSlot.putStack(null); - } else { - if (containsSuchStack(tStack)) return null; - tSlot.putStack(GT_Utility.copyAmount(1L, tStack)); - } - if (mTileEntity.isServerSide()) { - ItemStack newInfo = ((GT_MetaTileEntity_Hatch_InputBus_ME) mTileEntity.getMetaTileEntity()) - .updateInformationSlot(aSlotIndex, tStack); - ((Slot) this.inventorySlots.get(aSlotIndex + 16)).putStack(newInfo); - detectAndSendChanges(); - } - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_ItemDistributor.java b/src/main/java/gregtech/common/gui/GT_Container_ItemDistributor.java deleted file mode 100644 index 2de68c9752..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_ItemDistributor.java +++ /dev/null @@ -1,83 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.automation.GT_MetaTileEntity_ItemDistributor; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_ItemDistributor extends GT_ContainerMetaTile_Machine { - public GT_Container_ItemDistributor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(this.mTileEntity, x + y * 9, 8 + x * 18, 5 + y * 18)); - } - } - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 27) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex == 27) { - ((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); - } - return null; - } - if (aSlotIndex == 28) { - ((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = - (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); - if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("118", "Emit Redstone if no Slot is free")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("119", "Don't emit Redstone")); - } - return null; - } - if (aSlotIndex == 29) { - ((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert = - (!((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert); - if (((GT_MetaTileEntity_ItemDistributor) this.mTileEntity.getMetaTileEntity()).bInvert) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120", "Invert Redstone")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121", "Don't invert Redstone")); - } - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 27; - } - - @Override - public int getShiftClickSlotCount() { - return 27; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_MicrowaveEnergyTransmitter.java b/src/main/java/gregtech/common/gui/GT_Container_MicrowaveEnergyTransmitter.java deleted file mode 100644 index bd6b917f1f..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_MicrowaveEnergyTransmitter.java +++ /dev/null @@ -1,188 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_MicrowaveEnergyTransmitter; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_MicrowaveEnergyTransmitter extends GT_ContainerMetaTile_Machine { - public int mEgg = 0; - public int mTargetD = 0; - public int mTargetZ = 0; - public int mTargetY = 0; - public int mTargetX = 0; - - public GT_Container_MicrowaveEnergyTransmitter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - switch (aSlotIndex) { - case 0: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetX -= - (aShifthold == 1 ? 512 : 64); - return null; - case 1: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetY -= - (aShifthold == 1 ? 512 : 64); - return null; - case 2: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetZ -= - (aShifthold == 1 ? 512 : 64); - return null; - case 3: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetD -= - (aShifthold == 1 ? 16 : 8); - return null; - case 4: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetX -= - (aShifthold == 1 ? 16 : 1); - return null; - case 5: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetY -= - (aShifthold == 1 ? 16 : 1); - return null; - case 6: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetZ -= - (aShifthold == 1 ? 16 : 1); - return null; - case 7: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetD -= - (aShifthold == 1 ? 4 : 1); - return null; - case 8: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetX += - (aShifthold == 1 ? 512 : 64); - return null; - case 9: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetY += - (aShifthold == 1 ? 512 : 64); - return null; - case 10: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetZ += - (aShifthold == 1 ? 512 : 64); - return null; - case 11: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetD += - (aShifthold == 1 ? 16 : 8); - return null; - case 12: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetX += - (aShifthold == 1 ? 16 : 1); - return null; - case 13: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetY += - (aShifthold == 1 ? 16 : 1); - return null; - case 14: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetZ += - (aShifthold == 1 ? 16 : 1); - return null; - case 15: - ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetD += - (aShifthold == 1 ? 4 : 1); - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - this.mTargetX = ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetX; - this.mTargetY = ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetY; - this.mTargetZ = ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetZ; - this.mTargetD = ((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()).mTargetD; - this.mEgg = (((GT_MetaTileEntity_MicrowaveEnergyTransmitter) this.mTileEntity.getMetaTileEntity()) - .hasDimensionalTeleportCapability() - ? 1 - : 0); - - for (Object crafter : this.crafters) { - ICrafting aPlayer = (ICrafting) crafter; - aPlayer.sendProgressBarUpdate(this, 100, this.mTargetX & 0xFFFF); - aPlayer.sendProgressBarUpdate(this, 101, this.mTargetX >>> 16); - aPlayer.sendProgressBarUpdate(this, 102, this.mTargetY & 0xFFFF); - aPlayer.sendProgressBarUpdate(this, 103, this.mTargetY >>> 16); - aPlayer.sendProgressBarUpdate(this, 104, this.mTargetZ & 0xFFFF); - aPlayer.sendProgressBarUpdate(this, 105, this.mTargetZ >>> 16); - aPlayer.sendProgressBarUpdate(this, 106, this.mTargetD & 0xFFFF); - aPlayer.sendProgressBarUpdate(this, 107, this.mTargetD >>> 16); - aPlayer.sendProgressBarUpdate(this, 108, this.mEgg); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - this.mTargetX = (this.mTargetX & 0xFFFF0000 | value & 0xFFFF); - break; - case 101: - this.mTargetX = (this.mTargetX & 0xFFFF | value << 16); - break; - case 102: - this.mTargetY = (this.mTargetY & 0xFFFF0000 | value & 0xFFFF); - break; - case 103: - this.mTargetY = (this.mTargetY & 0xFFFF | value << 16); - break; - case 104: - this.mTargetZ = (this.mTargetZ & 0xFFFF0000 | value & 0xFFFF); - break; - case 105: - this.mTargetZ = (this.mTargetZ & 0xFFFF | value << 16); - break; - case 106: - this.mTargetD = (this.mTargetD & 0xFFFF0000 | value & 0xFFFF); - break; - case 107: - this.mTargetD = (this.mTargetD & 0xFFFF | value << 16); - break; - case 108: - this.mEgg = value; - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java b/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java deleted file mode 100644 index e42e145eb3..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java +++ /dev/null @@ -1,53 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_Slot_Output; -import gregtech.api.gui.GT_Slot_Render; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public class GT_Container_OutputHatch extends GT_Container_BasicTank { - - public GT_Container_OutputHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 3, 150, 42)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex == 3 && aMouseclick < 2) { - GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) mTileEntity.getMetaTileEntity(); - FluidStack tReadyLockFluid = GT_Utility.getFluidForFilledItem(aPlayer.inventory.getItemStack(), true); - byte tMode = tHatch.getMode(); - // If player click the locker slot with empty or the same fluid cell, clear the lock fluid - if (tReadyLockFluid == null - || (tMode >= 8 && tReadyLockFluid.getFluid().getName().equals(tHatch.getLockedFluidName()))) { - tHatch.setLockedFluidName(null); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("300.1", "Fluid Lock Cleared.")); - tHatch.lockFluid(false); - } else { - tHatch.setLockedFluidName(tReadyLockFluid.getFluid().getName()); - GT_Utility.sendChatToPlayer( - aPlayer, - String.format( - GT_Utility.trans("151.4", "Successfully locked Fluid to %s"), - tReadyLockFluid.getLocalizedName())); - tHatch.lockFluid(true); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/gui/GT_Container_PrimitiveBlastFurnace.java deleted file mode 100644 index e19b6167ec..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_PrimitiveBlastFurnace.java +++ /dev/null @@ -1,37 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Output; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_PrimitiveBlastFurnace; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -public class GT_Container_PrimitiveBlastFurnace extends GT_ContainerMetaTile_Machine { - - public GT_Container_PrimitiveBlastFurnace(InventoryPlayer inventoryPlayer, IGregTechTileEntity tileEntity) { - super(inventoryPlayer, tileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - for (int i = 0; i < GT_MetaTileEntity_PrimitiveBlastFurnace.INPUT_SLOTS; i++) { - addSlotToContainer(new Slot(this.mTileEntity, i, 34, 16 + 18 * i)); - } - for (int i = 0; i < GT_MetaTileEntity_PrimitiveBlastFurnace.OUTPUT_SLOTS; i++) { - addSlotToContainer(new GT_Slot_Output( - mTileEntity, GT_MetaTileEntity_PrimitiveBlastFurnace.INPUT_SLOTS + i, 86 + i * 18, 25)); - } - } - - @Override - public int getSlotCount() { - return GT_MetaTileEntity_PrimitiveBlastFurnace.INPUT_SLOTS - + GT_MetaTileEntity_PrimitiveBlastFurnace.OUTPUT_SLOTS; - } - - @Override - public int getShiftClickSlotCount() { - return GT_MetaTileEntity_PrimitiveBlastFurnace.INPUT_SLOTS; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_QuantumChest.java b/src/main/java/gregtech/common/gui/GT_Container_QuantumChest.java deleted file mode 100644 index a072017d08..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_QuantumChest.java +++ /dev/null @@ -1,70 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Output; -import gregtech.api.gui.GT_Slot_Render; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - -public class GT_Container_QuantumChest extends GT_ContainerMetaTile_Machine { - - public int mContent = 0; - - public GT_Container_QuantumChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - if (mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest) { - mContent = ((GT_MetaTileEntity_QuantumChest) mTileEntity.getMetaTileEntity()).mItemCount; - } else { - mContent = 0; - } - - for (Object crafter : this.crafters) { - ICrafting aPlayer = (ICrafting) crafter; - aPlayer.sendProgressBarUpdate(this, 100, mContent & 65535); - aPlayer.sendProgressBarUpdate(this, 101, mContent >>> 16); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - mContent = mContent & 0xffff0000 | value & 0x0000ffff; - break; - case 101: - mContent = mContent & 0x0000ffff | value << 16; - break; - } - } - - @Override - public int getSlotCount() { - return 2; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java deleted file mode 100644 index 3079b40470..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java +++ /dev/null @@ -1,177 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.automation.GT_MetaTileEntity_Regulator; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_Regulator extends GT_ContainerMetaTile_Machine { - public int[] mTargetSlots = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - - public GT_Container_Regulator(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - this.mTargetSlots = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0}; - - addSlotToContainer(new Slot(this.mTileEntity, 0, 8, 6)); - addSlotToContainer(new Slot(this.mTileEntity, 1, 26, 6)); - addSlotToContainer(new Slot(this.mTileEntity, 2, 44, 6)); - addSlotToContainer(new Slot(this.mTileEntity, 3, 8, 24)); - addSlotToContainer(new Slot(this.mTileEntity, 4, 26, 24)); - addSlotToContainer(new Slot(this.mTileEntity, 5, 44, 24)); - addSlotToContainer(new Slot(this.mTileEntity, 6, 8, 42)); - addSlotToContainer(new Slot(this.mTileEntity, 7, 26, 42)); - addSlotToContainer(new Slot(this.mTileEntity, 8, 44, 42)); - - addSlotToContainer(new Slot(this.mTileEntity, 19, 44, 63)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 9, 64, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 81, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 11, 98, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 12, 64, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 13, 81, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 14, 98, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 15, 64, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 16, 81, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 17, 98, 41, false, true, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 119, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 136, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 153, 7, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 119, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 136, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 153, 24, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 119, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 136, 41, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 153, 41, false, true, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 18, 8, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 10) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex == 28) { - ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); - } - return null; - } - if ((aSlotIndex < 19)) { - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack != null) { - tSlot.putStack(GT_Utility.copyOrNull(tStack)); - } else if (tSlot.getStack() != null) { - if (aMouseclick == 0) { - tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); - if (tSlot.getStack().stackSize <= 0) { - tSlot.putStack(null); - } - } else { - tSlot.getStack().stackSize += (aShifthold == 1 ? 8 : 1); - if (tSlot.getStack().stackSize > tSlot.getStack().getMaxStackSize()) { - tSlot.getStack().stackSize = tSlot.getStack().getMaxStackSize(); - } - } - } - return null; - } - if ((aSlotIndex < 28)) { - ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[(aSlotIndex - 19)] = - Math.min( - 99, - Math.max( - 0, - ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()) - .mTargetSlots[(aSlotIndex - 19)] - + (aMouseclick == 0 ? -1 : 1) * (aShifthold == 0 ? 1 : 16))); - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - this.mTargetSlots = new int[9]; - for (int i = 0; i < 9; i++) { - this.mTargetSlots[i] = ((GT_MetaTileEntity_Regulator) this.mTileEntity.getMetaTileEntity()).mTargetSlots[i]; - } - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; - for (int i = 0; i < 9; i++) { - player.sendProgressBarUpdate(this, 100 + i, this.mTargetSlots[i]); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - this.mTargetSlots[0] = value; - break; - case 101: - this.mTargetSlots[1] = value; - break; - case 102: - this.mTargetSlots[2] = value; - break; - case 103: - this.mTargetSlots[3] = value; - break; - case 104: - this.mTargetSlots[4] = value; - break; - case 105: - this.mTargetSlots[5] = value; - break; - case 106: - this.mTargetSlots[6] = value; - break; - case 107: - this.mTargetSlots[7] = value; - break; - case 108: - this.mTargetSlots[8] = value; - } - } - - @Override - public int getSlotCount() { - return 10; - } - - @Override - public int getShiftClickSlotCount() { - return 10; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java b/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java deleted file mode 100644 index 0fda1a485f..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_SuperBuffer.java +++ /dev/null @@ -1,97 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.automation.GT_MetaTileEntity_ChestBuffer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_SuperBuffer extends GT_ContainerMetaTile_Machine { - public GT_Container_SuperBuffer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 44, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 256, 62, 63, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if (tSlot != null) { - if (this.mTileEntity.getMetaTileEntity() == null) { - return null; - } - if (aSlotIndex == 0) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bOutput) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("116", "Emit Energy to Outputside")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("117", "Don't emit Energy")); - } - return null; - } - if (aSlotIndex == 1) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("118", "Emit Redstone if no Slot is free")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("119", "Don't emit Redstone")); - } - return null; - } - if (aSlotIndex == 2) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bInvert) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("120", "Invert Redstone")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("121", "Don't invert Redstone")); - } - return null; - } - if (aSlotIndex == 3) { - ((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode = - (!((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode); - if (((GT_MetaTileEntity_ChestBuffer) this.mTileEntity.getMetaTileEntity()).bStockingMode) { - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans( - "217", - "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.")); - } else { - GT_Utility.sendChatToPlayer( - aPlayer, - GT_Utility.trans( - "218", - "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); - } - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 0; - } - - @Override - public int getShiftClickSlotCount() { - return 0; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_Container_Teleporter.java b/src/main/java/gregtech/common/gui/GT_Container_Teleporter.java deleted file mode 100644 index 219391e662..0000000000 --- a/src/main/java/gregtech/common/gui/GT_Container_Teleporter.java +++ /dev/null @@ -1,190 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Teleporter; -import java.util.Iterator; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_Teleporter extends GT_ContainerMetaTile_Machine { - public int mEgg = 0; - public int mTargetD = 0; - public int mTargetZ = 0; - public int mTargetY = 0; - public int mTargetX = 0; - - public GT_Container_Teleporter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - switch (aSlotIndex) { - case 0: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetX -= - (aShifthold == 1 ? 512 : 64); - return null; - case 1: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetY -= - (aShifthold == 1 ? 512 : 64); - return null; - case 2: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetZ -= - (aShifthold == 1 ? 512 : 64); - return null; - case 3: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetD -= - (aShifthold == 1 ? 16 : 8); - return null; - case 4: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetX -= - (aShifthold == 1 ? 16 : 1); - return null; - case 5: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetY -= - (aShifthold == 1 ? 16 : 1); - return null; - case 6: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetZ -= - (aShifthold == 1 ? 16 : 1); - return null; - case 7: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetD -= - (aShifthold == 1 ? 4 : 1); - return null; - case 8: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetX += - (aShifthold == 1 ? 512 : 64); - return null; - case 9: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetY += - (aShifthold == 1 ? 512 : 64); - return null; - case 10: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetZ += - (aShifthold == 1 ? 512 : 64); - return null; - case 11: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetD += - (aShifthold == 1 ? 16 : 8); - return null; - case 12: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetX += - (aShifthold == 1 ? 16 : 1); - return null; - case 13: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetY += - (aShifthold == 1 ? 16 : 1); - return null; - case 14: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetZ += - (aShifthold == 1 ? 16 : 1); - return null; - case 15: - ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetD += - (aShifthold == 1 ? 4 : 1); - return null; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { - return; - } - this.mTargetX = ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetX; - this.mTargetY = ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetY; - this.mTargetZ = ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetZ; - this.mTargetD = ((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()).mTargetD; - this.mEgg = (((GT_MetaTileEntity_Teleporter) this.mTileEntity.getMetaTileEntity()) - .hasDimensionalTeleportCapability() - ? 1 - : 0); - - Iterator playerIterator = this.crafters.iterator(); - while (playerIterator.hasNext()) { - ICrafting player = (ICrafting) playerIterator.next(); - player.sendProgressBarUpdate(this, 100, this.mTargetX & 0xFFFF); - player.sendProgressBarUpdate(this, 101, this.mTargetX >>> 16); - player.sendProgressBarUpdate(this, 102, this.mTargetY & 0xFFFF); - player.sendProgressBarUpdate(this, 103, this.mTargetY >>> 16); - player.sendProgressBarUpdate(this, 104, this.mTargetZ & 0xFFFF); - player.sendProgressBarUpdate(this, 105, this.mTargetZ >>> 16); - player.sendProgressBarUpdate(this, 106, this.mTargetD & 0xFFFF); - player.sendProgressBarUpdate(this, 107, this.mTargetD >>> 16); - player.sendProgressBarUpdate(this, 108, this.mEgg); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100: - this.mTargetX = (this.mTargetX & 0xFFFF0000 | value & 0xFFFF); - break; - case 101: - this.mTargetX = (this.mTargetX & 0xFFFF | value << 16); - break; - case 102: - this.mTargetY = (this.mTargetY & 0xFFFF0000 | value & 0xFFFF); - break; - case 103: - this.mTargetY = (this.mTargetY & 0xFFFF | value << 16); - break; - case 104: - this.mTargetZ = (this.mTargetZ & 0xFFFF0000 | value & 0xFFFF); - break; - case 105: - this.mTargetZ = (this.mTargetZ & 0xFFFF | value << 16); - break; - case 106: - this.mTargetD = (this.mTargetD & 0xFFFF0000 | value & 0xFFFF); - break; - case 107: - this.mTargetD = (this.mTargetD & 0xFFFF | value << 16); - break; - case 108: - this.mEgg = value; - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainerVolumetricFlask.java b/src/main/java/gregtech/common/gui/GT_GUIContainerVolumetricFlask.java deleted file mode 100644 index 45df55cbe9..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainerVolumetricFlask.java +++ /dev/null @@ -1,234 +0,0 @@ -package gregtech.common.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.GT_Values; -import gregtech.api.net.GT_Packet_UpdateItem; -import gregtech.common.items.GT_VolumetricFlask; -import java.text.DecimalFormat; -import java.text.ParseException; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public final class GT_GUIContainerVolumetricFlask extends GuiContainer { - private static final ResourceLocation BACKGROUND = - new ResourceLocation("gregtech:textures/gui/VolumetricFlask.png"); - - private GuiIntegerBox amount; - private GuiButton apply; - private GuiButton plus1; - private GuiButton plus10; - private GuiButton plus100; - private GuiButton plus1000; - private GuiButton minus1; - private GuiButton minus10; - private GuiButton minus100; - private GuiButton minus1000; - private GT_ContainerVolumetricFlask container; - - public GT_GUIContainerVolumetricFlask(GT_ContainerVolumetricFlask container) { - super(container); - this.container = container; - } - - @Override - public void initGui() { - super.initGui(); - - buttonList.add(plus1 = new GuiButton(0, guiLeft + 20, guiTop + 26, 22, 20, "+1")); - buttonList.add(plus10 = new GuiButton(0, guiLeft + 48, guiTop + 26, 28, 20, "+10")); - buttonList.add(plus100 = new GuiButton(0, guiLeft + 82, guiTop + 26, 32, 20, "+100")); - buttonList.add(plus1000 = new GuiButton(0, guiLeft + 120, guiTop + 26, 38, 20, "+1000")); - - buttonList.add(minus1 = new GuiButton(0, guiLeft + 20, guiTop + 75, 22, 20, "-1")); - buttonList.add(minus10 = new GuiButton(0, guiLeft + 48, guiTop + 75, 28, 20, "-10")); - buttonList.add(minus100 = new GuiButton(0, guiLeft + 82, guiTop + 75, 32, 20, "-100")); - buttonList.add(minus1000 = new GuiButton(0, guiLeft + 120, guiTop + 75, 38, 20, "-1000")); - - buttonList.add(apply = new GuiButton(0, guiLeft + 128, guiTop + 51, 38, 20, "Accept")); - - amount = new GuiIntegerBox( - fontRendererObj, - guiLeft + 62, - guiTop + 57, - 59, - fontRendererObj.FONT_HEIGHT, - ((GT_VolumetricFlask) container.flask.getItem()).getMaxCapacity()); - amount.setEnableBackgroundDrawing(false); - amount.setMaxStringLength(16); - amount.setTextColor(16777215); - amount.setVisible(true); - amount.setFocused(true); - amount.setText("1"); - System.out.println(((GT_VolumetricFlask) container.flask.getItem()).getCapacity(container.flask)); - amount.setText(String.valueOf(((GT_VolumetricFlask) container.flask.getItem()).getCapacity(container.flask))); - } - - @Override - protected final void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(BACKGROUND); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - try { - Long.parseLong(amount.getText()); - apply.enabled = (amount.getText().length() > 0); - } catch (NumberFormatException e) { - apply.enabled = false; - } - - amount.drawTextBox(); - } - - @Override - protected void keyTyped(char character, int key) { - if (!checkHotbarKeys(key)) { - if (key == 28) actionPerformed(apply); - if (((key == 211) - || (key == 205) - || (key == 203) - || (key == 14) - || (character == '-') - || (Character.isDigit(character))) - && (amount.textboxKeyTyped(character, key))) { - try { - String out = amount.getText(); - boolean fixed = false; - while ((out.startsWith("0")) && (out.length() > 1)) { - out = out.substring(1); - fixed = true; - } - if (fixed) { - amount.setText(out); - } - if (out.isEmpty()) { - out = "0"; - } - long result = Long.parseLong(out); - if (result < 0L) { - amount.setText("1"); - } - - } catch (NumberFormatException ignored) { - } - } else { - super.keyTyped(character, key); - } - } - } - - @Override - protected void actionPerformed(GuiButton btn) { - try { - if (btn == apply) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("cap", Integer.parseInt(amount.getText())); - GT_Values.NW.sendToServer(new GT_Packet_UpdateItem(tag)); - mc.thePlayer.closeScreen(); - } - - } catch (NumberFormatException e) { - amount.setText("1"); - } - - boolean isPlus = (btn == plus1) || (btn == plus10) || (btn == plus100) || (btn == plus1000); - boolean isMinus = (btn == minus1) || (btn == minus10) || (btn == minus100) || (btn == minus1000); - - if ((isPlus) || (isMinus)) { - addQty(getQty(btn)); - } - } - - private void addQty(int i) { - try { - String out = amount.getText(); - - boolean fixed = false; - while ((out.startsWith("0")) && (out.length() > 1)) { - out = out.substring(1); - fixed = true; - } - - if (fixed) { - amount.setText(out); - } - if (out.isEmpty()) { - out = "0"; - } - long result = Integer.parseInt(out); - - if ((result == 1L) && (i > 1)) { - result = 0L; - } - result += i; - if (result < 1L) { - result = 1L; - } - out = Long.toString(result); - Integer.parseInt(out); - amount.setText(out); - } catch (NumberFormatException ignored) { - } - } - - protected int getQty(GuiButton btn) { - try { - DecimalFormat df = new DecimalFormat("+#;-#"); - return df.parse(btn.displayString).intValue(); - } catch (ParseException ignored) { - } - - return 0; - } - - public class GuiIntegerBox extends GuiTextField { - private final int maxValue; - - public GuiIntegerBox(FontRenderer fontRenderer, int x, int y, int width, int height) { - this(fontRenderer, x, y, width, height, Integer.MAX_VALUE); - } - - public GuiIntegerBox(FontRenderer fontRenderer, int x, int y, int width, int height, int maxValue) { - super(fontRenderer, x, y, width, height); - this.maxValue = maxValue; - } - - @Override - public void writeText(String selectedText) { - String original = getText(); - super.writeText(selectedText); - - try { - int i = Integer.parseInt(getText()); - if (i > maxValue) { - setText(String.valueOf(maxValue)); - } else if (i < 0) { - setText("0"); - } - } catch (NumberFormatException e) { - setText(original); - } - } - - @Override - public void setText(String s) { - try { - int i = Integer.parseInt(s); - if (i > maxValue) { - s = String.valueOf(maxValue); - } else if (i < 0) { - s = "0"; - } - } catch (NumberFormatException e) { - s = String.valueOf(maxValue); - } - super.setText(s); - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_AdvDebugStructureWriter.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_AdvDebugStructureWriter.java deleted file mode 100644 index 3ae07cef8e..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_AdvDebugStructureWriter.java +++ /dev/null @@ -1,76 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; -import static net.minecraft.util.StatCollector.translateToLocal; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.gui.widgets.GT_GuiSlotTooltip; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_AdvDebugStructureWriter extends GT_GUIContainerMetaTile_Machine { - - private static final String ADVDEBUGSTRUCTUREWRITER_PRINT_TOOLTIP = - "GT5U.machines.advdebugstructurewriter.gui.print.tooltip"; - private static final String ADVDEBUGSTRUCTUREWRITER_TRANSPOSE_TOOLTIP = - "GT5U.machines.advdebugstructurewriter.gui.transpose.tooltip"; - private static final String ADVDEBUGSTRUCTUREWRITER_HIGHLIGHT_TOOLTIP = - "GT5U.machines.advdebugstructurewriter.gui.highlight.tooltip"; - - public GT_GUIContainer_AdvDebugStructureWriter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super( - new GT_Container_AdvDebugStructureWriter(aInventoryPlayer, aTileEntity), - RES_PATH_GUI + "AdvDebugStructureWriter.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (mContainer != null) { - GT_Container_AdvDebugStructureWriter dsw = (GT_Container_AdvDebugStructureWriter) mContainer; - if (dsw.numbers == null) { - return; - } - fontRendererObj.drawString( - translateToLocal("GT5U.machines.advdebugstructurewriter.gui.origin"), 46, 8, 16448255); - fontRendererObj.drawString("A: " + dsw.numbers[0], 46, 18, 16448255); - fontRendererObj.drawString("B: " + dsw.numbers[1], 46, 26, 16448255); - fontRendererObj.drawString("C: " + dsw.numbers[2], 46, 34, 16448255); - - fontRendererObj.drawString( - translateToLocal("GT5U.machines.advdebugstructurewriter.gui.size"), 46, 60, 16448255); - fontRendererObj.drawString("A: " + dsw.numbers[3], 46, 70, 16448255); - fontRendererObj.drawString("B: " + dsw.numbers[4], 46, 78, 16448255); - fontRendererObj.drawString("C: " + dsw.numbers[5], 46, 86, 16448255); - } - } - - @Override - protected void setupTooltips() { - addToolTip(new GT_GuiSlotTooltip( - getContainer().printSlot, mTooltipCache.getData(ADVDEBUGSTRUCTUREWRITER_PRINT_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().transposeSlot, mTooltipCache.getData(ADVDEBUGSTRUCTUREWRITER_TRANSPOSE_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().highlightSlot, mTooltipCache.getData(ADVDEBUGSTRUCTUREWRITER_HIGHLIGHT_TOOLTIP))); - } - - private GT_Container_AdvDebugStructureWriter getContainer() { - return ((GT_Container_AdvDebugStructureWriter) this.mContainer); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if (mContainer != null) { - if (((GT_Container_AdvDebugStructureWriter) mContainer).transpose) { - drawTexturedModalRect(x + 32, y + 128, 176, 0, 18, 18); - } - if (((GT_Container_AdvDebugStructureWriter) mContainer).showHighlightBox) { - drawTexturedModalRect(x + 53, y + 128, 176, 18, 18, 18); - } - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java deleted file mode 100644 index ef7ed15720..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java +++ /dev/null @@ -1,46 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_Boiler extends GT_GUIContainerMetaTile_Machine { - - private final int textColor = this.getTextColorOrDefault("title", 0x404040); - - public GT_GUIContainer_Boiler( - InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName) { - super(new GT_Container_Boiler(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/" + aTextureName); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString("Boiler", 8, 4, textColor); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - int tScale = ((GT_Container_Boiler) this.mContainer).mSteamAmount; - if (tScale > 0) { - drawTexturedModalRect(x + 70, y + 25 + 54 - tScale, 194, 54 - tScale, 10, tScale); - } - tScale = ((GT_Container_Boiler) this.mContainer).mWaterAmount; - if (tScale > 0) { - drawTexturedModalRect(x + 83, y + 25 + 54 - tScale, 204, 54 - tScale, 10, tScale); - } - tScale = ((GT_Container_Boiler) this.mContainer).mTemperature; - if (tScale > 0) { - drawTexturedModalRect(x + 96, y + 25 + 54 - tScale, 214, 54 - tScale, 10, tScale); - } - tScale = ((GT_Container_Boiler) this.mContainer).mProcessingEnergy; - if (tScale > 0) { - drawTexturedModalRect(x + 117, y + 44 + 14 - tScale, 177, 14 - tScale, 15, tScale + 1); - } - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_BronzeBlastFurnace.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_BronzeBlastFurnace.java deleted file mode 100644 index b92f7e9243..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_BronzeBlastFurnace.java +++ /dev/null @@ -1,47 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_BronzeBlastFurnace extends GT_GUIContainerMetaTile_Machine { - - private final int textColor = this.getTextColorOrDefault("title", 0x404040); - - public GT_GUIContainer_BronzeBlastFurnace(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super( - new GT_Container_BronzeBlastFurnace(aInventoryPlayer, aTileEntity), - "gregtech:textures/gui/BronzeBlastFurnace.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString("Bronze Blast Furnace", 8, 4, textColor); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if ((this.mContainer != null) && (this.mContainer.mProgressTime > 0)) { - drawTexturedModalRect( - x + 58, - y + 28, - 176, - 0, - Math.max( - 0, - Math.min( - 20, - (this.mContainer.mProgressTime > 0 ? 1 : 0) - + this.mContainer.mProgressTime - * 20 - / (this.mContainer.mMaxProgressTime < 1 - ? 1 - : this.mContainer.mMaxProgressTime))), - 11); - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_ChestBuffer.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_ChestBuffer.java deleted file mode 100644 index 2f993140ac..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_ChestBuffer.java +++ /dev/null @@ -1,19 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_ChestBuffer extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_ChestBuffer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_ChestBuffer(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/ChestBuffer.png"); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_Filter.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_Filter.java deleted file mode 100644 index 2ad3ea3018..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_Filter.java +++ /dev/null @@ -1,19 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_Filter extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_Filter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_Filter(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/Filter.png"); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java deleted file mode 100644 index 87e035c61a..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_FusionReactor.java +++ /dev/null @@ -1,96 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.gui.GT_Container_MultiMachine; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import gregtech.nei.NEI_TransferRectHost; -import java.awt.Rectangle; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_FusionReactor extends GT_GUIContainerMetaTile_Machine implements NEI_TransferRectHost { - - public String mNEI; - String mName = ""; - - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0xFAFAFF), - textColorValue = this.getTextColorOrDefault("value", 0xFF0000); - - public GT_GUIContainer_FusionReactor( - InventoryPlayer aInventoryPlayer, - IGregTechTileEntity aTileEntity, - String aName, - String aTextureFile, - String aNEI) { - super( - new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity, false), - RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - mName = aName; - mNEI = aNEI; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(mName, 8, -10, textColorTitle); - - if (mContainer != null) { - if ((mContainer.mDisplayErrorCode & 64) != 0) - fontRendererObj.drawString("Incomplete Structure.", 10, 8, textColor); - - if (mContainer.mDisplayErrorCode == 0) { - if (mContainer.mActive == 0) { - fontRendererObj.drawString( - "Hit with Soft Mallet to (re-)start the Machine if it doesn't start.", -70, 170, textColor); - } else { - fontRendererObj.drawString("Running perfectly.", 10, 170, textColor); - } - } - if (this.mContainer.mEnergy > 160000000 && this.mContainer.mEnergy < 160010000) - fontRendererObj.drawString("160,000,000 EU", 50, 155, textColorValue); - else if (this.mContainer.mEnergy > 320000000 && this.mContainer.mEnergy < 320010000) - fontRendererObj.drawString("320,000,000 EU", 50, 155, textColorValue); - else if (this.mContainer.mEnergy > 640000000 && this.mContainer.mEnergy < 640010000) - fontRendererObj.drawString("640,000,000 EU", 50, 155, textColorValue); - else if (this.mContainer.mEnergyLong > 5120000000L && this.mContainer.mEnergyLong < 5120080000L) - fontRendererObj.drawString("5,120,000,000 EU", 50, 155, textColorValue); - else - fontRendererObj.drawString( - GT_Utility.formatNumbers(this.mContainer.mEnergyLong) + " EU", 50, 155, textColorValue); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if (this.mContainer != null) { - double tScale = (double) this.mContainer.mEnergyLong / (double) this.mContainer.mStorageLong; - drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148)), 5); - } - } - - @Override - public String getNeiTransferRectString() { - return mNEI; - } - - @Override - public String getNeiTransferRectTooltip() { - return "Recipes"; - } - - @Override - public Object[] getNeiTransferRectArgs() { - return new Object[0]; - } - - @Override - public Rectangle getNeiTransferRect() { - return new Rectangle(149, -7, 18, 18); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_IndustrialApiary.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_IndustrialApiary.java deleted file mode 100644 index 015e9f74a5..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_IndustrialApiary.java +++ /dev/null @@ -1,174 +0,0 @@ -package gregtech.common.gui; - -import forestry.api.apiculture.*; -import gregtech.api.enums.GT_Values; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.gui.widgets.GT_GuiSlotTooltip; -import gregtech.api.gui.widgets.GT_GuiTooltip; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_TooltipDataCache; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_IndustrialApiary; -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.StatCollector; - -public class GT_GUIContainer_IndustrialApiary extends GT_GUIContainerMetaTile_Machine { - - private static final String BATTERY_SLOT_TOOLTIP = "GT5U.machines.battery_slot.tooltip", - UNUSED_SLOT_TOOLTIP = "GT5U.machines.unused_slot.tooltip", - STALLED_STUTTERING_TOOLTIP = "GT5U.machines.stalled_stuttering.tooltip", - ITEM_TRANSFER_TOOLTIP = "GT5U.machines.item_transfer.tooltip", - POWER_SOURCE_POWER = "GT5U.machines.powersource.power", - CANCEL_PROCESS_TOOLTIP = "GT5U.machines.industrialapiary.cancel.tooltip", - SPEED_TOOLTIP = "GT5U.machines.industrialapiary.speed.tooltip", - SPEED_LOCKED_TOOLTIP = "GT5U.machines.industrialapiary.speedlocked.tooltip", - INFO_TOOLTIP = "GT5U.machines.industrialapiary.info.tooltip", - INFO_WITH_BEE_TOOLTIP = "GT5U.machines.industrialapiary.infoextended.tooltip", - UPGRADE_TOOLTIP = "GT5U.machines.industrialapiary.upgradeslot.tooltip"; - private final int textColor = this.getTextColorOrDefault("text", 0x404040), - textColorTitle = this.getTextColorOrDefault("title", 0x404040), - textColorValue = this.getTextColorOrDefault("value", 0x404040); - - GT_GuiTooltip mErrorStatesTooltip; - GT_GuiTooltip mSpeedToggleTooltip; - GT_GuiTooltip mInfoTooltip; - - public GT_GUIContainer_IndustrialApiary(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super( - new GT_Container_IndustrialApiary(aInventoryPlayer, aTileEntity), - "gregtech:textures/gui/basicmachines/IndustrialApiary.png"); - } - - @Override - protected void setupTooltips() { - Rectangle tBeeProblemArea = new Rectangle(this.guiLeft + 100, this.guiTop + 63, 18, 18); - addToolTip( - mErrorStatesTooltip = new GT_GuiTooltip(tBeeProblemArea, "") { - @Override - protected void onTick() { - boolean e = this.enabled; - super.onTick(); - this.enabled = e; - } - }); - addToolTip( - mSpeedToggleTooltip = new GT_GuiSlotTooltip( - getContainer().slotSpeedToggle, new GT_TooltipDataCache.TooltipData(null, null))); - mErrorStatesTooltip.enabled = false; - addToolTip(mInfoTooltip = new GT_GuiTooltip(new Rectangle(this.guiLeft + 163, guiTop + 5, 6, 17))); - - addToolTip( - new GT_GuiSlotTooltip(getContainer().slotCancelProcess, mTooltipCache.getData(CANCEL_PROCESS_TOOLTIP))); - getContainer() - .slotUpgrade - .forEach(s -> addToolTip(new GT_GuiSlotTooltip(s, mTooltipCache.getData(UPGRADE_TOOLTIP)))); - - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotItemTransferToggle, mTooltipCache.getData(ITEM_TRANSFER_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotBattery, - mTooltipCache.getData( - BATTERY_SLOT_TOOLTIP, powerTierName(getContainer().getMachine().mTier), powerTierName((byte) - (getContainer().getMachine().mTier + 1))))); - addToolTip(new GT_GuiSlotTooltip(getContainer().slotSpecial, mTooltipCache.getData(UNUSED_SLOT_TOOLTIP))); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float parTicks) { - mErrorStatesTooltip.enabled = !getContainer().mErrorStates.isEmpty(); - if (mErrorStatesTooltip.enabled) { - mErrorStatesTooltip.setToolTipText( - new GT_TooltipDataCache.TooltipData(getContainer().mErrorStates, getContainer().mErrorStates)); - } else if (getContainer().mStuttering) { - mErrorStatesTooltip.enabled = true; - mErrorStatesTooltip.setToolTipText(mTooltipCache.getData( - STALLED_STUTTERING_TOOLTIP, StatCollector.translateToLocal(POWER_SOURCE_POWER))); - } - int accelerated = (1 << getContainer().mSpeed); - int energyusage = 0; - if (accelerated == 2) energyusage = 32; - else if (accelerated > 2) energyusage = 32 * accelerated << (getContainer().mSpeed - 2); - mSpeedToggleTooltip.setToolTipText(mTooltipCache.getUncachedTooltipData( - getContainer().mLockedSpeed ? SPEED_LOCKED_TOOLTIP : SPEED_TOOLTIP, - accelerated, - GT_Utility.formatNumbers(energyusage))); - ArrayList<String> s = new ArrayList<>(); - GT_MetaTileEntity_IndustrialApiary IA = getContainer().getMachine(); - - String energyreq = GT_Utility.formatNumbers( - (int) ((float) GT_MetaTileEntity_IndustrialApiary.baseEUtUsage * IA.getEnergyModifier() * accelerated) - + energyusage); - String Temp = StatCollector.translateToLocal(IA.getTemperature().getName()); - String Hum = StatCollector.translateToLocal(IA.getHumidity().getName()); - boolean moreinformationgiven = false; - if (IA.getUsedQueen() != null && BeeManager.beeRoot.isMember(IA.getUsedQueen(), EnumBeeType.QUEEN.ordinal())) { - IBee bee = BeeManager.beeRoot.getMember(IA.getUsedQueen()); - if (bee.isAnalyzed()) { - moreinformationgiven = true; - IBeeGenome genome = bee.getGenome(); - IBeeModifier mod = - BeeManager.beeRoot.getBeekeepingMode(IA.getWorld()).getBeeModifier(); - float tmod = IA.getTerritoryModifier(null, 1f) * mod.getTerritoryModifier(null, 1f); - int[] t = Arrays.stream(genome.getTerritory()) - .map(i -> (int) ((float) i * tmod)) - .toArray(); - mInfoTooltip.setToolTipText(mTooltipCache.getUncachedTooltipData( - INFO_WITH_BEE_TOOLTIP, - energyreq, - Temp, - Hum, - genome.getSpeed(), - IA.getProductionModifier(null, 1f) * mod.getProductionModifier(null, 1f), - Math.round(IA.getFloweringModifier(null, 1f) - * genome.getFlowering() - * mod.getFloweringModifier(null, 1f)), - Math.round(IA.getLifespanModifier(null, null, 1f) - * genome.getLifespan() - * mod.getLifespanModifier(null, null, 1f)), - t[0], - t[1], - t[2])); - } - } - if (!moreinformationgiven) - mInfoTooltip.setToolTipText(mTooltipCache.getUncachedTooltipData(INFO_TOOLTIP, energyreq, Temp, Hum)); - - super.drawScreen(mouseX, mouseY, parTicks); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString("Ind. Apiary", 8, 4, textColorTitle); - this.fontRendererObj.drawString("x", 30, 63, textColor); - this.fontRendererObj.drawString((1 << getContainer().mSpeed) + "", 26, 72, textColorValue); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - if (getContainer().mItemTransfer) drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); - if (getContainer().mMaxProgressTime > 0) { - double p = (double) getContainer().mProgressTime / getContainer().mMaxProgressTime; - drawTexturedModalRect(x + 70, y + 3, 176, 0, (int) (p * 20), 18); - } - if (mErrorStatesTooltip.enabled) - drawTexturedModalRect(x + 100, y + 63, 176, 36, getContainer().mStuttering ? 18 : 9, 18); - } - } - - private GT_Container_IndustrialApiary getContainer() { - return ((GT_Container_IndustrialApiary) this.mContainer); - } - - // taken from GT_GUIContainer_BasicMachine - private String powerTierName(byte machineTier) { - return GT_Values.TIER_COLORS[machineTier] + GT_Values.VN[machineTier]; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java deleted file mode 100644 index 9b19da6367..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java +++ /dev/null @@ -1,77 +0,0 @@ -package gregtech.common.gui; - -import appeng.client.render.AppEngRenderItem; -import appeng.core.AELog; -import appeng.integration.IntegrationRegistry; -import appeng.integration.IntegrationType; -import appeng.integration.abstraction.INEI; -import appeng.util.Platform; -import cpw.mods.fml.common.Optional; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo_ME; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machine { - - private final AppEngRenderItem aeRenderItem = new AppEngRenderItem(); - - public GT_GUIContainer_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_InputBus_ME(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/InputBusME.png"); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - // base method is made public by AE2 ASM - public void func_146977_a(final Slot s) { - this.drawSlot(s); - } - - @Optional.Method(modid = "appliedenergistics2") - private RenderItem setItemRender(final RenderItem item) { - if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI)) { - return ((INEI) IntegrationRegistry.INSTANCE.getInstance(IntegrationType.NEI)).setItemRender(item); - } else { - final RenderItem ri = itemRender; - itemRender = item; - return ri; - } - } - - @Optional.Method(modid = "appliedenergistics2") - private void drawSlot(final Slot s) { - if (s instanceof GT_Slot_Holo_ME) { - final RenderItem pIR = this.setItemRender(this.aeRenderItem); - try { - this.zLevel = 0.0F; - itemRender.zLevel = 0.0F; - this.aeRenderItem.setAeStack(Platform.getAEStackInSlot(s)); - this.safeDrawSlot(s); - } catch (final Exception err) { - AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err.toString()); - } - this.setItemRender(pIR); - return; - } - safeDrawSlot(s); - } - - @Optional.Method(modid = "appliedenergistics2") - private void safeDrawSlot(final Slot s) { - try { - GuiContainer.class - .getDeclaredMethod("func_146977_a_original", Slot.class) - .invoke(this, s); - } catch (final Exception ignored) { - } - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_ItemDistributor.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_ItemDistributor.java deleted file mode 100644 index 2c8fa870a1..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_ItemDistributor.java +++ /dev/null @@ -1,21 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_ItemDistributor extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_ItemDistributor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super( - new GT_Container_ItemDistributor(aInventoryPlayer, aTileEntity), - "gregtech:textures/gui/ItemDistributor.png"); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_MicrowaveEnergyTransmitter.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_MicrowaveEnergyTransmitter.java deleted file mode 100644 index 7b0b840276..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_MicrowaveEnergyTransmitter.java +++ /dev/null @@ -1,75 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_MicrowaveEnergyTransmitter extends GT_GUIContainerMetaTile_Machine { - - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0xFAFAFF); - - public GT_GUIContainer_MicrowaveEnergyTransmitter( - InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super( - new GT_Container_MicrowaveEnergyTransmitter(aInventoryPlayer, aTileEntity), - RES_PATH_GUI + "Teleporter.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString("Teleporter", 46, 8, textColorTitle); - if (this.mContainer != null) { - this.fontRendererObj.drawString( - "X: " - + GT_Utility.parseNumberToString( - ((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mTargetX), - 46, - 16, - textColor); - this.fontRendererObj.drawString( - "Y: " - + GT_Utility.parseNumberToString( - ((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mTargetY), - 46, - 24, - textColor); - this.fontRendererObj.drawString( - "Z: " - + GT_Utility.parseNumberToString( - ((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mTargetZ), - 46, - 32, - textColor); - if (((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mEgg > 0) { - this.fontRendererObj.drawString( - "Dim: " - + GT_Utility.parseNumberToString( - ((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mTargetD), - 46, - 40, - textColor); - this.fontRendererObj.drawString( - "Dim Valid: " - + (GT_Utility.isRealDimension( - ((GT_Container_MicrowaveEnergyTransmitter) this.mContainer).mTargetD) - ? "Yes" - : "No"), - 46, - 48, - textColor); - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java deleted file mode 100644 index ab00d16291..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java +++ /dev/null @@ -1,75 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.enums.GT_Values; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.IDragAndDropSupport; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.net.GT_Packet_SetLockedFluid; -import gregtech.api.util.GT_Utility; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.FluidStack; - -public class GT_GUIContainer_OutputHatch extends GT_GUIContainerMetaTile_Machine implements IDragAndDropSupport { - - private final String mName; - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0x404040), - textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); - - public GT_GUIContainer_OutputHatch( - InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new GT_Container_OutputHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "OutputHatch.png"); - mName = aName; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString( - StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorTitle); - fontRendererObj.drawString(mName, 8, 6, textColorTitle); - if (mContainer != null) { - fontRendererObj.drawString("Liquid Amount", 10, 20, textColor); - fontRendererObj.drawString( - GT_Utility.parseNumberToString(((GT_Container_OutputHatch) mContainer).mContent), - 10, - 30, - textColorValue); - fontRendererObj.drawString("Locked Fluid", 101, 20, textColor); - ItemStack tLockedDisplayStack = - (ItemStack) mContainer.getInventory().get(3); - String fluidName = tLockedDisplayStack == null ? "None" : tLockedDisplayStack.getDisplayName(); - fontRendererObj.drawString(fluidName, 101, 30, textColorValue); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } - - @Override - public boolean handleDragAndDropGT( - GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button, boolean isGhost) { - if (isGhost - && gui instanceof GT_GUIContainer_OutputHatch - && ((GT_GUIContainer_OutputHatch) gui).isMouseOverSlot(3, mousex, mousey)) { - // the instanceof check should be unnecessary, but we will do it regardless, just in case. - FluidStack tFluidStack = GT_Utility.getFluidFromContainerOrFluidDisplay(draggedStack); - if (tFluidStack != null) { - GT_Values.NW.sendToServer(new GT_Packet_SetLockedFluid( - ((GT_GUIContainer_OutputHatch) gui).mContainer.mTileEntity, tFluidStack)); - draggedStack.stackSize = 0; - return true; - } - } - return false; - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_PrimitiveBlastFurnace.java deleted file mode 100644 index 060b93674a..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_PrimitiveBlastFurnace.java +++ /dev/null @@ -1,81 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.gui.widgets.GT_GuiIcon; -import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.nei.NEI_TransferRectHost; -import java.awt.*; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_PrimitiveBlastFurnace extends GT_GUIContainerMetaTile_Machine - implements NEI_TransferRectHost { - private String name; - public String mNEI; - private static final GT_GuiTabIconSet TAB_ICONSET = new GT_GuiTabIconSet( - GT_GuiIcon.TAB_NORMAL_BRICK, GT_GuiIcon.TAB_HIGHLIGHT_BRICK, GT_GuiIcon.TAB_DISABLED_BRICK); - private final int textColor = this.getTextColorOrDefault("title", 0x404040); - - public GT_GUIContainer_PrimitiveBlastFurnace( - InventoryPlayer inventoryPlayer, IGregTechTileEntity tileEntity, String name, String aNEI) { - super( - new GT_Container_PrimitiveBlastFurnace(inventoryPlayer, tileEntity), - String.format("gregtech:textures/gui/%s.png", name.replace(" ", ""))); - this.name = name; - this.mNEI = aNEI; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString(name, 8, 4, textColor); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if ((this.mContainer != null) && (this.mContainer.mProgressTime > 0)) { - drawTexturedModalRect( - x + 58, - y + 28, - 176, - 0, - Math.max( - 0, - Math.min( - 20, - (1) - + this.mContainer.mProgressTime - * 20 - / (Math.max(this.mContainer.mMaxProgressTime, 1)))), - 11); - } - } - - @Override - protected GT_GuiTabIconSet getTabBackground() { - return TAB_ICONSET; - } - - @Override - public String getNeiTransferRectString() { - return mNEI; - } - - @Override - public String getNeiTransferRectTooltip() { - return "Recipes"; - } - - @Override - public Object[] getNeiTransferRectArgs() { - return new Object[0]; - } - - @Override - public Rectangle getNeiTransferRect() { - return new Rectangle(51, 10, 24, 24); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_QuantumChest.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_QuantumChest.java deleted file mode 100644 index 530e48e550..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_QuantumChest.java +++ /dev/null @@ -1,46 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.StatCollector; - -public class GT_GUIContainer_QuantumChest extends GT_GUIContainerMetaTile_Machine { - - private final String mName; - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("title", 0x404040), - textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); - - public GT_GUIContainer_QuantumChest( - InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new GT_Container_QuantumChest(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); - mName = aName; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString( - StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColorTitle); - fontRendererObj.drawString(mName, 8, 6, textColorTitle); - if (mContainer != null) { - fontRendererObj.drawString("Item Amount", 10, 20, textColor); - fontRendererObj.drawString( - GT_Utility.parseNumberToString(((GT_Container_QuantumChest) mContainer).mContent), - 10, - 30, - textColorValue); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_RecipeFilter.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_RecipeFilter.java deleted file mode 100644 index 8bfc2c0944..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_RecipeFilter.java +++ /dev/null @@ -1,23 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_Container_SpecialFilter; -import gregtech.api.gui.GT_GUIContainer_SpecialFilter; -import gregtech.api.gui.widgets.GT_GuiSlotTooltip; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_RecipeFilter extends GT_GUIContainer_SpecialFilter { - - private static final String REPRESENTATION_SLOT_TOOLTIP = "GT5U.recipe_filter.representation_slot.tooltip"; - - public GT_GUIContainer_RecipeFilter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - protected void setupTooltips() { - addToolTip(new GT_GuiSlotTooltip( - ((GT_Container_SpecialFilter) mContainer).getSpecialSlot(), - mTooltipCache.getData(REPRESENTATION_SLOT_TOOLTIP))); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_Regulator.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_Regulator.java deleted file mode 100644 index c3d579e58c..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_Regulator.java +++ /dev/null @@ -1,44 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_Regulator extends GT_GUIContainerMetaTile_Machine { - - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF); - - public GT_GUIContainer_Regulator(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_Regulator(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/Regulator.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[0]), 120, 9, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[1]), 137, 9, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[2]), 155, 9, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[3]), 120, 26, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[4]), 137, 26, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[5]), 155, 26, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[6]), 120, 43, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[7]), 137, 43, textColor); - this.fontRendererObj.drawString( - String.valueOf(((GT_Container_Regulator) this.mContainer).mTargetSlots[8]), 155, 43, textColor); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_SuperBuffer.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_SuperBuffer.java deleted file mode 100644 index e7b7730d75..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_SuperBuffer.java +++ /dev/null @@ -1,19 +0,0 @@ -package gregtech.common.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_SuperBuffer extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_SuperBuffer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_SuperBuffer(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/SuperBuffer.png"); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_Teleporter.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_Teleporter.java deleted file mode 100644 index a5e035b4ff..0000000000 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_Teleporter.java +++ /dev/null @@ -1,63 +0,0 @@ -package gregtech.common.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_Teleporter extends GT_GUIContainerMetaTile_Machine { - - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF), - textColorTitle = this.getTextColorOrDefault("text", 0xFAFAFF); - - public GT_GUIContainer_Teleporter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_Teleporter(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Teleporter.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString("Teleporter", 46, 8, textColorTitle); - if (this.mContainer != null) { - this.fontRendererObj.drawString( - "X: " + GT_Utility.parseNumberToString(((GT_Container_Teleporter) this.mContainer).mTargetX), - 46, - 16, - textColor); - this.fontRendererObj.drawString( - "Y: " + GT_Utility.parseNumberToString(((GT_Container_Teleporter) this.mContainer).mTargetY), - 46, - 24, - textColor); - this.fontRendererObj.drawString( - "Z: " + GT_Utility.parseNumberToString(((GT_Container_Teleporter) this.mContainer).mTargetZ), - 46, - 32, - textColor); - if (((GT_Container_Teleporter) this.mContainer).mEgg > 0) { - this.fontRendererObj.drawString( - "Dim: " + GT_Utility.parseNumberToString(((GT_Container_Teleporter) this.mContainer).mTargetD), - 46, - 40, - textColor); - this.fontRendererObj.drawString( - "Dim Valid: " - + (GT_Utility.isRealDimension(((GT_Container_Teleporter) this.mContainer).mTargetD) - ? "Yes" - : "No"), - 46, - 48, - textColor); - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(parTicks, mouseX, mouseY); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } -} diff --git a/src/main/java/gregtech/common/gui/modularui/UIHelper.java b/src/main/java/gregtech/common/gui/modularui/UIHelper.java new file mode 100644 index 0000000000..f500514258 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/UIHelper.java @@ -0,0 +1,222 @@ +package gregtech.common.gui.modularui; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.SteamTexture; +import gregtech.api.util.GT_Recipe; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nullable; + +public class UIHelper { + + /** + * Iterates over candidates for slot placement. + */ + public static void forEachSlots( + ForEachSlot forEachItemInputSlot, + ForEachSlot forEachItemOutputSlot, + ForEachSlot forEachSpecialSlot, + ForEachSlot forEachFluidInputSlot, + ForEachSlot forEachFluidOutputSlot, + IDrawable itemSlotBackground, + IDrawable fluidSlotBackground, + @Nullable GT_Recipe.GT_Recipe_Map recipeMap, + int itemInputCount, + int itemOutputCount, + int fluidInputCount, + int fluidOutputCount, + SteamVariant steamVariant, + Pos2d offset) { + List<Pos2d> itemInputPositions = recipeMap != null + ? recipeMap.getItemInputPositions(itemInputCount) + : UIHelper.getItemInputPositions(itemInputCount); + itemInputPositions = itemInputPositions.stream().map(p -> p.add(offset)).collect(Collectors.toList()); + for (int i = 0; i < itemInputPositions.size(); i++) { + forEachItemInputSlot.accept( + i, + getBackgroundsForSlot(itemSlotBackground, recipeMap, false, false, i, false, steamVariant), + itemInputPositions.get(i)); + } + + List<Pos2d> itemOutputPositions = recipeMap != null + ? recipeMap.getItemOutputPositions(itemOutputCount) + : UIHelper.getItemOutputPositions(itemOutputCount); + itemOutputPositions = + itemOutputPositions.stream().map(p -> p.add(offset)).collect(Collectors.toList()); + for (int i = 0; i < itemOutputPositions.size(); i++) { + forEachItemOutputSlot.accept( + i, + getBackgroundsForSlot(itemSlotBackground, recipeMap, false, true, i, false, steamVariant), + itemOutputPositions.get(i)); + } + + forEachSpecialSlot.accept( + 0, + getBackgroundsForSlot(itemSlotBackground, recipeMap, false, false, 0, true, steamVariant), + (recipeMap != null ? recipeMap.getSpecialItemPosition() : UIHelper.getSpecialItemPosition()) + .add(offset)); + + List<Pos2d> fluidInputPositions = recipeMap != null + ? recipeMap.getFluidInputPositions(fluidInputCount) + : UIHelper.getFluidInputPositions(fluidInputCount); + fluidInputPositions = + fluidInputPositions.stream().map(p -> p.add(offset)).collect(Collectors.toList()); + for (int i = 0; i < fluidInputPositions.size(); i++) { + forEachFluidInputSlot.accept( + i, + getBackgroundsForSlot(fluidSlotBackground, recipeMap, true, false, i, false, steamVariant), + fluidInputPositions.get(i)); + } + + List<Pos2d> fluidOutputPositions = recipeMap != null + ? recipeMap.getFluidOutputPositions(fluidOutputCount) + : UIHelper.getFluidOutputPositions(fluidOutputCount); + fluidOutputPositions = + fluidOutputPositions.stream().map(p -> p.add(offset)).collect(Collectors.toList()); + for (int i = 0; i < fluidOutputPositions.size(); i++) { + forEachFluidOutputSlot.accept( + i, + getBackgroundsForSlot(fluidSlotBackground, recipeMap, true, true, i, false, steamVariant), + fluidOutputPositions.get(i)); + } + } + + /** + * @return Display positions for GUI, including border (18x18 size) + */ + public static List<Pos2d> getItemInputPositions(int itemInputCount) { + switch (itemInputCount) { + case 0: + return Collections.emptyList(); + case 1: + return getItemGridPositions(itemInputCount, 52, 24, 1, 1); + case 2: + return getItemGridPositions(itemInputCount, 34, 24, 2, 1); + case 3: + return getItemGridPositions(itemInputCount, 16, 24, 3, 1); + case 4: + case 5: + return getItemGridPositions(itemInputCount, 16, 24, 3, 2); + case 6: + return getItemGridPositions(itemInputCount, 16, 15, 3, 2); + default: + return getItemGridPositions(itemInputCount, 16, 6, 3, 3); + } + } + + /** + * @return Display positions for GUI, including border (18x18 size) + */ + public static List<Pos2d> getItemOutputPositions(int itemOutputCount) { + switch (itemOutputCount) { + case 0: + return Collections.emptyList(); + case 1: + return getItemGridPositions(itemOutputCount, 106, 24, 1, 1); + case 2: + return getItemGridPositions(itemOutputCount, 106, 24, 2, 1); + case 3: + return getItemGridPositions(itemOutputCount, 106, 24, 3, 1); + case 4: + return getItemGridPositions(itemOutputCount, 106, 15, 2, 2); + case 5: + case 6: + return getItemGridPositions(itemOutputCount, 106, 15, 3, 2); + default: + return getItemGridPositions(itemOutputCount, 106, 6, 3, 3); + } + } + + /** + * @return Display position for GUI, including border (18x18 size) + */ + public static Pos2d getSpecialItemPosition() { + return new Pos2d(124, 62); + } + + /** + * @return Display positions for GUI, including border (18x18 size) + */ + public static List<Pos2d> getFluidInputPositions(int fluidInputCount) { + List<Pos2d> results = new ArrayList<>(); + int x = 52; + for (int i = 0; i < fluidInputCount; i++) { + results.add(new Pos2d(x, 62)); + x -= 18; + } + return results; + } + + /** + * @return Display positions for GUI, including border (18x18 size) + */ + public static List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + List<Pos2d> results = new ArrayList<>(); + int x = 106; + for (int i = 0; i < fluidOutputCount; i++) { + results.add(new Pos2d(x, 62)); + x += 18; + } + return results; + } + + public static List<Pos2d> getItemGridPositions( + int itemCount, int xOrigin, int yOrigin, int xDirMaxCount, int yDirMaxCount) { + // 18 pixels to get to a new grid for placing an item tile since they are 16x16 and have 1 pixel buffers + // around them. + int distanceGrid = 18; + int xMax = xOrigin + xDirMaxCount * distanceGrid; + + List<Pos2d> results = new ArrayList<>(); + // Temp variables to keep track of current coordinates to place item at. + int xCoord = xOrigin; + int yCoord = yOrigin; + + for (int i = 0; i < itemCount; i++) { + results.add(new Pos2d(xCoord, yCoord)); + xCoord += distanceGrid; + if (xCoord == xMax) { + xCoord = xOrigin; + yCoord += distanceGrid; + } + } + + return results; + } + + private static IDrawable[] getBackgroundsForSlot( + IDrawable base, + GT_Recipe.GT_Recipe_Map recipeMap, + boolean isFluid, + boolean isOutput, + int index, + boolean isSpecial, + SteamVariant steamVariant) { + if (recipeMap != null) { + IDrawable overlay; + if (steamVariant != SteamVariant.NONE) { + SteamTexture steamTexture = recipeMap.getOverlayForSlotSteam(isFluid, isOutput, index, isSpecial); + if (steamTexture != null) { + overlay = steamTexture.get(steamVariant); + } else { + overlay = null; + } + } else { + overlay = recipeMap.getOverlayForSlot(isFluid, isOutput, index, isSpecial); + } + if (overlay != null) { + return new IDrawable[] {base, overlay}; + } + } + return new IDrawable[] {base}; + } + + @FunctionalInterface + public interface ForEachSlot { + void accept(int index, IDrawable[] backgrounds, Pos2d pos); + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/uifactory/SelectItemUIFactory.java b/src/main/java/gregtech/common/gui/modularui/uifactory/SelectItemUIFactory.java new file mode 100644 index 0000000000..c3da5cb1b4 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/uifactory/SelectItemUIFactory.java @@ -0,0 +1,221 @@ +package gregtech.common.gui.modularui.uifactory; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import gregtech.api.enums.Dyes; +import gregtech.api.gui.GT_GUIColorOverride; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.util.GT_Util; +import gregtech.api.util.GT_Utility; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; +import java.util.function.Supplier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +/** + * Creates UI for selecting item from given list. + * This is client-only UI to allow using client-preferred settings. + */ +public class SelectItemUIFactory { + + private final String header; + private final ItemStack headerItem; + public static final int UNSELECTED = -1; + private static final int cols = 9; + private final Consumer<ItemStack> selectedCallback; + // passed in stack + private final List<ItemStack> stacks; + private final boolean noDeselect; + private int selected; + private boolean anotherWindow = false; + private AtomicBoolean dialogOpened; + private int guiTint = GT_Util.getRGBInt(Dyes.MACHINE_METAL.getRGBA()); + private final ItemStackHandler currentDisplayItemHandler = new ItemStackHandler(); + private Supplier<ItemStack> currentGetter; + + private final GT_GUIColorOverride colorOverride = new GT_GUIColorOverride("SelectItemUIFactory"); + + private int getTextColorOrDefault(String textType, int defaultColor) { + return colorOverride.getTextColorOrDefault(textType, defaultColor); + } + + private final Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x222222); + private final Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x555555); + + public SelectItemUIFactory( + String header, ItemStack headerItem, Consumer<ItemStack> selectedCallback, List<ItemStack> stacks) { + this(header, headerItem, selectedCallback, stacks, UNSELECTED); + } + + public SelectItemUIFactory( + String header, + ItemStack headerItem, + Consumer<ItemStack> selectedCallback, + List<ItemStack> stacks, + int selected) { + this(header, headerItem, selectedCallback, stacks, selected, false); + } + + /** + * Constructor for a dialog to select an item from given list. Given callback may be called zero or more times depending on user action. + * @param header Header text + * @param headerItem ItemStack to use as Dialog icon + * @param selectedCallback callback upon selected + * @param stacks list to choose from + * @param selected preselected item. Use {@link #UNSELECTED} for unselected. Invalid selected will be clamped to 0 or highest index + * @param noDeselect true if player cannot deselect, false otherwise. If this is set to true, selectedCallback is guaranteed to be called with a nonnull stack + */ + public SelectItemUIFactory( + String header, + ItemStack headerItem, + Consumer<ItemStack> selectedCallback, + List<ItemStack> stacks, + int selected, + boolean noDeselect) { + this.header = header; + this.headerItem = headerItem; + this.selectedCallback = selectedCallback; + this.stacks = stacks; + this.noDeselect = noDeselect; + this.selected = noDeselect ? Math.max(0, selected) : selected; + this.currentDisplayItemHandler.setStackInSlot(0, getCandidate(selected)); + } + + /** + * @param anotherWindow If UI is shown on top of another window + * @param dialogOpened Flag to store whether this UI is opened and hence it should block duplicated creation of this UI + */ + public SelectItemUIFactory setAnotherWindow(boolean anotherWindow, AtomicBoolean dialogOpened) { + this.anotherWindow = anotherWindow; + this.dialogOpened = dialogOpened; + return this; + } + + public SelectItemUIFactory setGuiTint(int guiTint) { + this.guiTint = guiTint; + return this; + } + + /** + * @param currentGetter Getter for "current" item displayed that may change from external reasons + */ + public SelectItemUIFactory setCurrentGetter(Supplier<ItemStack> currentGetter) { + this.currentGetter = currentGetter; + return this; + } + + public ModularWindow createWindow(UIBuildContext buildContext) { + ModularWindow.Builder builder = + ModularWindow.builder(getGUIWidth(), 53 + 18 * ((stacks.size() - 1) / cols + 1)); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.setGuiTint(guiTint); + + if (headerItem != null) { + builder.widget(new ItemDrawable(headerItem).asWidget().setPos(5, 5).setSize(16, 16)); + } + builder.widget(new TextWidget(header).setDefaultColor(COLOR_TITLE.get()).setPos(25, 9)); + + builder.widget( + new SlotWidget(BaseSlot.phantom(currentDisplayItemHandler, 0)) { + @Override + public void draw(float partialTicks) { + if (currentGetter != null) { + ItemStack current = currentGetter.get(); + currentDisplayItemHandler.setStackInSlot(0, current); + selected = GT_Utility.findMatchingStackInList(stacks, current); + } + super.draw(partialTicks); + } + }.disableInteraction() + .setBackground(GT_UITextures.SLOT_DARK_GRAY) + .setPos( + 9 + + getFontRenderer() + .getStringWidth(StatCollector.translateToLocal( + "GT5U.gui.select.current")), + 24)) + .widget(new TextWidget(StatCollector.translateToLocal("GT5U.gui.select.current")) + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(8, 25 + (18 - getFontRenderer().FONT_HEIGHT) / 2)); + + for (int i = 0; i < stacks.size(); i++) { + final int index = i; + builder.widget( + new SlotWidget(new BaseSlot(new ItemStackHandler(new ItemStack[] {stacks.get(index)}), 0, true)) { + @Override + public ClickResult onClick(int buttonId, boolean doubleClick) { + if (buttonId == 0) { + setSelected(index); + } else if (buttonId == 1) { + setSelected(UNSELECTED); + } else { + return ClickResult.ACCEPT; + } + selectedCallback.accept(getCandidate(getSelected())); + return ClickResult.SUCCESS; + } + + @Override + public IDrawable[] getBackground() { + return new IDrawable[] { + index == selected ? GT_UITextures.SLOT_DARK_GRAY : ModularUITextures.ITEM_SLOT + }; + } + }.disableInteraction().setPos(7 + 18 * (index % cols), 43 + 18 * (index / cols))); + } + + if (anotherWindow) { + dialogOpened.set(true); + builder.widget( + new ButtonWidget() { + @Override + public void onDestroy() { + dialogOpened.set(false); + } + }.setOnClick((clickData, widget) -> widget.getWindow().tryClose()) + .setBackground(ModularUITextures.VANILLA_BACKGROUND, new Text("x")) + .setPos(getGUIWidth() - 15, 3) + .setSize(12, 12)); + } + + return builder.build(); + } + + public int getSelected() { + return selected; + } + + public void setSelected(int selected) { + if (selected == this.selected) return; + int newSelected = GT_Utility.clamp(selected, UNSELECTED, stacks.size() - 1); + if (noDeselect && newSelected == UNSELECTED) return; + + this.selected = newSelected; + currentDisplayItemHandler.setStackInSlot(0, getCandidate(this.selected)); + } + + private ItemStack getCandidate(int listIndex) { + return listIndex < 0 || listIndex >= stacks.size() ? null : stacks.get(listIndex); + } + + private FontRenderer getFontRenderer() { + return Minecraft.getMinecraft().fontRenderer; + } + + private int getGUIWidth() { + return 176; + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/AESlotWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/AESlotWidget.java new file mode 100644 index 0000000000..f3620d3234 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/AESlotWidget.java @@ -0,0 +1,40 @@ +package gregtech.common.gui.modularui.widget; + +import appeng.client.render.AppEngRenderItem; +import appeng.core.AELog; +import appeng.util.Platform; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.inventory.Slot; + +public class AESlotWidget extends SlotWidget { + + public AESlotWidget(BaseSlot slot) { + super(slot); + } + + @Override + @SideOnly(Side.CLIENT) + protected void drawSlot(Slot slotIn) { + final AppEngRenderItem aeRenderItem = new AppEngRenderItem(); + final RenderItem pIR = this.setItemRender(aeRenderItem); + try { + aeRenderItem.setAeStack(Platform.getAEStackInSlot(slotIn)); + super.drawSlot(slotIn, false); + } catch (final Exception err) { + AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err); + } + this.setItemRender(pIR); + } + + @SideOnly(Side.CLIENT) + private RenderItem setItemRender(final RenderItem item) { + final RenderItem ri = ModularGui.getItemRenderer(); + ModularGui.setItemRenderer(item); + return ri; + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverCycleButtonWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverCycleButtonWidget.java new file mode 100644 index 0000000000..599ed28a5f --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverCycleButtonWidget.java @@ -0,0 +1,89 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.modularui.GT_UITextures; +import org.lwjgl.opengl.GL11; + +/** + * Fires click action on mouse release, not on press. + * Draws different backgrounds depending on whether the mouse is being pressed or the widget is hovered. + */ +public class CoverCycleButtonWidget extends CycleButtonWidget { + + private static final UITexture BUTTON_NORMAL_NOT_PRESSED = + GT_UITextures.BUTTON_COVER_NORMAL.getSubArea(0, 0, 1, 0.5f); + private static final UITexture BUTTON_NORMAL_PRESSED = GT_UITextures.BUTTON_COVER_NORMAL.getSubArea(0, 0.5f, 1, 1); + private static final UITexture BUTTON_HOVERED_NOT_PRESSED = + GT_UITextures.BUTTON_COVER_NORMAL_HOVERED.getSubArea(0, 0, 1, 0.5f); + private static final UITexture BUTTON_HOVERED_PRESSED = + GT_UITextures.BUTTON_COVER_NORMAL_HOVERED.getSubArea(0, 0.5f, 1, 1); + + private boolean clickPressed; + + private static final int TOOLTIP_DELAY = 5; + + public CoverCycleButtonWidget() { + setSize(16, 16); + setTooltipShowUpDelay(TOOLTIP_DELAY); + } + + @Override + public ClickResult onClick(int buttonId, boolean doubleClick) { + updateState(); + if (!canClick()) return ClickResult.REJECT; + clickPressed = true; + return ClickResult.SUCCESS; + } + + @Override + public boolean onClickReleased(int buttonId) { + clickPressed = false; + updateState(); + if (!isHovering() || !canClick()) return false; + return onClickImpl(buttonId); + } + + protected boolean onClickImpl(int buttonId) { + super.onClick(buttonId, false); + return true; + } + + @SuppressWarnings("BooleanMethodIsAlwaysInverted") + protected boolean canClick() { + return true; + } + + @SideOnly(Side.CLIENT) + protected void updateState() {} + + public boolean isClickPressed() { + return clickPressed; + } + + @Override + public void drawBackground(float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + super.drawBackground(partialTicks); + } + + @Override + public IDrawable[] getBackground() { + if (isHovering()) { + if (clickPressed) { + return new IDrawable[] {BUTTON_HOVERED_PRESSED}; + } else { + return new IDrawable[] {BUTTON_HOVERED_NOT_PRESSED}; + } + } else { + if (clickPressed) { + return new IDrawable[] {BUTTON_NORMAL_PRESSED}; + } else { + return new IDrawable[] {BUTTON_NORMAL_NOT_PRESSED}; + } + } + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverDataControllerWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataControllerWidget.java new file mode 100644 index 0000000000..d28117054a --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataControllerWidget.java @@ -0,0 +1,138 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.ISerializableObject; +import java.io.IOException; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import net.minecraft.network.PacketBuffer; + +public class CoverDataControllerWidget<T extends ISerializableObject> extends DataControllerWidget<T> { + + protected final GT_CoverBehaviorBase<T> coverBehavior; + + /** + * @param dataGetter () -> cover data this widget handles + * @param dataSetter data to set -> if setting cover data is successful + * @param coverBehavior cover this widget handles data update + */ + public CoverDataControllerWidget( + Supplier<T> dataGetter, Function<T, Boolean> dataSetter, GT_CoverBehaviorBase<T> coverBehavior) { + super(dataGetter, dataSetter); + this.coverBehavior = coverBehavior; + } + + @Override + public <U, W extends Widget & IDataFollowerWidget<T, U>> CoverDataControllerWidget<T> addFollower( + W widget, Function<T, U> dataToStateGetter, BiFunction<T, U, T> dataUpdater, Consumer<W> applyForWidget) { + super.addFollower(widget, dataToStateGetter, dataUpdater, applyForWidget); + return this; + } + + @Override + protected void writeToPacket(PacketBuffer buffer, T data) { + try { + NetworkUtils.writeNBTBase(buffer, data.saveDataToNBT()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected T readFromPacket(PacketBuffer buffer) throws IOException { + return coverBehavior.createDataObject(NetworkUtils.readNBTBase(buffer)); + } + + /** + * Uses int index to determine toggle button behaviors. + */ + public static class CoverDataIndexedControllerWidget_ToggleButtons<T extends ISerializableObject> + extends CoverDataControllerWidget<T> { + + private final BiFunction<Integer, T, Boolean> dataToStateGetter; + private final BiFunction<Integer, T, T> dataUpdater; + + /** + * @param coverDataGetter () -> cover data this widget handles + * @param coverDataSetter data to set -> if setting cover data is successful + * @param coverBehavior cover this widget handles data update + * @param dataToStateGetter (index of button, given cover data) -> button state + * @param dataUpdater (index of button, current cover data) -> new cover data + */ + public CoverDataIndexedControllerWidget_ToggleButtons( + Supplier<T> coverDataGetter, + Function<T, Boolean> coverDataSetter, + GT_CoverBehaviorBase<T> coverBehavior, + BiFunction<Integer, T, Boolean> dataToStateGetter, + BiFunction<Integer, T, T> dataUpdater) { + super(coverDataGetter, coverDataSetter, coverBehavior); + this.dataToStateGetter = dataToStateGetter; + this.dataUpdater = dataUpdater; + } + + /** + * @param index index of widget to add + * @param widget widget to add + * @param applyForWidget methods to call for widget to add + */ + public <W extends CoverDataFollower_ToggleButtonWidget<T>> + CoverDataIndexedControllerWidget_ToggleButtons<T> addToggleButton( + int index, W widget, Consumer<CoverDataFollower_ToggleButtonWidget<T>> applyForWidget) { + addFollower( + widget, + data -> dataToStateGetter.apply(index, data), + (data, state) -> dataUpdater.apply(index, data), + applyForWidget); + return this; + } + } + + /** + * Uses int index to determine cycle button behaviors. + */ + public static class CoverDataIndexedControllerWidget_CycleButtons<T extends ISerializableObject> + extends CoverDataControllerWidget<T> { + + private final BiFunction<Integer, T, Integer> dataToStateGetter; + private final BiFunction<Integer, T, T> dataUpdater; + + /** + * @param coverDataGetter () -> cover data this widget handles + * @param coverDataSetter data to set -> if setting cover data is successful + * @param coverBehavior cover this widget handles data update + * @param dataToStateGetter (index of button, given cover data) -> button state + * @param dataUpdater (index of button, current cover data) -> new cover data + */ + public CoverDataIndexedControllerWidget_CycleButtons( + Supplier<T> coverDataGetter, + Function<T, Boolean> coverDataSetter, + GT_CoverBehaviorBase<T> coverBehavior, + BiFunction<Integer, T, Integer> dataToStateGetter, + BiFunction<Integer, T, T> dataUpdater) { + super(coverDataGetter, coverDataSetter, coverBehavior); + this.dataToStateGetter = dataToStateGetter; + this.dataUpdater = dataUpdater; + } + + /** + * @param index index of widget to add + * @param widget widget to add + * @param applyForWidget methods to call for the widget to add + */ + public <W extends CoverDataFollower_CycleButtonWidget<T>> + CoverDataIndexedControllerWidget_CycleButtons<T> addCycleButton( + int index, W widget, Consumer<CoverDataFollower_CycleButtonWidget<T>> applyForWidget) { + addFollower( + widget, + data -> dataToStateGetter.apply(index, data), + (data, state) -> dataUpdater.apply(index, data), + applyForWidget); + return this; + } + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_CycleButtonWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_CycleButtonWidget.java new file mode 100644 index 0000000000..d07165cc6e --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_CycleButtonWidget.java @@ -0,0 +1,38 @@ +package gregtech.common.gui.modularui.widget; + +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.ISerializableObject; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * Determines button state with cover data. + */ +public class CoverDataFollower_CycleButtonWidget<T extends ISerializableObject> extends CoverCycleButtonWidget + implements IDataFollowerWidget<T, Integer> { + + private Function<T, Integer> dataToStateGetter; + + public CoverDataFollower_CycleButtonWidget() { + super(); + setGetter(() -> 0); // fake getter; used only for init + setSynced(false, false); + } + + @Override + public CoverDataFollower_CycleButtonWidget<T> setDataToStateGetter(Function<T, Integer> dataToStateGetter) { + this.dataToStateGetter = dataToStateGetter; + return this; + } + + @Override + public CoverDataFollower_CycleButtonWidget<T> setStateSetter(Consumer<Integer> setter) { + super.setSetter(setter); + return this; + } + + @Override + public void updateState(T data) { + setState(dataToStateGetter.apply(data), false, false); + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_SlotWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_SlotWidget.java new file mode 100644 index 0000000000..c09c5b5279 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_SlotWidget.java @@ -0,0 +1,102 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.widget.Interactable; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.ISerializableObject; +import java.io.IOException; +import java.util.function.Consumer; +import java.util.function.Function; +import net.minecraft.item.ItemStack; + +public class CoverDataFollower_SlotWidget<T extends ISerializableObject> extends SlotWidget + implements IDataFollowerWidget<T, ItemStack> { + + private Function<T, ItemStack> dataToStateGetter; + private Consumer<ItemStack> dataSetter; + + public CoverDataFollower_SlotWidget(BaseSlot slot) { + super(slot); + } + + public CoverDataFollower_SlotWidget(IItemHandlerModifiable handler, int index, boolean phantom) { + this(new BaseSlot(handler, index, phantom)); + } + + public CoverDataFollower_SlotWidget(IItemHandlerModifiable handler, int index) { + this(handler, index, false); + } + + @Override + public CoverDataFollower_SlotWidget<T> setDataToStateGetter(Function<T, ItemStack> dataToStateGetter) { + this.dataToStateGetter = dataToStateGetter; + return this; + } + + @Override + public CoverDataFollower_SlotWidget<T> setStateSetter(Consumer<ItemStack> setter) { + this.dataSetter = setter; + return this; + } + + @Override + public void updateState(T data) { + getMcSlot().putStack(dataToStateGetter.apply(data)); + } + + @Override + public void detectAndSendChanges(boolean init) {} + + // Slot sync is handled differently from other DataFollowers, + // so we need to also sync slot content directly to server. + + @Override + public ClickResult onClick(int buttonId, boolean doubleClick) { + if (interactionDisabled) return ClickResult.REJECT; + if (isPhantom()) { + ClickData clickData = ClickData.create(buttonId, doubleClick); + syncToServer(2, clickData::writeToPacket); + phantomClick(clickData); + dataSetter.accept(getMcSlot().getStack()); + return ClickResult.ACCEPT; + } + return ClickResult.REJECT; + } + + @Override + public boolean onMouseScroll(int direction) { + if (interactionDisabled) return false; + if (isPhantom()) { + if (Interactable.hasShiftDown()) { + direction *= 8; + } + final int finalDirection = direction; + syncToServer(3, buffer -> buffer.writeVarIntToBuffer(finalDirection)); + phantomScroll(finalDirection); + dataSetter.accept(getMcSlot().getStack()); + return true; + } + return false; + } + + @Override + public boolean handleDragAndDrop(ItemStack draggedStack, int button) { + if (interactionDisabled) return false; + if (!isPhantom()) return false; + ClickData clickData = ClickData.create(button, false); + syncToServer(5, buffer -> { + try { + clickData.writeToPacket(buffer); + buffer.writeItemStackToBuffer(draggedStack); + } catch (IOException e) { + e.printStackTrace(); + } + }); + phantomClick(clickData, draggedStack); + dataSetter.accept(getMcSlot().getStack()); + draggedStack.stackSize = 0; + return true; + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_TextFieldWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_TextFieldWidget.java new file mode 100644 index 0000000000..9130f8e3d0 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_TextFieldWidget.java @@ -0,0 +1,110 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.MathExpression; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.ISerializableObject; +import java.util.function.Consumer; +import java.util.function.Function; +import net.minecraft.client.gui.GuiScreen; + +public class CoverDataFollower_TextFieldWidget<T extends ISerializableObject> extends TextFieldWidget + implements IDataFollowerWidget<T, String> { + + private Function<T, String> dataToStateGetter; + + public CoverDataFollower_TextFieldWidget() { + super(); + setGetter(() -> ""); // fake getter; used only for init + setSynced(false, false); + setTextColor(Color.WHITE.dark(1)); + setTextAlignment(Alignment.CenterLeft); + setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)); + } + + @Override + public void onPostInit() { + // Widget#onPostInit is called earlier than IDataFollowerWidget#onPostInit, + // so we make sure cursor is set after text is set + super.onPostInit(); + + // On first call #handler does not contain text. + // On second call, it contains correct text to update #lastText, + // but #shouldGetFocus call is skipped by Cursor#updateFocused, + // so we need to manually call this. + if (focusOnGuiOpen) { + shouldGetFocus(); + } + } + + @Override + public CoverDataFollower_TextFieldWidget<T> setDataToStateGetter(Function<T, String> dataToStateGetter) { + this.dataToStateGetter = dataToStateGetter; + return this; + } + + @Override + public CoverDataFollower_TextFieldWidget<T> setStateSetter(Consumer<String> setter) { + super.setSetter(setter); + return this; + } + + @Override + public void updateState(T data) { + setText(dataToStateGetter.apply(data)); + } + + public CoverDataFollower_TextFieldWidget<T> setOnScrollNumbers(int baseStep, int ctrlStep, int shiftStep) { + setOnScrollNumbers((val, direction) -> { + int step = (GuiScreen.isShiftKeyDown() ? shiftStep : GuiScreen.isCtrlKeyDown() ? ctrlStep : baseStep) + * direction; + try { + val = Math.addExact(val, step); + } catch (ArithmeticException ignored) { + val = Integer.MAX_VALUE; + } + return val; + }); + return this; + } + + public CoverDataFollower_TextFieldWidget<T> setOnScrollNumbers() { + return setOnScrollNumbers(1, 50, 1000); + } + + public CoverDataFollower_TextFieldWidget<T> setOnScrollText(int baseStep, int ctrlStep, int shiftStep) { + setOnScroll((text, direction) -> { + int val = (int) MathExpression.parseMathExpression(text, -1); + int step = (GuiScreen.isShiftKeyDown() ? shiftStep : GuiScreen.isCtrlKeyDown() ? ctrlStep : baseStep) + * direction; + try { + val = Math.addExact(val, step); + } catch (ArithmeticException ignored) { + val = Integer.MAX_VALUE; + } + return TextFieldWidget.format.format(val); + }); + return this; + } + + public CoverDataFollower_TextFieldWidget<T> setOnScrollText() { + return setOnScrollText(1, 5, 50); + } + + public CoverDataFollower_TextFieldWidget<T> setOnScrollNumbersLong(long baseStep, long ctrlStep, long shiftStep) { + setOnScrollNumbersLong((val, direction) -> { + long step = (GuiScreen.isShiftKeyDown() ? shiftStep : GuiScreen.isCtrlKeyDown() ? ctrlStep : baseStep) + * direction; + try { + val = Math.addExact(val, step); + } catch (ArithmeticException ignored) { + val = Long.MAX_VALUE; + } + return val; + }); + return this; + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_ToggleButtonWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_ToggleButtonWidget.java new file mode 100644 index 0000000000..8e091d7bc6 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/CoverDataFollower_ToggleButtonWidget.java @@ -0,0 +1,84 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.ISerializableObject; +import java.util.function.Consumer; +import java.util.function.Function; + +public class CoverDataFollower_ToggleButtonWidget<T extends ISerializableObject> extends CoverCycleButtonWidget + implements IDataFollowerWidget<T, Boolean> { + + private Function<T, Boolean> dataToStateGetter; + + public CoverDataFollower_ToggleButtonWidget() { + super(); + setGetter(() -> 0); // fake getter; used only for init + setSynced(false, false); + setLength(2); + } + + @Override + public CoverDataFollower_ToggleButtonWidget<T> setDataToStateGetter(Function<T, Boolean> dataToStateGetter) { + this.dataToStateGetter = dataToStateGetter; + return this; + } + + @Override + public CoverDataFollower_ToggleButtonWidget<T> setStateSetter(Consumer<Boolean> setter) { + super.setSetter(val -> setter.accept(val == 1)); + return this; + } + + @Override + public void updateState(T data) { + setState(dataToStateGetter.apply(data) ? 1 : 0, false, false); + } + + public CoverDataFollower_ToggleButtonWidget<T> setToggleTexture(IDrawable active, IDrawable inactive) { + setTextureGetter(state -> state == 1 ? active : inactive); + return this; + } + + public static <T extends ISerializableObject> CoverDataFollower_ToggleButtonWidget<T> ofCheckAndCross() { + return new CoverDataFollower_ToggleButtonWidget<T>() + .setToggleTexture(GT_UITextures.OVERLAY_BUTTON_CHECKMARK, GT_UITextures.OVERLAY_BUTTON_CROSS); + } + + public static <T extends ISerializableObject> CoverDataFollower_ToggleButtonWidget<T> ofCheck() { + return new CoverDataFollower_ToggleButtonWidget<T>() + .setToggleTexture(GT_UITextures.OVERLAY_BUTTON_CHECKMARK, GT_UITextures.TRANSPARENT); + } + + public static <T extends ISerializableObject> CoverDataFollower_ToggleButtonWidget<T> ofRedstone() { + return new CoverDataFollower_ToggleButtonWidget<T>() + .setToggleTexture(GT_UITextures.OVERLAY_BUTTON_REDSTONE_ON, GT_UITextures.OVERLAY_BUTTON_REDSTONE_OFF); + } + + public static <T extends ISerializableObject> CoverDataFollower_ToggleButtonWidget<T> ofDisableable() { + return new CoverDataFollower_DisableableToggleButtonWidget<>(); + } + + /** + * Disables clicking if button is already pressed. + */ + public static class CoverDataFollower_DisableableToggleButtonWidget<T extends ISerializableObject> + extends CoverDataFollower_ToggleButtonWidget<T> { + + public CoverDataFollower_DisableableToggleButtonWidget() { + super(); + } + + @Override + protected boolean canClick() { + return getState() == 0; + } + + @Override + public IDrawable[] getBackground() { + if (!canClick()) return new IDrawable[] {GT_UITextures.BUTTON_COVER_NORMAL_DISABLED}; + return super.getBackground(); + } + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/DataControllerWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/DataControllerWidget.java new file mode 100644 index 0000000000..f29b8eeaf9 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/DataControllerWidget.java @@ -0,0 +1,162 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.widget.ISyncedWidget; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.modularui.IDataFollowerWidget; +import gregtech.api.util.ISerializableObject; +import java.io.IOException; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; +import net.minecraft.network.PacketBuffer; + +/** + * Controls state of child widgets with specific data, and allows centralized control of multiple widgets. + * e.g. clicking button B will set machine mode to B, so button A, whose state is bound to the mode, + * will be automatically deactivated by this widget. + * <br> This widget wraps data and handles validation, e.g. tell client to close GUI when tile is broken or cover is removed. + * <br> Data can be anything, e.g. {@link ISerializableObject} or machine recipe mode. + * @param <T> Data type stored in this widget + * @see IDataFollowerWidget + */ +public abstract class DataControllerWidget<T> extends MultiChildWidget implements ISyncedWidget { + + private final Supplier<T> dataGetter; + private final Function<T, Boolean> dataSetter; + + protected T lastData; + + private boolean needsUpdate; + + /** + * @param dataGetter () -> data this widget handles + * @param dataSetter data to set -> if setting data is successful + */ + public DataControllerWidget(Supplier<T> dataGetter, Function<T, Boolean> dataSetter) { + this.dataGetter = dataGetter; + this.dataSetter = dataSetter; + } + + protected T getLastData() { + return lastData; + } + + @Override + public void onPostInit() { + super.onPostInit(); + // client _should_ have received initial cover data from `GT_UIInfos#openCoverUI` + lastData = dataGetter.get(); + if (NetworkUtils.isClient()) { + updateChildren(true); + } + } + + @Override + public void detectAndSendChanges(boolean init) { + T actualValue = dataGetter.get(); + if (actualValue == null) { + // data is in invalid state e.g. tile is broken, cover is removed + getWindow().tryClose(); + return; + } + if (init || !actualValue.equals(getLastData())) { + // init sync or someone else edited data + lastData = actualValue; + syncDataToClient(actualValue); + } + } + + protected void syncDataToClient(T data) { + syncToClient(0, buffer -> writeToPacket(buffer, data)); + } + + protected void syncDataToServer(T data) { + syncToServer(0, buffer -> writeToPacket(buffer, data)); + updateChildren(); + } + + @Override + public void readOnClient(int id, PacketBuffer buf) throws IOException { + if (id == 0) { + lastData = readFromPacket(buf); + dataSetter.apply(getLastData()); + updateChildren(); + } + } + + @Override + public void readOnServer(int id, PacketBuffer buf) throws IOException { + if (id == 0) { + lastData = readFromPacket(buf); + if (dataSetter.apply(getLastData())) { + markForUpdate(); + } else { + getWindow().closeWindow(); + } + } + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + protected void updateChildren(boolean postInit) { + for (Widget child : getChildren()) { + if (child instanceof IDataFollowerWidget) { + ((IDataFollowerWidget<T, ?>) child).updateState(getLastData()); + if (postInit) { + ((IDataFollowerWidget<T, ?>) child).onPostInit(); + } + } + } + } + + @SideOnly(Side.CLIENT) + protected void updateChildren() { + updateChildren(false); + } + + protected abstract void writeToPacket(PacketBuffer buffer, T data); + + protected abstract T readFromPacket(PacketBuffer buffer) throws IOException; + + @Override + public void markForUpdate() { + needsUpdate = true; + } + + @Override + public void unMarkForUpdate() { + needsUpdate = false; + } + + @Override + public boolean isMarkedForUpdate() { + return needsUpdate; + } + + /** + * @param widget widget to add that implements {@link IDataFollowerWidget} + * @param dataToStateGetter given data -> state of the widget to add + * @param dataUpdater (current data, state of the widget to add) -> new data to set + * @param applyForWidget methods to call for the widget to add + * @param <U> state type stored in the widget to add + * @param <W> widget type to add + */ + public <U, W extends Widget & IDataFollowerWidget<T, U>> DataControllerWidget<T> addFollower( + W widget, Function<T, U> dataToStateGetter, BiFunction<T, U, T> dataUpdater, Consumer<W> applyForWidget) { + widget.setDataToStateGetter(dataToStateGetter); + widget.setStateSetter(state -> { + T newData = dataUpdater.apply(getLastData(), state); + lastData = newData; + dataSetter.apply(getLastData()); + syncDataToServer(newData); + }); + applyForWidget.accept(widget); + addChild(widget); + return this; + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/FluidDisplaySlotWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/FluidDisplaySlotWidget.java new file mode 100644 index 0000000000..99200e5e8d --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/FluidDisplaySlotWidget.java @@ -0,0 +1,474 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.GT_Mod; +import gregtech.api.interfaces.IFluidAccess; +import gregtech.api.interfaces.IHasFluidDisplayItem; +import gregtech.api.interfaces.metatileentity.IFluidLockable; +import gregtech.api.util.GT_Utility; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Supplier; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +public class FluidDisplaySlotWidget extends SlotWidget { + + private IHasFluidDisplayItem iHasFluidDisplay; + private Supplier<IFluidAccess> fluidAccessConstructor; + private Supplier<Boolean> canDrainGetter; + private Supplier<Boolean> canFillGetter; + private Action actionRealClick = Action.NONE; + private Action actionDragAndDrop = Action.NONE; + private BiFunction<ClickData, FluidDisplaySlotWidget, Boolean> beforeRealClick; + private BiFunction<ClickData, FluidDisplaySlotWidget, Boolean> beforeDragAndDrop; + private Runnable updateFluidDisplayItem = () -> { + if (iHasFluidDisplay != null) { + iHasFluidDisplay.updateFluidDisplayItem(); + } + }; + + public FluidDisplaySlotWidget(BaseSlot slot) { + super(slot); + setAccess(false, false); + disableShiftInsert(); + } + + public FluidDisplaySlotWidget(IItemHandlerModifiable handler, int index) { + this(new BaseSlot(handler, index, true)); + } + + // === client actions === + + @Override + public ClickResult onClick(int buttonId, boolean doubleClick) { + if (actionRealClick == Action.NONE) return ClickResult.REJECT; + if (interactionDisabled) return ClickResult.REJECT; + + /* + * While a logical client don't really need to process fluid cells upon click (it could have just wait + * for server side to send the result), doing so would result in every fluid interaction having a + * noticeable delay between clicking and changes happening even on single player. + * I'd imagine this lag to become only more severe when playing MP over ethernet, which would have much more latency + * than a memory connection + */ + ClickData clickData = ClickData.create(buttonId, doubleClick); + ItemStack verifyToken = executeRealClick(clickData); + syncToServer(2, buffer -> { + clickData.writeToPacket(buffer); + try { + buffer.writeItemStackToBuffer(verifyToken); + } catch (IOException e) { + e.printStackTrace(); + } + }); + return ClickResult.ACCEPT; + } + + @Override + public boolean handleDragAndDrop(ItemStack draggedStack, int button) { + if (actionDragAndDrop == Action.NONE || actionDragAndDrop == Action.TRANSFER) return false; + if (interactionDisabled) return false; + + ClickData clickData = ClickData.create(button, false); + executeDragAndDrop(clickData, draggedStack); + syncToServer(5, buffer -> { + try { + clickData.writeToPacket(buffer); + buffer.writeItemStackToBuffer(draggedStack); + } catch (IOException e) { + e.printStackTrace(); + } + }); + draggedStack.stackSize = 0; + return true; + } + + @Override + public List<String> getExtraTooltip() { + return Collections.emptyList(); + } + + // === server actions === + + @Override + public void readOnServer(int id, PacketBuffer buf) throws IOException { + if (id == 1) { + getMcSlot().xDisplayPosition = buf.readVarIntFromBuffer(); + getMcSlot().yDisplayPosition = buf.readVarIntFromBuffer(); + } else if (id == 2) { + onClickServer(ClickData.readPacket(buf), buf.readItemStackFromBuffer()); + } else if (id == 3) { + phantomScroll(buf.readVarIntFromBuffer()); + } else if (id == 4) { + setEnabled(buf.readBoolean()); + } else if (id == 5) { + executeDragAndDrop(ClickData.readPacket(buf), buf.readItemStackFromBuffer()); + if (onDragAndDropComplete != null) { + onDragAndDropComplete.accept(this); + } + } + markForUpdate(); + } + + private void onClickServer(ClickData clickData, ItemStack clientVerifyToken) { + ItemStack serverVerifyToken = executeRealClick(clickData); + // similar to what NetHandlerPlayServer#processClickWindow does + if (!ItemStack.areItemStacksEqual(clientVerifyToken, serverVerifyToken)) { + ((EntityPlayerMP) getContext().getPlayer()) + .sendContainerToPlayer(getContext().getContainer()); + } + } + + // === client/server actions === + + private ItemStack executeRealClick(ClickData clickData) { + if (actionRealClick == Action.NONE) return null; + if (beforeRealClick != null && !beforeRealClick.apply(clickData, this)) return null; + + ItemStack ret = null; + if (actionRealClick == Action.TRANSFER) { + if (fluidAccessConstructor == null) { + GT_Mod.GT_FML_LOGGER.warn( + "FluidDisplaySlotWidget is asked to transfer fluid, but fluidAccessConstructor is null!"); + return null; + } + ret = transferFluid( + fluidAccessConstructor.get(), + getContext().getPlayer(), + clickData.mouseButton == 0, + canDrainGetter != null ? canDrainGetter.get() : true, + canFillGetter != null ? canFillGetter.get() : true); + } else if (actionRealClick == Action.LOCK) { + lockFluid(getContext().getPlayer().inventory.getItemStack()); + } + + updateFluidDisplayItem.run(); + return ret; + } + + protected ItemStack transferFluid( + IFluidAccess aFluidAccess, + EntityPlayer aPlayer, + boolean aProcessFullStack, + boolean aCanDrain, + boolean aCanFill) { + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; + FluidStack tInputFluid = aFluidAccess.get(); + FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); + if (tFluidHeld != null && tFluidHeld.amount <= 0) tFluidHeld = null; + if (tInputFluid == null) { + // tank empty, consider fill only from now on + if (!aCanFill) + // cannot fill and nothing to take, bail out + return null; + if (tFluidHeld == null) + // no fluid to fill + return null; + return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); + } + // tank not empty, both action possible + if (tFluidHeld != null && tInputFluid.amount < aFluidAccess.getCapacity()) { + // both nonnull and have space left for filling. + if (aCanFill) + // actually both pickup and fill is reasonable, but I'll go with fill here + return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); + if (!aCanDrain) + // cannot take AND cannot fill, why make this call then? + return null; + // the slot does not allow filling, so try take some + return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); + } else { + // cannot fill and there is something to take + if (!aCanDrain) + // but the slot does not allow taking, so bail out + return null; + return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); + } + } + + protected static ItemStack drainFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack) { + FluidStack tTankStack = aFluidAccess.get(); + if (tTankStack == null) return null; + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; + int tOriginalFluidAmount = tTankStack.amount; + ItemStack tFilledContainer = GT_Utility.fillFluidContainer(tTankStack, tStackSizedOne, true, false); + if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); + int tFilledAmount = tContainerItem.fill(tStackSizedOne, tTankStack, true); + if (tFilledAmount > 0) { + tFilledContainer = tStackSizedOne; + tTankStack.amount -= tFilledAmount; + } + } + if (tFilledContainer != null) { + if (aProcessFullStack) { + int tFilledAmount = tOriginalFluidAmount - tTankStack.amount; + /* + work out how many more items we can fill + one cell is already used, so account for that + the round down behavior will left over a fraction of a cell worth of fluid + the user then get to decide what to do with it + it will not be too fancy if it spills out partially filled cells + */ + int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, tTankStack.amount / tFilledAmount); + tTankStack.amount -= tFilledAmount * tAdditionalParallel; + tFilledContainer.stackSize += tAdditionalParallel; + } + replaceCursorItemStack(aPlayer, tFilledContainer); + } + aFluidAccess.verifyFluidStack(); + return tFilledContainer; + } + + protected static ItemStack fillFluid( + IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { + // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves + if (aFluidAccess.get() != null && !aFluidAccess.get().isFluidEqual(aFluidHeld)) return null; + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null) return null; + + int tFreeSpace = aFluidAccess.getCapacity() - (aFluidAccess.get() != null ? aFluidAccess.get().amount : 0); + if (tFreeSpace <= 0) + // no space left + return null; + + // find out how much fluid can be taken + // some cells cannot be partially filled + ItemStack tStackEmptied = null; + int tAmountTaken = 0; + if (tFreeSpace >= aFluidHeld.amount) { + // fully accepted - try take it from item now + // IFluidContainerItem is intentionally not checked here. it will be checked later + tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); + tAmountTaken = aFluidHeld.amount; + } + if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + // either partially accepted, or is IFluidContainerItem + IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); + FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); + if (tDrained != null && tDrained.amount > 0) { + // something is actually drained - change the cell and drop it to player + tStackEmptied = tStackSizedOne; + tAmountTaken = tDrained.amount; + } + } + if (tStackEmptied == null) + // somehow the cell refuse to give out that amount of fluid, no op then + return null; + + // find out how many fill can we do + // same round down behavior as above + // however here the fluid stack is not changed at all, so the exact code will slightly differ + int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; + if (aFluidAccess.get() == null) { + FluidStack tNewFillableStack = aFluidHeld.copy(); + tNewFillableStack.amount = tAmountTaken * tParallel; + aFluidAccess.set(tNewFillableStack); + } else { + aFluidAccess.addAmount(tAmountTaken * tParallel); + } + tStackEmptied.stackSize = tParallel; + replaceCursorItemStack(aPlayer, tStackEmptied); + return tStackEmptied; + } + + protected static void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { + int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); + while (tStackResult.stackSize > tStackResultMaxStackSize) { + aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); + } + if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { + // every cell is mutated. it could just stay on the cursor. + aPlayer.inventory.setItemStack(tStackResult); + } else { + // some cells not mutated. The mutated cells must go into the inventory + // or drop into the world if there isn't enough space. + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + tStackHeld.stackSize -= tStackResult.stackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); + } + } + + protected void executeDragAndDrop(ClickData clickData, ItemStack draggedStack) { + if (actionDragAndDrop == Action.NONE || actionDragAndDrop == Action.TRANSFER) return; + if (beforeDragAndDrop != null && !beforeDragAndDrop.apply(clickData, this)) return; + + if (actionDragAndDrop == Action.LOCK) { + lockFluid(draggedStack); + } + updateFluidDisplayItem.run(); + } + + protected void lockFluid(ItemStack cursorStack) { + if (!(iHasFluidDisplay instanceof IFluidLockable)) return; + IFluidLockable mteToLock = (IFluidLockable) iHasFluidDisplay; + + if (cursorStack == null) { + if (!mteToLock.allowChangingLockedFluid(null)) return; + + mteToLock.lockFluid(false); + mteToLock.setLockedFluidName(null); + GT_Utility.sendChatToPlayer(getContext().getPlayer(), GT_Utility.trans("300.1", "Fluid Lock Cleared.")); + + if (!isClient()) { + mteToLock.onFluidLockPacketReceived(null); + } + } else { + FluidStack fluidStack = GT_Utility.getFluidFromContainerOrFluidDisplay(cursorStack); + if (fluidStack == null) return; + Fluid tFluid = fluidStack.getFluid(); + if (tFluid == null) return; + + if (!mteToLock.allowChangingLockedFluid(tFluid.getName())) return; + + mteToLock.lockFluid(true); + mteToLock.setLockedFluidName(tFluid.getName()); + GT_Utility.sendChatToPlayer( + getContext().getPlayer(), + String.format( + GT_Utility.trans("151.4", "Successfully locked Fluid to %s"), + new FluidStack(tFluid, 1).getLocalizedName())); + + if (!isClient()) { + mteToLock.onFluidLockPacketReceived(tFluid.getName()); + } + } + } + + protected void updateFluidDisplayItem() { + if (iHasFluidDisplay != null) { + iHasFluidDisplay.updateFluidDisplayItem(); + } + } + + // === setters === + + public FluidDisplaySlotWidget setFluidAccessConstructor(Supplier<IFluidAccess> fluidAccessConstructor) { + this.fluidAccessConstructor = fluidAccessConstructor; + return this; + } + + public FluidDisplaySlotWidget setIHasFluidDisplay(IHasFluidDisplayItem iHasFluidDisplay) { + this.iHasFluidDisplay = iHasFluidDisplay; + return this; + } + + public FluidDisplaySlotWidget setCanDrainGetter(Supplier<Boolean> canDrainGetter) { + this.canDrainGetter = canDrainGetter; + return this; + } + + public FluidDisplaySlotWidget setCanDrain(boolean canDrain) { + return setCanDrainGetter(() -> canDrain); + } + + public FluidDisplaySlotWidget setCanFillGetter(Supplier<Boolean> canFillGetter) { + this.canFillGetter = canFillGetter; + return this; + } + + public FluidDisplaySlotWidget setCanFill(boolean canFill) { + return setCanFillGetter(() -> canFill); + } + + /** + * Sets action called on click while holding the real item. + */ + public FluidDisplaySlotWidget setActionRealClick(Action actionRealClick) { + this.actionRealClick = actionRealClick; + return this; + } + + /** + * Sets action called on drag-and-drop from NEI. + * You can't use {@link Action#TRANSFER} here. + */ + public FluidDisplaySlotWidget setActionDragAndDrop(Action actionDragAndDrop) { + this.actionDragAndDrop = actionDragAndDrop; + return this; + } + + /** + * Sets function called before {@link #executeRealClick}. + * @param beforeRealClick (click data, this widget) -> if allow click + */ + public FluidDisplaySlotWidget setBeforeRealClick( + BiFunction<ClickData, FluidDisplaySlotWidget, Boolean> beforeRealClick) { + this.beforeRealClick = beforeRealClick; + return this; + } + + /** + * Sets function called before {@link #executeDragAndDrop}. + * @param beforeDragAndDrop (click data, this widget) -> if allow click + */ + public FluidDisplaySlotWidget setBeforeDragAndDrop( + BiFunction<ClickData, FluidDisplaySlotWidget, Boolean> beforeDragAndDrop) { + this.beforeDragAndDrop = beforeDragAndDrop; + return this; + } + + /** + * Sets function called before both of {@link #executeRealClick} and {@link #executeDragAndDrop}. + * @param beforeClick (click data, this widget) -> if allow click + */ + public FluidDisplaySlotWidget setBeforeClick(BiFunction<ClickData, FluidDisplaySlotWidget, Boolean> beforeClick) { + setBeforeRealClick(beforeClick); + setBeforeDragAndDrop(beforeClick); + return this; + } + + /** + * By default, this widget runs {@link IHasFluidDisplayItem#updateFluidDisplayItem} after click. + * You can specify custom update action with this method. + */ + public FluidDisplaySlotWidget setUpdateFluidDisplayItem(Runnable updateFluidDisplayItem) { + this.updateFluidDisplayItem = updateFluidDisplayItem; + return this; + } + + /** + * Action triggered on mouse click or NEI drag-and-drop. + */ + public enum Action { + + /** + * Fill/drain fluid into/from the tank. + * Uses fluid amount, so drag-and-drop cannot use this mode. + */ + TRANSFER, + + /** + * Lock fluid for {@link IFluidLockable}. + * Does not use fluid amount. + */ + LOCK, + + /** + * Set filter for the tank. (not implemented yet) + * Does not use fluid amount. + */ + FILTER, + + /** + * Does nothing. + */ + NONE + } +} diff --git a/src/main/java/gregtech/common/gui/modularui/widget/ItemWatcherSlotWidget.java b/src/main/java/gregtech/common/gui/modularui/widget/ItemWatcherSlotWidget.java new file mode 100644 index 0000000000..7385208874 --- /dev/null +++ b/src/main/java/gregtech/common/gui/modularui/widget/ItemWatcherSlotWidget.java @@ -0,0 +1,47 @@ +package gregtech.common.gui.modularui.widget; + +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.api.util.GT_Utility; +import java.util.function.Supplier; +import net.minecraft.item.ItemStack; + +/** + * Watches specific ItemStack and pulls changes from it. + * Player cannot interact with slot, other than viewing NEI recipe or adding bookmark. + */ +public class ItemWatcherSlotWidget extends SlotWidget { + + private ItemStack lastItem; + private Supplier<ItemStack> getter; + + public ItemWatcherSlotWidget() { + super(BaseSlot.phantom(new ItemStackHandler(), 0)); + disableInteraction(); + } + + public ItemWatcherSlotWidget setGetter(Supplier<ItemStack> getter) { + this.getter = getter; + return this; + } + + @Override + public void detectAndSendChanges(boolean init) { + ItemStack target = getter.get(); + if (init || !GT_Utility.areStacksEqual(lastItem, target)) { + ItemStack toPut; + if (target != null) { + toPut = target.copy(); + toPut.stackSize = 1; + } else { + toPut = null; + } + ((IItemHandlerModifiable) getMcSlot().getItemHandler()).setStackInSlot(0, toPut); + lastItem = target; + getMcSlot().onSlotChanged(); + } + super.detectAndSendChanges(init); + } +} |