diff options
author | miozune <miozune@gmail.com> | 2022-11-26 01:45:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-25 17:45:28 +0100 |
commit | 9a2741128a78bb52eba50a631126e090a5a2abd8 (patch) | |
tree | a90f47aa94951acb4050e45dc3ed60698e79cf32 /src/main/java/gregtech/api | |
parent | 51537482fefc4f9c6d3fbd93d119c333a63dcd7b (diff) | |
download | GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.gz GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.bz2 GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.zip |
Rewrite GUIs with ModularUI (#1381)
* Base work for ModularUI compat
* Remove useless interface
* Add almost all the widgets
* Invert method
* Refactor NEI stack placement positions
* NEI handlers on ModularUI
* Add some more docs
* AdvDebugStructureWriter
* Fix NEI progressbar not working
* PrimitiveBlastFurnace
* clean
* derp
* clean
* spotlessApply
* Boilers
* Buffers
* clean
* N by N slots containers
* Fix boilers not having bucket interaction
Put opening UI to individual MetaTEs
* Maintenance Hatch
* clean
* spotlessApply
* Add dependency
* IndustrialApiary
* Adapt to ModularUI change
* Base work for covers & fix crash with MP
* Fix crash with server
* Rewrite base work for covers
* Send initial cover data on cover GUI open
so that the time of showing incorrect data will be eliminated
* Covers part 1
* Rename package: ModularUI -> modularui
* Rename class: GT_UIInfo -> GT_UIInfos
* Fix build
* Covers part2
* Fix missing client check with tile UI & fix title overlap
* CoverTabLine
* Move cover window creators to inner class
* Fix crash with null base TE
* Close GUI when tile is broken
* Color cover window with tile colorization
* Change signature of addUIWidgets
* FluidFilter cover, FluidDisplaySlotWidget, BasicTank, BasicGenerator, Output Hatch, MicrowaveEnergyTransmitter, Teleporter, DigitalChest, DigitalTank
* Add title tab
* Move package: modularui -> modularui/widget
* Programmed circuit + IConfigurationCircuitSupport
* clean
* VolumetricFlask
* Remove integrated circuit overlay from recipe input slots
* Input Hatch & Quadruple Input Hatch
* Multiblock
* Deprecate old cover GUI
* BasicMachines
* Finish BasicMachine & NEI
* Expand DTPF NEI to 9 slots
* Fix ME input bus on MP
* Move AESlotWidget to public class
* Move GT_Recipe_Map constructors with mNEIUnificateOutput to setter method
* Move SteamTexture.Variant to outer enum
* Switch to remote repository
* oops
* Update MUI
* Update MUI
* Minor refactor for change amount buttons
* Display items and fluids that exceed usual count
* blah
* use +=, why didn't I do this
* Update MUI
* Move ModularUI to Base (#1510)
* Move ModularUI to Base
* Move most of the ModularUI functionality to `BaseTileEntity` (and `CoverableTileEntity`)
* `CommonMetaTileEntity` delegates ato the MetaTileEntity
* Added several interfaces (with defaults) to indicate if a tile/metatile override/implement certain behaviors.
* Moved `IConfigurationCircuitSupport` interface such that it will work with BaseTileEntity or a MetaTileEntity
* Address reviews
Co-authored-by: miozune <miozune@gmail.com>
* Update MUI
* Minor changes to NEI
* Return :facepalm:
* IGetTabIconSet override
* Some more changes to NEI
* Merge texture getter interfaces to new class GUITextureSet
* Remove BBF structure picture as it's auto-buildable now
* Make unified title tab style of texture angular
* Expose some boiler texture getters for addon
* Fix crash with cover GUI on pipe
* Lower the number of recipe per page for DTPF & update MUI
* Update MUI
* Fix crash with middle-clicking slot on circuit selection GUI
* Fix circuit selection window not syncing item from base machine
* Merge GT_NEI_AssLineHandler into GT_NEI_DefaultHandler
* Update MUI
* Add in TecTech multi message
* Allow changing the way of binding player inventory
* Update MUI
* Update MUI
* Update MUI
* Update MUI
* Update MUI
* Make MUI non-transitive to allow addons to use their own version
* Force enable mixin
* Format fluid amount tooltip
* Add GUITextureSet.STEAM
* Add guard against null ModularWindow creation
* Add constructors for Muffler Hatch with inventory
* Fix output slot on digital chest and tank allowing insertion
* Don't log null ModularWindow
* Add default implementation for IHasWorldObjectAndCoords#openGUI
* Make openGTTileEntityUI accept MultiTE & cleanup
Co-authored-by: Jason Mitchell <mitchej@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api')
78 files changed, 5213 insertions, 2366 deletions
diff --git a/src/main/java/gregtech/api/enums/Dyes.java b/src/main/java/gregtech/api/enums/Dyes.java index 46207ee781..2a546e6138 100644 --- a/src/main/java/gregtech/api/enums/Dyes.java +++ b/src/main/java/gregtech/api/enums/Dyes.java @@ -125,4 +125,8 @@ public enum Dyes implements IColorModulationContainer { public short[] getRGBA() { return mRGBa; } + + public static Dyes getDyeFromIndex(short index) { + return index != -1 ? Dyes.get(index) : Dyes.MACHINE_METAL; + } } diff --git a/src/main/java/gregtech/api/enums/SteamVariant.java b/src/main/java/gregtech/api/enums/SteamVariant.java new file mode 100644 index 0000000000..333f678900 --- /dev/null +++ b/src/main/java/gregtech/api/enums/SteamVariant.java @@ -0,0 +1,15 @@ +package gregtech.api.enums; + +import java.util.Locale; + +public enum SteamVariant { + BRONZE, + STEEL, + PRIMITIVE, + NONE; + + @Override + public String toString() { + return super.toString().toLowerCase(Locale.ENGLISH); + } +} diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java index f2774bbd38..588fb415c2 100644 --- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java @@ -2,7 +2,7 @@ package gregtech.api.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; diff --git a/src/main/java/gregtech/api/gui/GT_Container_1by1.java b/src/main/java/gregtech/api/gui/GT_Container_1by1.java index 3c65c5e590..882b4d0502 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_1by1.java +++ b/src/main/java/gregtech/api/gui/GT_Container_1by1.java @@ -4,6 +4,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +@Deprecated public class GT_Container_1by1 extends GT_ContainerMetaTile_Machine { public GT_Container_1by1(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/main/java/gregtech/api/gui/GT_Container_2by2.java b/src/main/java/gregtech/api/gui/GT_Container_2by2.java index 92d50b3aae..4267423b75 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_2by2.java +++ b/src/main/java/gregtech/api/gui/GT_Container_2by2.java @@ -4,6 +4,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +@Deprecated public class GT_Container_2by2 extends GT_ContainerMetaTile_Machine { public GT_Container_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java deleted file mode 100644 index d2d6249e5b..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_2by2_Fluid.java +++ /dev/null @@ -1,97 +0,0 @@ -package gregtech.api.gui; - -import gregtech.api.interfaces.IFluidAccess; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_MultiInput; -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_2by2_Fluid extends GT_ContainerMetaTile_Machine { - - public GT_Container_2by2_Fluid(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - /** - * Subclasses must ensure third slot (aSlotIndex==2) is drainable fluid display item slot. - * Otherwise, subclasses must intercept the appropriate the slotClick event and call super.slotClick(2, xxx) if necessary - */ - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Render(mTileEntity, 0, 71, 26)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 1, 89, 26)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 71, 44)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 3, 89, 44)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 4 && aSlotIndex >= 0 && aMouseclick < 2) { - GT_MetaTileEntity_Hatch_MultiInput tTank = - (GT_MetaTileEntity_Hatch_MultiInput) mTileEntity.getMetaTileEntity(); - if (mTileEntity.isClientSide()) { - /* - * See comment in gregtech.api.gui.GT_Container_BasicTank.slotClick on why this is necessary - */ - Slot slot = (Slot) inventorySlots.get(aSlotIndex); - tTank.setFluid(GT_Utility.getFluidFromDisplayStack(slot.getStack()), aSlotIndex); - } - MultiFluidAccess tDrainableAccess = MultiFluidAccess.from(tTank, aSlotIndex); - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackHeld, true); - if (tDrainableAccess.isMatch(tFluidHeld, aSlotIndex)) - return handleFluidSlotClick( - tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public int getSlotCount() { - return 0; - } - - @Override - public int getShiftClickSlotCount() { - return 0; - } - - static class MultiFluidAccess implements IFluidAccess { - private final GT_MetaTileEntity_Hatch_MultiInput mTank; - private final int mSlot; - - public MultiFluidAccess(GT_MetaTileEntity_Hatch_MultiInput aTank, int aSlot) { - this.mTank = aTank; - this.mSlot = aSlot; - } - - public boolean isMatch(FluidStack stack, int slot) { - if (!mTank.hasFluid(stack)) return true; - if (stack == null) return true; - return stack.equals(mTank.getFluid(slot)); - } - - @Override - public void set(FluidStack stack) { - mTank.setFluid(stack, mSlot); - } - - @Override - public FluidStack get() { - return mTank.getFluid(mSlot); - } - - @Override - public int getCapacity() { - return mTank.getCapacity(); - } - - static MultiFluidAccess from(GT_MetaTileEntity_Hatch_MultiInput aTank, int aSlot) { - return new MultiFluidAccess(aTank, aSlot); - } - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_3by3.java b/src/main/java/gregtech/api/gui/GT_Container_3by3.java index 282d740347..80f3e213d6 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_3by3.java +++ b/src/main/java/gregtech/api/gui/GT_Container_3by3.java @@ -4,6 +4,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +@Deprecated public class GT_Container_3by3 extends GT_ContainerMetaTile_Machine { public GT_Container_3by3(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/main/java/gregtech/api/gui/GT_Container_4by4.java b/src/main/java/gregtech/api/gui/GT_Container_4by4.java index 0b38a265a6..6aa0717a11 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_4by4.java +++ b/src/main/java/gregtech/api/gui/GT_Container_4by4.java @@ -4,6 +4,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +@Deprecated public class GT_Container_4by4 extends GT_ContainerMetaTile_Machine { public GT_Container_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index dc306ec223..bc0ac72a8b 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -6,7 +6,6 @@ import gregtech.api.interfaces.IFluidAccess; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalTankBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -123,8 +122,6 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { public void set(FluidStack stack) { if (mIsFillableStack) mTank.setFillableStack(stack); else mTank.setDrainableStack(stack); - if (mTank instanceof GT_MetaTileEntity_DigitalTankBase) - ((GT_MetaTileEntity_DigitalTankBase) mTank).onEmptyingContainerWhenEmpty(); } @Override diff --git a/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java b/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java deleted file mode 100644 index f12f2a2ad0..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_DigitalTank.java +++ /dev/null @@ -1,185 +0,0 @@ -package gregtech.api.gui; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.IFluidAccess; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalTankBase; -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_DigitalTank extends GT_Container_BasicTank { - - public boolean outputFluid = false; - public boolean mLockFluid = false; - public boolean mVoidFluidPart = false; - public boolean mVoidFluidFull = false; - public boolean mAllowInputFromOutputSide = false; - - public Slot slotAutoOutput; - public Slot slotLockFLuid; - public Slot slotVoidOverFlow; - public Slot slotVoidFull; - public Slot slotInputFromOutput; - - public GT_Container_DigitalTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 81, 17)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 81, 44)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); - addSlotToContainer(slotAutoOutput = new GT_Slot_Holo(mTileEntity, 3, 8, 64, false, true, 1)); - addSlotToContainer(slotLockFLuid = new GT_Slot_Holo(mTileEntity, 4, 26, 64, false, true, 1)); - addSlotToContainer(slotVoidOverFlow = new GT_Slot_Holo(mTileEntity, 5, 152, 8, false, true, 1)); - addSlotToContainer(slotVoidFull = new GT_Slot_Holo(mTileEntity, 6, 152, 26, false, true, 1)); - addSlotToContainer(slotInputFromOutput = new GT_Slot_Holo(mTileEntity, 7, 44, 64, false, true, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - - GT_MetaTileEntity_DigitalTankBase mte = ((GT_MetaTileEntity_DigitalTankBase) mTileEntity.getMetaTileEntity()); - - if (aSlotIndex == 3) { - mte.mOutputFluid = !mte.mOutputFluid; - if (!mte.mOutputFluid) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("262", "Fluid Auto Output Disabled")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("263", "Fluid Auto Output Enabled")); - } - return null; - } - if (aSlotIndex == 4) { - String inBrackets; - mte.mLockFluid = !mte.mLockFluid; - if (mte.mLockFluid) { - if (mte.mFluid == null) { - mte.setLockedFluidName(null); - inBrackets = GT_Utility.trans("264", "currently none, will be locked to the next that is put in"); - } else { - mte.setLockedFluidName(mte.getDrainableStack().getFluid().getName()); - inBrackets = mte.getDrainableStack().getLocalizedName(); - } - GT_Utility.sendChatToPlayer( - aPlayer, String.format("%s (%s)", GT_Utility.trans("265", "1 specific Fluid"), inBrackets)); - } else { - mte.setLockedFluidName(null); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("266", "Lock Fluid Mode Disabled")); - } - return null; - } - if (aSlotIndex == 5) { - mte.mVoidFluidPart = !mte.mVoidFluidPart; - if (!mte.mVoidFluidPart) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("267", "Overflow Voiding Mode Disabled")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("268", "Overflow Voiding Mode Enabled")); - } - return null; - } - if (aSlotIndex == 6) { - mte.mVoidFluidFull = !mte.mVoidFluidFull; - if (!mte.mVoidFluidFull) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("269", "Void Full Mode Disabled")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("270", "Void Full Mode Enabled")); - return null; - } - } - if (aSlotIndex == 7) { - mte.mAllowInputFromOutputSide = !mte.mAllowInputFromOutputSide; - if (!mte.mAllowInputFromOutputSide) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.getTrans("096")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.getTrans("095")); - } - return null; - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void sendProgressBar() { - GT_MetaTileEntity_DigitalTankBase mte = ((GT_MetaTileEntity_DigitalTankBase) mTileEntity.getMetaTileEntity()); - - for (Object crafter : this.crafters) { - ICrafting player = (ICrafting) crafter; - if (mContent != oContent) { - player.sendProgressBarUpdate(this, 100, mContent & 65535); - player.sendProgressBarUpdate(this, 101, mContent >>> 16); - } - if (outputFluid != mte.mOutputFluid) { - player.sendProgressBarUpdate(this, 103, mte.mOutputFluid ? 1 : 0); - } - if (mLockFluid != mte.mLockFluid) { - player.sendProgressBarUpdate(this, 104, mte.mLockFluid ? 1 : 0); - } - if (mVoidFluidPart != mte.mVoidFluidPart) { - player.sendProgressBarUpdate(this, 105, mte.mVoidFluidPart ? 1 : 0); - } - if (mVoidFluidFull != mte.mVoidFluidFull) { - player.sendProgressBarUpdate(this, 106, mte.mVoidFluidFull ? 1 : 0); - } - if (mAllowInputFromOutputSide != mte.mAllowInputFromOutputSide) { - player.sendProgressBarUpdate(this, 107, mte.mAllowInputFromOutputSide ? 1 : 0); - } - } - - outputFluid = mte.mOutputFluid; - mLockFluid = mte.mLockFluid; - mVoidFluidPart = mte.mVoidFluidPart; - mVoidFluidFull = mte.mVoidFluidFull; - mAllowInputFromOutputSide = mte.mAllowInputFromOutputSide; - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 103: - outputFluid = (value != 0); - break; - case 104: - mLockFluid = (value != 0); - break; - case 105: - mVoidFluidPart = (value != 0); - break; - case 106: - mVoidFluidFull = (value != 0); - break; - case 107: - mAllowInputFromOutputSide = (value != 0); - break; - } - } - - @Override - protected IFluidAccess constructFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { - return new DigitalTankFluidAccess(aTank, aIsFillableStack); - } - - static class DigitalTankFluidAccess extends BasicTankFluidAccess { - - public DigitalTankFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { - super(aTank, aIsFillableStack); - } - - @Override - public int getRealCapacity() { - return ((GT_MetaTileEntity_DigitalTankBase) mTank).getRealCapacity(); - } - - @Override - public void verifyFluidStack() {} - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java b/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java deleted file mode 100644 index fcaf618b56..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java +++ /dev/null @@ -1,30 +0,0 @@ -package gregtech.api.gui; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public class GT_Container_MaintenanceHatch extends GT_ContainerMetaTile_Machine { - - public GT_Container_MaintenanceHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 80, 35, 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); - ItemStack tStack = aPlayer.inventory.getItemStack(); - if (tStack != null) { - ((GT_MetaTileEntity_Hatch_Maintenance) mTileEntity.getMetaTileEntity()).onToolClick(tStack, aPlayer); - if (tStack.stackSize <= 0) aPlayer.inventory.setItemStack(null); - } - return null; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java index 722057950b..4bfc14ad57 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java @@ -9,6 +9,7 @@ import net.minecraft.inventory.Slot; * <p/> * The Container I use for all my Basic Machines */ +@Deprecated public class GT_Container_MultiMachine extends GT_ContainerMetaTile_Machine { public GT_Container_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); diff --git a/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java b/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java deleted file mode 100644 index 0622f52865..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_SpecialFilter.java +++ /dev/null @@ -1,123 +0,0 @@ -package gregtech.api.gui; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SpecialFilter; -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; - -public class GT_Container_SpecialFilter extends GT_ContainerMetaTile_Machine { - - private GT_Slot_Render mSpecialSlot; - - public GT_Container_SpecialFilter(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(mSpecialSlot = new GT_Slot_Render(this.mTileEntity, 9, 35, 23)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 8, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 26, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 44, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 62, 63, false, true, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 10, 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 == 9) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()) - .clickTypeIcon(aMouseclick != 0, aPlayer.inventory.getItemStack()); - return null; - } - if (aSlotIndex == 10) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput = - (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bOutput); - if (((GT_MetaTileEntity_SpecialFilter) 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 == 11) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = - (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); - if (((GT_MetaTileEntity_SpecialFilter) 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 == 12) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert = - (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvert); - if (((GT_MetaTileEntity_SpecialFilter) 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 == 13) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter = - (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bInvertFilter); - if (((GT_MetaTileEntity_SpecialFilter) 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 == 14) { - ((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed = - (!((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed); - if (((GT_MetaTileEntity_SpecialFilter) this.mTileEntity.getMetaTileEntity()).bNBTAllowed) { - 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; - } - - public GT_Slot_Render getSpecialSlot() { - return mSpecialSlot; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java index 63c7b224b5..f934102eb9 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java +++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java @@ -13,12 +13,16 @@ public class GT_GUIColorOverride { public GT_GUIColorOverride(String guiTexturePath) { try { + // this is dumb, but CombTypeTest causes cascading class load + // and leads to instantiation of GT_CoverBehaviorBase + if (Minecraft.getMinecraft() == null) return; IResource ir = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(guiTexturePath)); if (ir.hasMetadata()) { cmSection = (ColorsMetadataSection) ir.getMetadata("colors"); } - } catch (IOException ignore) { + } catch (IOException | NoClassDefFoundError ignore) { + // this is also dumb, but FMLCommonHandler#getEffectiveSide doesn't work during test } } diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index 0752324678..19aa8fa9a8 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -9,7 +9,7 @@ import gregtech.api.gui.widgets.GT_GuiTabLine.DisplayStyle; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer; import gregtech.api.gui.widgets.GT_GuiTooltipManager.GT_IToolTipRenderer; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java index 16ef27c941..694b212872 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +@Deprecated public class GT_GUIContainer_1by1 extends GT_GUIContainerMetaTile_Machine { private final String mName; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java index 909a5b0d6a..069e6f67fe 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +@Deprecated public class GT_GUIContainer_2by2 extends GT_GUIContainerMetaTile_Machine { private final String mName; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java deleted file mode 100644 index d896349f0a..0000000000 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2_Fluid.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.api.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.StatCollector; - -public class GT_GUIContainer_2by2_Fluid extends GT_GUIContainerMetaTile_Machine { - - private final String mName; - private final int textColor = this.getTextColorOrDefault("title", 0x404040); - - public GT_GUIContainer_2by2_Fluid(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new GT_Container_2by2_Fluid(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "2by2fluid.png"); - mName = aName; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, textColor); - fontRendererObj.drawString(mName, 8, 6, textColor); - } - - @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/api/gui/GT_GUIContainer_3by3.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java index 97caa08946..2ce72e054c 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +@Deprecated public class GT_GUIContainer_3by3 extends GT_GUIContainerMetaTile_Machine { private final String mName; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java index 40441e3093..df8e3d137b 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; +@Deprecated public class GT_GUIContainer_4by4 extends GT_GUIContainerMetaTile_Machine { private final String mName; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index 35dcf047a7..50272f4820 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -22,9 +22,6 @@ import net.minecraft.util.StatCollector; * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> * The GUI-Container I use for all my Basic Machines - * <p/> - * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes - * which extend this class */ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machine implements NEI_TransferRectHost { private static final int NEEDS_STEAM_VENTING = 64; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java deleted file mode 100644 index 163aaa2929..0000000000 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_DigitalTank.java +++ /dev/null @@ -1,111 +0,0 @@ -package gregtech.api.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.enums.GT_Values; -import gregtech.api.gui.widgets.GT_GuiSlotTooltip; -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 gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalTankBase; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public class GT_GUIContainer_DigitalTank extends GT_GUIContainerMetaTile_Machine implements IDragAndDropSupport { - - private final String mName; - private final int textColor = this.getTextColorOrDefault("text", 0xFAFAFF); - private final int textColorTitle = this.getTextColorOrDefault("title", 0x404040); - private final int textColorValue = this.getTextColorOrDefault("value", 0xFAFAFF); - - private static final String DIGITALTANK_AUTOOUTPUT_TOOLTIP = "GT5U.machines.digitaltank.autooutput.tooltip"; - private static final String DIGITALTANK_LOCKFLUID_TOOLTIP = "GT5U.machines.digitaltank.lockfluid.tooltip"; - private static final String DIGITALTANK_VOIDOVERFLOW_TOOLTIP = "GT5U.machines.digitaltank.voidoverflow.tooltip"; - private static final String DIGITALTANK_VOIDFULL_TOOLTIP = "GT5U.machines.digitaltank.voidfull.tooltip"; - private static final String DIGITALTANK_INPUTFROMOUTPUT_TOOLTIP = - "GT5U.machines.digitaltank.inputfromoutput.tooltip"; - - public GT_GUIContainer_DigitalTank( - InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { - super(new GT_Container_DigitalTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "DigitalTank.png"); - mName = aName; - } - - @Override - protected void setupTooltips() { - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotAutoOutput, mTooltipCache.getData(DIGITALTANK_AUTOOUTPUT_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotLockFLuid, mTooltipCache.getData(DIGITALTANK_LOCKFLUID_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotVoidOverFlow, mTooltipCache.getData(DIGITALTANK_VOIDOVERFLOW_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotVoidFull, mTooltipCache.getData(DIGITALTANK_VOIDFULL_TOOLTIP))); - addToolTip(new GT_GuiSlotTooltip( - getContainer().slotInputFromOutput, mTooltipCache.getData(DIGITALTANK_INPUTFROMOUTPUT_TOOLTIP))); - } - - private GT_Container_DigitalTank getContainer() { - return (GT_Container_DigitalTank) mContainer; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString(mName, 8, 6, textColorTitle); - if (mContainer != null) { - fontRendererObj.drawString("Liquid Amount", 10, 20, textColor); - fontRendererObj.drawString( - GT_Utility.parseNumberToString(((GT_Container_DigitalTank) 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); - if (mContainer != null) { - if (((GT_Container_DigitalTank) mContainer).mLockFluid) { - drawTexturedModalRect(x + 25, y + 63, 176, 0, 18, 18); - } - if (((GT_Container_DigitalTank) mContainer).outputFluid) { - drawTexturedModalRect(x + 7, y + 63, 176, 18, 18, 18); - } - if (((GT_Container_DigitalTank) mContainer).mVoidFluidPart) { - drawTexturedModalRect(x + 151, y + 7, 176, 36, 18, 18); - } - if (((GT_Container_DigitalTank) mContainer).mVoidFluidFull) { - drawTexturedModalRect(x + 151, y + 25, 176, 54, 18, 18); - } - if (((GT_Container_DigitalTank) mContainer).mAllowInputFromOutputSide) { - drawTexturedModalRect(x + 43, y + 63, 176, 72, 18, 18); - } - } - } - - @Override - public boolean handleDragAndDropGT( - GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button, boolean isGhost) { - if (!(gui instanceof GT_GUIContainer_DigitalTank) - || !((GT_GUIContainer_DigitalTank) gui).isMouseOverSlot(2, mousex, mousey) - || !isGhost) return false; - FluidStack fluidStack = GT_Utility.getFluidFromContainerOrFluidDisplay(draggedStack); - if (fluidStack == null) return false; - IGregTechTileEntity te = ((GT_GUIContainer_DigitalTank) gui).mContainer.mTileEntity; - GT_MetaTileEntity_DigitalTankBase mte = (GT_MetaTileEntity_DigitalTankBase) te.getMetaTileEntity(); - if (mte == null || !mte.allowChangingLockedFluid(fluidStack.getFluid().getName())) return false; - - GT_Values.NW.sendToServer(new GT_Packet_SetLockedFluid(te, fluidStack)); - draggedStack.stackSize = 0; - // propagate to client too - mte.setLockedFluidName(fluidStack.getFluid().getName()); - return true; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java deleted file mode 100644 index 07ca031345..0000000000 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MaintenanceHatch.java +++ /dev/null @@ -1,29 +0,0 @@ -package gregtech.api.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_MaintenanceHatch extends GT_GUIContainerMetaTile_Machine { - private final int textColor = this.getTextColorOrDefault("text", 0x404040), - textColorTitle = this.getTextColorOrDefault("title", 0x404040); - - public GT_GUIContainer_MaintenanceHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_MaintenanceHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Maintenance.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - fontRendererObj.drawString("Maintenance Hatch", 8, 4, textColorTitle); - fontRendererObj.drawString("Click with Tool to repair.", 8, 12, textColor); - } - - @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/api/gui/GT_GUIContainer_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java index 1f9170f3fb..7fb5026cd3 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java @@ -15,9 +15,8 @@ import net.minecraft.item.ItemStack; * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> * The GUI-Container I use for all my Basic Machines - * <p/> - * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class */ +@Deprecated public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machine { String mName; diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_SpecialFilter.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_SpecialFilter.java deleted file mode 100644 index 8f43dffffa..0000000000 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_SpecialFilter.java +++ /dev/null @@ -1,18 +0,0 @@ -package gregtech.api.gui; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_SpecialFilter extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_SpecialFilter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_SpecialFilter(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/SpecialFilter.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/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java index 635a27d6ef..cef3ddb3bf 100644 --- a/src/main/java/gregtech/api/gui/GT_GUICover.java +++ b/src/main/java/gregtech/api/gui/GT_GUICover.java @@ -5,6 +5,7 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.net.GT_Packet_GtTileEntityGuiRequest; import net.minecraft.item.ItemStack; +@Deprecated public abstract class GT_GUICover extends GT_GUIScreen { public final ICoverable tile; diff --git a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java index c077b02bf7..b0c381f104 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java +++ b/src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java @@ -12,6 +12,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; +@Deprecated public class GT_GUIDialogSelectItem extends GT_GUIScreen { public static final int UNSELECTED = -1; private static final int cols = 9; diff --git a/src/main/java/gregtech/api/gui/GT_GUIScreen.java b/src/main/java/gregtech/api/gui/GT_GUIScreen.java index d39a6b738e..470c1045a4 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIScreen.java +++ b/src/main/java/gregtech/api/gui/GT_GUIScreen.java @@ -20,6 +20,7 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +@Deprecated public abstract class GT_GUIScreen extends GuiScreen implements GT_IToolTipRenderer, IGuiScreen { protected GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager(); diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java b/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java deleted file mode 100644 index 205a6d74dc..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Slot_Holo_ME.java +++ /dev/null @@ -1,10 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.inventory.IInventory; - -public class GT_Slot_Holo_ME extends GT_Slot_Holo { - public GT_Slot_Holo_ME( - IInventory inventory, int slotIndex, int xPos, int yPos, boolean aCanInsertItem, boolean aCanStackItem) { - super(inventory, slotIndex, xPos, yPos, aCanInsertItem, aCanStackItem, Integer.MAX_VALUE); - } -} diff --git a/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java new file mode 100644 index 0000000000..811ad8be5f --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java @@ -0,0 +1,70 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import gregtech.api.interfaces.tileentity.ICoverable; +import net.minecraft.entity.player.EntityPlayer; + +public class GT_CoverUIBuildContext extends UIBuildContext { + + // cover data is not synced to client, while ID is + private final int coverID; + private final byte side; + private final ICoverable tile; + private final boolean anotherWindow; + private final int guiColorization; + + /** + * @param player Player opened this UI + * @param coverID See {@link ICoverable#getCoverIDAtSide} + * @param side Side this cover is attached to + * @param tile Tile this cover is attached to + * @param anotherWindow If cover UI is shown on top of another window + * @param guiColorization The color used to render machine's GUI + */ + public GT_CoverUIBuildContext( + EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow, int guiColorization) { + super(player); + this.coverID = coverID; + this.side = side; + this.tile = tile; + this.anotherWindow = anotherWindow; + this.guiColorization = guiColorization; + } + + /** + * @param player Player opened this UI + * @param coverID See {@link ICoverable#getCoverIDAtSide} + * @param side Side this cover is attached to + * @param tile Tile this cover is attached to + * @param anotherWindow If cover GUI is shown in opened on top of another window + */ + public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow) { + this(player, coverID, side, tile, anotherWindow, tile.getGUIColorization()); + } + + public int getCoverID() { + return coverID; + } + + public byte getCoverSide() { + return side; + } + + /** + * Note that this will return different object between client v.s. server side on SP. + */ + public ICoverable getTile() { + return tile; + } + + /** + * If cover GUI is shown in opened on top of another window. + */ + public boolean isAnotherWindow() { + return anotherWindow; + } + + public int getGuiColorization() { + return guiColorization; + } +} diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java new file mode 100644 index 0000000000..2d776ce71e --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java @@ -0,0 +1,204 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.builder.UIBuilder; +import com.gtnewhorizons.modularui.common.builder.UIInfo; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.net.GT_Packet_SendCoverData; +import gregtech.api.util.GT_CoverBehaviorBase; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_UIInfos { + + /** + * Generator for {@link UIInfo} which is responsible for registering and opening UIs. + * Unlike {@link com.gtnewhorizons.modularui.api.UIInfos#TILE_MODULAR_UI}, this accepts + * custom constructors for UI. + * <br> Do NOT run {@link UIBuilder#build} on-the-fly, otherwise MP client won't register UIs. + * Instead, store to static field, just like {@link #GTTileEntityDefaultUI}. + * Such mistake can be easily overlooked by testing only SP. + */ + public static final Function<ContainerConstructor, UIInfo<?, ?>> GTTileEntityUIFactory = + containerConstructor -> UIBuilder.of() + .container((player, world, x, y, z) -> { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + return createTileEntityContainer( + player, + ((ITileWithModularUI) te)::createWindow, + te::markDirty, + containerConstructor); + } + return null; + }) + .gui(((player, world, x, y, z) -> { + if (!world.isRemote) return null; + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + return createTileEntityGuiContainer( + player, ((ITileWithModularUI) te)::createWindow, containerConstructor); + } + return null; + })) + .build(); + + private static final UIInfo<?, ?> GTTileEntityDefaultUI = GTTileEntityUIFactory.apply(ModularUIContainer::new); + + private static final Map<Byte, UIInfo<?, ?>> coverUI = new HashMap<>(); + + static { + for (byte i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { + final byte side = i; + coverUI.put( + side, + UIBuilder.of() + .container((player, world, x, y, z) -> { + TileEntity te = world.getTileEntity(x, y, z); + if (!(te instanceof ICoverable)) return null; + ICoverable gtTileEntity = (ICoverable) te; + GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); + return createCoverContainer( + player, + cover::createWindow, + te::markDirty, + gtTileEntity.getCoverIDAtSide(side), + side, + gtTileEntity); + }) + .gui((player, world, x, y, z) -> { + if (!world.isRemote) return null; + TileEntity te = world.getTileEntity(x, y, z); + if (!(te instanceof ICoverable)) return null; + ICoverable gtTileEntity = (ICoverable) te; + GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side); + return createCoverGuiContainer( + player, + cover::createWindow, + gtTileEntity.getCoverIDAtSide(side), + side, + gtTileEntity); + }) + .build()); + } + } + + /** + * Opens TileEntity UI, created by {@link ITileWithModularUI#createWindow}. + */ + public static void openGTTileEntityUI(IHasWorldObjectAndCoords aTileEntity, EntityPlayer aPlayer) { + if (aTileEntity.isClientSide()) return; + GTTileEntityDefaultUI.open( + aPlayer, + aTileEntity.getWorld(), + aTileEntity.getXCoord(), + aTileEntity.getYCoord(), + aTileEntity.getZCoord()); + } + + /** + * Opens cover UI, created by {@link GT_CoverBehaviorBase#createWindow}. + */ + public static void openCoverUI(ICoverable tileEntity, EntityPlayer player, byte side) { + if (tileEntity.isClientSide()) return; + + GT_Values.NW.sendToPlayer( + new GT_Packet_SendCoverData( + side, + tileEntity.getCoverIDAtSide(side), + tileEntity.getComplexCoverDataAtSide(side), + tileEntity), + (EntityPlayerMP) player); + + coverUI.get(side) + .open( + player, + tileEntity.getWorld(), + tileEntity.getXCoord(), + tileEntity.getYCoord(), + tileEntity.getZCoord()); + } + + /** + * Opens UI for player's item, created by {@link com.gtnewhorizons.modularui.api.screen.IItemWithModularUI#createWindow}. + */ + public static void openPlayerHeldItemUI(EntityPlayer player) { + if (NetworkUtils.isClient()) return; + UIInfos.PLAYER_HELD_ITEM_UI.open(player); + } + + private static ModularUIContainer createTileEntityContainer( + EntityPlayer player, + Function<UIBuildContext, ModularWindow> windowCreator, + Runnable onWidgetUpdate, + ContainerConstructor containerCreator) { + UIBuildContext buildContext = new UIBuildContext(player); + ModularWindow window = windowCreator.apply(buildContext); + if (window == null) { + return null; + } + return containerCreator.of(new ModularUIContext(buildContext, onWidgetUpdate), window); + } + + @SideOnly(Side.CLIENT) + private static ModularGui createTileEntityGuiContainer( + EntityPlayer player, + Function<UIBuildContext, ModularWindow> windowCreator, + ContainerConstructor containerConstructor) { + ModularUIContainer container = createTileEntityContainer(player, windowCreator, null, containerConstructor); + if (container == null) { + return null; + } + return new ModularGui(container); + } + + private static ModularUIContainer createCoverContainer( + EntityPlayer player, + Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, + Runnable onWidgetUpdate, + int coverID, + byte side, + ICoverable tile) { + GT_CoverUIBuildContext buildContext = new GT_CoverUIBuildContext(player, coverID, side, tile, false); + ModularWindow window = windowCreator.apply(buildContext); + if (window == null) { + return null; + } + return new ModularUIContainer(new ModularUIContext(buildContext, onWidgetUpdate), window); + } + + @SideOnly(Side.CLIENT) + private static ModularGui createCoverGuiContainer( + EntityPlayer player, + Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, + int coverID, + byte side, + ICoverable tile) { + ModularUIContainer container = createCoverContainer(player, windowCreator, null, coverID, side, tile); + if (container == null) { + return null; + } + return new ModularGui(container); + } + + @FunctionalInterface + public interface ContainerConstructor { + ModularUIContainer of(ModularUIContext context, ModularWindow mainWindow); + } +} diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java new file mode 100644 index 0000000000..76b4874838 --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java @@ -0,0 +1,347 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import java.util.function.BiFunction; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public class GT_UITextures { + + private static final String MODID = "gregtech"; + + public static final UITexture TRANSPARENT = UITexture.fullImage(MODID, "gui/picture/transparent"); + + public static final AdaptableUITexture BACKGROUND_SINGLEBLOCK_DEFAULT = + AdaptableUITexture.of(MODID, "gui/background/singleblock_default", 176, 166, 4); + public static final SteamTexture BACKGROUND_STEAM = + SteamTexture.adaptableTexture(MODID, "gui/background/%s", 176, 166, 4); + public static final UITexture BACKGROUND_FUSION_COMPUTER = + UITexture.fullImage(MODID, "gui/background/fusion_computer"); + public static final AdaptableUITexture BACKGROUND_TEXT_FIELD = + AdaptableUITexture.of(MODID, "gui/background/text_field", 142, 28, 1); + public static final AdaptableUITexture BACKGROUND_TEXT_FIELD_LIGHT_GRAY = + AdaptableUITexture.of(MODID, "gui/background/text_field_light_gray", 61, 12, 1); + + public static final SteamTexture SLOT_ITEM_STEAM = SteamTexture.fullImage(MODID, "gui/slot/item_%s"); + public static final AdaptableUITexture SLOT_DARK_GRAY = + AdaptableUITexture.of(MODID, "gui/slot/dark_gray", 18, 18, 1); + public static final AdaptableUITexture SLOT_MAINTENANCE = + AdaptableUITexture.of(MODID, "gui/slot/maintenance", 20, 20, 1); + public static final AdaptableUITexture SLOT_UPLIFTED = AdaptableUITexture.of(MODID, "gui/slot/uplifted", 18, 18, 1); + + public static final UITexture OVERLAY_SLOT_ARROW_ME = UITexture.fullImage(MODID, "gui/overlay_slot/arrow_me"); + public static final UITexture OVERLAY_SLOT_BEAKER_1 = UITexture.fullImage(MODID, "gui/overlay_slot/beaker_1"); + public static final UITexture OVERLAY_SLOT_BEAKER_2 = UITexture.fullImage(MODID, "gui/overlay_slot/beaker_2"); + public static final UITexture OVERLAY_SLOT_BEE_DRONE = UITexture.fullImage(MODID, "gui/overlay_slot/bee_drone"); + public static final UITexture OVERLAY_SLOT_BEE_QUEEN = UITexture.fullImage(MODID, "gui/overlay_slot/bee_queen"); + public static final UITexture OVERLAY_SLOT_BENDER = UITexture.fullImage(MODID, "gui/overlay_slot/bender"); + public static final UITexture OVERLAY_SLOT_BOX = UITexture.fullImage(MODID, "gui/overlay_slot/box"); + public static final UITexture OVERLAY_SLOT_BOXED = UITexture.fullImage(MODID, "gui/overlay_slot/boxed"); + public static final UITexture OVERLAY_SLOT_CANISTER = UITexture.fullImage(MODID, "gui/overlay_slot/canister"); + public static final SteamTexture OVERLAY_SLOT_CANISTER_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/canister_%s"); + public static final UITexture OVERLAY_SLOT_CANNER = UITexture.fullImage(MODID, "gui/overlay_slot/canner"); + public static final UITexture OVERLAY_SLOT_CAULDRON = UITexture.fullImage(MODID, "gui/overlay_slot/cauldron"); + public static final UITexture OVERLAY_SLOT_CENTRIFUGE = UITexture.fullImage(MODID, "gui/overlay_slot/centrifuge"); + public static final UITexture OVERLAY_SLOT_CENTRIFUGE_FLUID = + UITexture.fullImage(MODID, "gui/overlay_slot/centrifuge_fluid"); + public static final SteamTexture OVERLAY_SLOT_CENTRIFUGE_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/centrifuge_%s"); + public static final UITexture OVERLAY_SLOT_CHARGER = UITexture.fullImage(MODID, "gui/overlay_slot/charger"); + public static final UITexture OVERLAY_SLOT_CHARGER_FLUID = + UITexture.fullImage(MODID, "gui/overlay_slot/charger_fluid"); + public static final UITexture OVERLAY_SLOT_CIRCUIT = UITexture.fullImage(MODID, "gui/overlay_slot/circuit"); + public static final SteamTexture OVERLAY_SLOT_COAL_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/coal_%s"); + public static final UITexture OVERLAY_SLOT_COMPRESSOR = UITexture.fullImage(MODID, "gui/overlay_slot/compressor"); + public static final SteamTexture OVERLAY_SLOT_COMPRESSOR_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/compressor_%s"); + public static final UITexture OVERLAY_SLOT_CRUSHED_ORE = UITexture.fullImage(MODID, "gui/overlay_slot/crushed_ore"); + public static final SteamTexture OVERLAY_SLOT_CRUSHED_ORE_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/crushed_ore_%s"); + public static final UITexture OVERLAY_SLOT_CUTTER_SLICED = + UITexture.fullImage(MODID, "gui/overlay_slot/cutter_sliced"); + public static final UITexture OVERLAY_SLOT_DATA_ORB = UITexture.fullImage(MODID, "gui/overlay_slot/data_orb"); + public static final UITexture OVERLAY_SLOT_DATA_STICK = UITexture.fullImage(MODID, "gui/overlay_slot/data_stick"); + public static final UITexture OVERLAY_SLOT_DUST = UITexture.fullImage(MODID, "gui/overlay_slot/dust"); + public static final SteamTexture OVERLAY_SLOT_DUST_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/dust_%s"); + public static final UITexture OVERLAY_SLOT_EXPLOSIVE = UITexture.fullImage(MODID, "gui/overlay_slot/explosive"); + public static final UITexture OVERLAY_SLOT_EXTRUDER_SHAPE = + UITexture.fullImage(MODID, "gui/overlay_slot/extruder_shape"); + public static final UITexture OVERLAY_SLOT_FURNACE = UITexture.fullImage(MODID, "gui/overlay_slot/furnace"); + public static final SteamTexture OVERLAY_SLOT_FURNACE_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/furnace_%s"); + public static final UITexture OVERLAY_SLOT_GEM = UITexture.fullImage(MODID, "gui/overlay_slot/gem"); + public static final UITexture OVERLAY_SLOT_HAMMER = UITexture.fullImage(MODID, "gui/overlay_slot/hammer"); + public static final SteamTexture OVERLAY_SLOT_HAMMER_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/hammer_%s"); + public static final UITexture OVERLAY_SLOT_HEATER_1 = UITexture.fullImage(MODID, "gui/overlay_slot/heater_1"); + public static final UITexture OVERLAY_SLOT_HEATER_2 = UITexture.fullImage(MODID, "gui/overlay_slot/heater_2"); + public static final UITexture OVERLAY_SLOT_IMPLOSION = UITexture.fullImage(MODID, "gui/overlay_slot/implosion"); + public static final UITexture OVERLAY_SLOT_IN = UITexture.fullImage(MODID, "gui/overlay_slot/in"); + public static final SteamTexture OVERLAY_SLOT_IN_STEAM = SteamTexture.fullImage(MODID, "gui/overlay_slot/in_%s"); + public static final SteamTexture OVERLAY_SLOT_INGOT_STEAM = + SteamTexture.fullImage(MODID, "gui/overlay_slot/ingot_%s"); + public static final UITexture OVERLAY_SLOT_INT_CIRCUIT = UITexture.fullImage(MODID, "gui/overlay_slot/int_circuit"); + public static final UITexture OVERLAY_SLOT_LENS = UITexture.fullImage(MODID, "gui/overlay_slot/lens"); + public static final UITexture OVERLAY_SLOT_MICROSCOPE = UITexture.fullImage(MODID, "gui/overlay_slot/microscope"); + public static final UITexture OVERLAY_SLOT_MOLD = UITexture.fullImage(MODID, "gui/overlay_slot/mold"); + public static final UITexture OVERLAY_SLOT_MOLECULAR_1 = UITexture.fullImage(MODID, "gui/overlay_slot/molecular_1"); + public static final UITexture OVERLAY_SLOT_MOLECULAR_2 = UITexture.fullImage(MODID, "gui/overlay_slot/molecular_2"); + public static final UITexture OVERLAY_SLOT_MOLECULAR_3 = UITexture.fullImage(MODID, "gui/overlay_slot/molecular_3"); + public static final UITexture OVERLAY_SLOT_OUT = UITexture.fullImage(MODID, "gui/overlay_slot/out"); + public static final SteamTexture OVERLAY_SLOT_OUT_STEAM = SteamTexture.fullImage(MODID, "gui/overlay_slot/out_%s"); + public static final UITexture OVERLAY_SLOT_PAGE_BLANK = UITexture.fullImage(MODID, "gui/overlay_slot/page_blank"); + public static final UITexture OVERLAY_SLOT_PAGE_PRINTED = + UITexture.fullImage(MODID, "gui/overlay_slot/page_printed"); + public static final UITexture OVERLAY_SLOT_PRESS_1 = UITexture.fullImage(MODID, "gui/overlay_slot/press_1"); + public static final UITexture OVERLAY_SLOT_PRESS_2 = UITexture.fullImage(MODID, "gui/overlay_slot/press_2"); + public static final UITexture OVERLAY_SLOT_PRESS_3 = UITexture.fullImage(MODID, "gui/overlay_slot/press_3"); + public static final UITexture OVERLAY_SLOT_RECYCLE = UITexture.fullImage(MODID, "gui/overlay_slot/recycle"); + public static final UITexture OVERLAY_SLOT_ROD_1 = UITexture.fullImage(MODID, "gui/overlay_slot/rod_1"); + public static final UITexture OVERLAY_SLOT_ROD_2 = UITexture.fullImage(MODID, "gui/overlay_slot/rod_2"); + public static final UITexture OVERLAY_SLOT_SLICE_SHAPE = UITexture.fullImage(MODID, "gui/overlay_slot/slice_shape"); + public static final UITexture OVERLAY_SLOT_SLICER_SLICED = + UITexture.fullImage(MODID, "gui/overlay_slot/slicer_sliced"); + public static final UITexture OVERLAY_SLOT_SQUARE = UITexture.fullImage(MODID, "gui/overlay_slot/square"); + public static final UITexture OVERLAY_SLOT_UUA = UITexture.fullImage(MODID, "gui/overlay_slot/uua"); + public static final UITexture OVERLAY_SLOT_UUM = UITexture.fullImage(MODID, "gui/overlay_slot/uum"); + public static final UITexture OVERLAY_SLOT_VIAL_1 = UITexture.fullImage(MODID, "gui/overlay_slot/vial_1"); + public static final UITexture OVERLAY_SLOT_VIAL_2 = UITexture.fullImage(MODID, "gui/overlay_slot/vial_2"); + public static final UITexture OVERLAY_SLOT_WIREMILL = UITexture.fullImage(MODID, "gui/overlay_slot/wiremill"); + public static final UITexture OVERLAY_SLOT_WRENCH = UITexture.fullImage(MODID, "gui/overlay_slot/wrench"); + public static final UITexture[] OVERLAY_SLOTS_NUMBER = IntStream.range(0, 12) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/overlay_slot/number_" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + + public static final UITexture PROGRESSBAR_ARROW = UITexture.fullImage(MODID, "gui/progressbar/arrow"); + public static final SteamTexture PROGRESSBAR_ARROW_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/arrow_%s"); + public static final SteamTexture PROGRESSBAR_ARROW_2_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/arrow_2_%s"); + public static final UITexture PROGRESSBAR_ARROW_MULTIPLE = + UITexture.fullImage(MODID, "gui/progressbar/arrow_multiple"); + public static final UITexture PROGRESSBAR_ASSEMBLE = UITexture.fullImage(MODID, "gui/progressbar/assemble"); + public static final UITexture PROGRESSBAR_ASSEMBLY_LINE_1 = + UITexture.fullImage(MODID, "gui/progressbar/assemblyline_1"); + public static final UITexture PROGRESSBAR_ASSEMBLY_LINE_2 = + UITexture.fullImage(MODID, "gui/progressbar/assemblyline_2"); + public static final UITexture PROGRESSBAR_ASSEMBLY_LINE_3 = + UITexture.fullImage(MODID, "gui/progressbar/assemblyline_3"); + public static final UITexture PROGRESSBAR_BATH = UITexture.fullImage(MODID, "gui/progressbar/bath"); + public static final UITexture PROGRESSBAR_BENDING = UITexture.fullImage(MODID, "gui/progressbar/bending"); + public static final SteamTexture PROGRESSBAR_BOILER_EMPTY_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/boiler_empty_%s"); + public static final UITexture PROGRESSBAR_BOILER_HEAT = UITexture.fullImage(MODID, "gui/progressbar/boiler_heat"); + public static final UITexture PROGRESSBAR_BOILER_STEAM = UITexture.fullImage(MODID, "gui/progressbar/boiler_steam"); + public static final UITexture PROGRESSBAR_BOILER_WATER = UITexture.fullImage(MODID, "gui/progressbar/boiler_water"); + public static final UITexture PROGRESSBAR_CANNER = UITexture.fullImage(MODID, "gui/progressbar/canner"); + public static final UITexture PROGRESSBAR_CIRCUIT_ASSEMBLER = + UITexture.fullImage(MODID, "gui/progressbar/circuit_assembler"); + public static final UITexture PROGRESSBAR_COMPRESS = UITexture.fullImage(MODID, "gui/progressbar/compress"); + public static final SteamTexture PROGRESSBAR_COMPRESS_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/compress_%s"); + public static final UITexture PROGRESSBAR_CUT = UITexture.fullImage(MODID, "gui/progressbar/cut"); + public static final UITexture PROGRESSBAR_EXTRACT = UITexture.fullImage(MODID, "gui/progressbar/extract"); + public static final SteamTexture PROGRESSBAR_EXTRACT_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/extract_%s"); + public static final UITexture PROGRESSBAR_EXTRUDE = UITexture.fullImage(MODID, "gui/progressbar/extrude"); + public static final SteamTexture PROGRESSBAR_FUEL_STEAM = SteamTexture.fullImage(MODID, "gui/progressbar/fuel_%s"); + public static final UITexture PROGRESSBAR_HAMMER = UITexture.fullImage(MODID, "gui/progressbar/hammer"); + public static final UITexture PROGRESSBAR_HAMMER_BASE = UITexture.fullImage(MODID, "gui/progressbar/hammer_base"); + public static final SteamTexture PROGRESSBAR_HAMMER_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/hammer_%s"); + public static final SteamTexture PROGRESSBAR_HAMMER_BASE_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/hammer_base_%s"); + public static final UITexture PROGRESSBAR_LATHE = UITexture.fullImage(MODID, "gui/progressbar/lathe"); + public static final UITexture PROGRESSBAR_LATHE_BASE = UITexture.fullImage(MODID, "gui/progressbar/lathe_base"); + public static final UITexture PROGRESSBAR_MACERATE = UITexture.fullImage(MODID, "gui/progressbar/macerate"); + public static final SteamTexture PROGRESSBAR_MACERATE_STEAM = + SteamTexture.fullImage(MODID, "gui/progressbar/macerate_%s"); + public static final UITexture PROGRESSBAR_MAGNET = UITexture.fullImage(MODID, "gui/progressbar/magnet"); + public static final UITexture PROGRESSBAR_MIXER = UITexture.fullImage(MODID, "gui/progressbar/mixer"); + public static final UITexture PROGRESSBAR_RECYCLE = UITexture.fullImage(MODID, "gui/progressbar/recycle"); + public static final UITexture PROGRESSBAR_SIFT = UITexture.fullImage(MODID, "gui/progressbar/sift"); + public static final UITexture PROGRESSBAR_SLICE = UITexture.fullImage(MODID, "gui/progressbar/slice"); + public static final UITexture PROGRESSBAR_STORED_EU = UITexture.fullImage(MODID, "gui/progressbar/stored_eu"); + public static final UITexture PROGRESSBAR_WIREMILL = UITexture.fullImage(MODID, "gui/progressbar/wiremill"); + + public static final UITexture TAB_COVER_NORMAL = UITexture.fullImage(MODID, "gui/tab/cover_normal"); + public static final UITexture TAB_COVER_HIGHLIGHT = UITexture.fullImage(MODID, "gui/tab/cover_highlight"); + public static final UITexture TAB_COVER_DISABLED = UITexture.fullImage(MODID, "gui/tab/cover_disabled"); + public static final SteamTexture TAB_COVER_STEAM_NORMAL = SteamTexture.fullImage(MODID, "gui/tab/cover_%s_normal"); + public static final SteamTexture TAB_COVER_STEAM_HIGHLIGHT = + SteamTexture.fullImage(MODID, "gui/tab/cover_%s_highlight"); + public static final SteamTexture TAB_COVER_STEAM_DISABLED = + SteamTexture.fullImage(MODID, "gui/tab/cover_%s_disabled"); + public static final AdaptableUITexture TAB_TITLE = AdaptableUITexture.of(MODID, "gui/tab/title", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_DARK = + AdaptableUITexture.of(MODID, "gui/tab/title_dark", 28, 28, 4); + public static final SteamTexture TAB_TITLE_STEAM = + SteamTexture.adaptableTexture(MODID, "gui/tab/title_%s", 28, 28, 4); + public static final SteamTexture TAB_TITLE_DARK_STEAM = + SteamTexture.adaptableTexture(MODID, "gui/tab/title_dark_%s", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_ANGULAR = + AdaptableUITexture.of(MODID, "gui/tab/title_angular", 28, 28, 4); + public static final SteamTexture TAB_TITLE_ANGULAR_STEAM = + SteamTexture.adaptableTexture(MODID, "gui/tab/title_angular_%s", 28, 28, 4); + + public static final UITexture BUTTON_STANDARD = UITexture.fullImage(MODID, "gui/button/standard"); + public static final UITexture BUTTON_STANDARD_TOGGLE = UITexture.fullImage(MODID, "gui/button/standard_toggle"); + public static final UITexture BUTTON_COVER_NORMAL = UITexture.fullImage(MODID, "gui/button/cover_normal"); + public static final UITexture BUTTON_COVER_NORMAL_HOVERED = + UITexture.fullImage(MODID, "gui/button/cover_normal_hovered"); + public static final UITexture BUTTON_COVER_NORMAL_DISABLED = + UITexture.fullImage(MODID, "gui/button/cover_normal_disabled"); + + public static final UITexture OVERLAY_BUTTON_DISABLE = UITexture.fullImage(MODID, "gui/overlay_button/disable"); + public static final UITexture OVERLAY_BUTTON_REDSTONE_OFF = + UITexture.fullImage(MODID, "gui/overlay_button/redstone_off"); + public static final UITexture OVERLAY_BUTTON_REDSTONE_ON = + UITexture.fullImage(MODID, "gui/overlay_button/redstone_on"); + public static final UITexture OVERLAY_BUTTON_CHECKMARK = UITexture.fullImage(MODID, "gui/overlay_button/checkmark"); + public static final UITexture OVERLAY_BUTTON_CROSS = UITexture.fullImage(MODID, "gui/overlay_button/cross"); + public static final UITexture OVERLAY_BUTTON_WHITELIST = UITexture.fullImage(MODID, "gui/overlay_button/whitelist"); + public static final UITexture OVERLAY_BUTTON_BLACKLIST = UITexture.fullImage(MODID, "gui/overlay_button/blacklist"); + public static final UITexture OVERLAY_BUTTON_PROGRESS = UITexture.fullImage(MODID, "gui/overlay_button/progress"); + public static final UITexture OVERLAY_BUTTON_EXPORT = UITexture.fullImage(MODID, "gui/overlay_button/export"); + public static final UITexture OVERLAY_BUTTON_IMPORT = UITexture.fullImage(MODID, "gui/overlay_button/import"); + public static final UITexture OVERLAY_BUTTON_AUTOOUTPUT_ITEM = + UITexture.fullImage(MODID, "gui/overlay_button/autooutput_item"); + public static final UITexture OVERLAY_BUTTON_AUTOOUTPUT_FLUID = + UITexture.fullImage(MODID, "gui/overlay_button/autooutput_fluid"); + public static final UITexture OVERLAY_BUTTON_ALLOW_INPUT = + UITexture.fullImage(MODID, "gui/overlay_button/allow_input"); + public static final UITexture OVERLAY_BUTTON_BLOCK_INPUT = + UITexture.fullImage(MODID, "gui/overlay_button/block_input"); + public static final UITexture OVERLAY_BUTTON_ARROW_GREEN_UP = + UITexture.fullImage(MODID, "gui/overlay_button/arrow_green_up"); + public static final UITexture OVERLAY_BUTTON_ARROW_GREEN_DOWN = + UITexture.fullImage(MODID, "gui/overlay_button/arrow_green_down"); + public static final UITexture OVERLAY_BUTTON_CYCLIC = UITexture.fullImage(MODID, "gui/overlay_button/cyclic"); + public static final UITexture OVERLAY_BUTTON_EMIT_ENERGY = + UITexture.fullImage(MODID, "gui/overlay_button/emit_energy"); + public static final UITexture OVERLAY_BUTTON_EMIT_REDSTONE = + UITexture.fullImage(MODID, "gui/overlay_button/emit_redstone"); + public static final UITexture OVERLAY_BUTTON_INVERT_REDSTONE = + UITexture.fullImage(MODID, "gui/overlay_button/invert_redstone"); + public static final UITexture OVERLAY_BUTTON_STOCKING_MODE = + UITexture.fullImage(MODID, "gui/overlay_button/stocking_mode"); + public static final UITexture OVERLAY_BUTTON_INVERT_FILTER = + UITexture.fullImage(MODID, "gui/overlay_button/invert_filter"); + public static final UITexture OVERLAY_BUTTON_NBT = UITexture.fullImage(MODID, "gui/overlay_button/nbt"); + public static final UITexture OVERLAY_BUTTON_PRINT = UITexture.fullImage(MODID, "gui/overlay_button/print"); + public static final UITexture OVERLAY_BUTTON_TRANSPOSE = UITexture.fullImage(MODID, "gui/overlay_button/transpose"); + public static final UITexture OVERLAY_BUTTON_BOUNDING_BOX = + UITexture.fullImage(MODID, "gui/overlay_button/bounding_box"); + public static final UITexture OVERLAY_BUTTON_MINUS_SMALL = + UITexture.fullImage(MODID, "gui/overlay_button/minus_small"); + public static final UITexture OVERLAY_BUTTON_MINUS_LARGE = + UITexture.fullImage(MODID, "gui/overlay_button/minus_large"); + public static final UITexture OVERLAY_BUTTON_PLUS_SMALL = + UITexture.fullImage(MODID, "gui/overlay_button/plus_small"); + public static final UITexture OVERLAY_BUTTON_PLUS_LARGE = + UITexture.fullImage(MODID, "gui/overlay_button/plus_large"); + public static final UITexture OVERLAY_BUTTON_GATE_AND = UITexture.fullImage(MODID, "gui/overlay_button/gate_and"); + public static final UITexture OVERLAY_BUTTON_GATE_NAND = UITexture.fullImage(MODID, "gui/overlay_button/gate_nand"); + public static final UITexture OVERLAY_BUTTON_GATE_OR = UITexture.fullImage(MODID, "gui/overlay_button/gate_or"); + public static final UITexture OVERLAY_BUTTON_GATE_NOR = UITexture.fullImage(MODID, "gui/overlay_button/gate_nor"); + public static final UITexture OVERLAY_BUTTON_ANALOG = UITexture.fullImage(MODID, "gui/overlay_button/analog"); + public static final UITexture OVERLAY_BUTTON_LOCK = UITexture.fullImage(MODID, "gui/overlay_button/lock"); + public static final UITexture OVERLAY_BUTTON_INPUT_FROM_OUTPUT_SIDE = + UITexture.fullImage(MODID, "gui/overlay_button/input_from_output_side"); + public static final UITexture OVERLAY_BUTTON_VOID_EXCESS = + UITexture.fullImage(MODID, "gui/overlay_button/void_excess"); + public static final UITexture OVERLAY_BUTTON_VOID_ALL = UITexture.fullImage(MODID, "gui/overlay_button/void_all"); + public static final UITexture OVERLAY_BUTTON_NEI = UITexture.fullImage(MODID, "gui/overlay_button/nei"); + + /** + * Can adjust size as needed. + */ + public static final AdaptableUITexture PICTURE_SCREEN_BLACK = + AdaptableUITexture.of(MODID, "gui/picture/screen_black", 16, 16, 2); + + public static final UITexture PICTURE_GT_LOGO_17x17_TRANSPARENT = + UITexture.fullImage(MODID, "gui/picture/gt_logo_17x17_transparent"); + public static final UITexture PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY = + UITexture.fullImage(MODID, "gui/picture/gt_logo_17x17_transparent_gray"); + public static final SteamTexture PICTURE_GT_LOGO_17x17_TRANSPARENT_STEAM = + SteamTexture.fullImage(MODID, "gui/picture/gt_logo_17x17_transparent_%s"); + public static final UITexture PICTURE_GT_LOGO_18x18 = UITexture.fullImage(MODID, "gui/picture/gt_logo_18x18"); + public static final UITexture PICTURE_GT_LOGO_19x19 = UITexture.fullImage(MODID, "gui/picture/gt_logo_19x19"); + public static final UITexture PICTURE_INFORMATION = UITexture.fullImage(MODID, "gui/picture/information"); + public static final UITexture PICTURE_STALLED_ELECTRICITY = + UITexture.fullImage(MODID, "gui/picture/stalled_electricity"); + public static final UITexture PICTURE_STALLED_STEAM = UITexture.fullImage(MODID, "gui/picture/stalled_steam"); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_22_RED = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_22_red", + 87, + 22, + fromRight ? 87 - width : 0, + 0, + fromRight ? 87 : width, + 22); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_22_BLUE = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_22_blue", + 87, + 22, + fromRight ? 87 - width : 0, + 0, + fromRight ? 87 : width, + 22); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_22_WHITE = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_22_white", + 87, + 22, + fromRight ? 87 - width : 0, + 0, + fromRight ? 87 : width, + 22); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_24_RED = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_24_red", + 69, + 24, + fromRight ? 69 - width : 0, + 0, + fromRight ? 69 : width, + 24); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_24_BLUE = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_24_blue", + 69, + 24, + fromRight ? 69 - width : 0, + 0, + fromRight ? 69 : width, + 24); + public static final BiFunction<Integer, Boolean, UITexture> PICTURE_ARROW_24_WHITE = + (width, fromRight) -> UITexture.partly( + MODID, + "gui/picture/arrow_24_white", + 69, + 24, + fromRight ? 69 - width : 0, + 0, + fromRight ? 69 : width, + 24); + public static final UITexture PICTURE_FLUID_WINDOW = UITexture.fullImage(MODID, "gui/picture/fluid_window"); + public static final UITexture PICTURE_FLUID_TANK = UITexture.fullImage(MODID, "gui/picture/fluid_tank"); + public static final UITexture PICTURE_SLOTS_HOLO_3BY3 = UITexture.fullImage(MODID, "gui/picture/slots_holo_3by3"); + public static final UITexture PICTURE_ARROW_DOUBLE = UITexture.fullImage(MODID, "gui/picture/arrow_double"); + public static final UITexture PICTURE_SUPER_BUFFER = UITexture.fullImage(MODID, "gui/picture/super_buffer"); + public static final UITexture PICTURE_SQUARE_LIGHT_GRAY = + UITexture.fullImage(MODID, "gui/picture/square_light_gray"); + public static final UITexture PICTURE_GAUGE = UITexture.fullImage(MODID, "gui/picture/gauge"); +} diff --git a/src/main/java/gregtech/api/gui/modularui/GUITextureSet.java b/src/main/java/gregtech/api/gui/modularui/GUITextureSet.java new file mode 100644 index 0000000000..13d7eadfee --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/GUITextureSet.java @@ -0,0 +1,150 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import gregtech.api.enums.SteamVariant; +import java.util.function.Function; + +/** + * Set of textures that is commonly used for GUI but can vary depending on "style" of machines, + * e.g. bronze steam or steel steam. + * <br> This has builder pattern; Textures you didn't specify will fall back to default ones. + */ +public class GUITextureSet { + private UITexture mainBackground; + private UITexture itemSlot; + private UITexture fluidSlot; + private UITexture coverTabNormal; + private UITexture coverTabHighlight; + private UITexture coverTabDisabled; + private UITexture coverTabNormalFlipped; + private UITexture coverTabHighlightFlipped; + private UITexture coverTabDisabledFlipped; + private AdaptableUITexture titleTabNormal; + private AdaptableUITexture titleTabDark; + private AdaptableUITexture titleTabAngular; + private UITexture gregtechLogo; + + public static final GUITextureSet DEFAULT = new GUITextureSet() + .setMainBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT) + .setItemSlot(ModularUITextures.ITEM_SLOT) + .setFluidSlot(ModularUITextures.FLUID_SLOT) + .setCoverTab( + GT_UITextures.TAB_COVER_NORMAL, GT_UITextures.TAB_COVER_HIGHLIGHT, GT_UITextures.TAB_COVER_DISABLED) + .setTitleTab(GT_UITextures.TAB_TITLE, GT_UITextures.TAB_TITLE_DARK, GT_UITextures.TAB_TITLE_ANGULAR) + .setGregTechLogo(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT); + + public static final Function<SteamVariant, GUITextureSet> STEAM = steamVariant -> new GUITextureSet() + .setMainBackground(GT_UITextures.BACKGROUND_STEAM.get(steamVariant)) + .setItemSlot(GT_UITextures.SLOT_ITEM_STEAM.get(steamVariant)) + .setCoverTab( + GT_UITextures.TAB_COVER_STEAM_NORMAL.get(steamVariant), + GT_UITextures.TAB_COVER_STEAM_HIGHLIGHT.get(steamVariant), + GT_UITextures.TAB_COVER_STEAM_DISABLED.get(steamVariant)) + .setTitleTab( + GT_UITextures.TAB_TITLE_STEAM.getAdaptable(steamVariant), + GT_UITextures.TAB_TITLE_DARK_STEAM.getAdaptable(steamVariant), + GT_UITextures.TAB_TITLE_ANGULAR_STEAM.getAdaptable(steamVariant)) + .setGregTechLogo(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_STEAM.get(steamVariant)); + + public GUITextureSet() {} + + // region setters + + public GUITextureSet setMainBackground(UITexture mainBackground) { + this.mainBackground = mainBackground; + return this; + } + + public GUITextureSet setItemSlot(UITexture itemSlot) { + this.itemSlot = itemSlot; + return this; + } + + public GUITextureSet setFluidSlot(UITexture fluidSlot) { + this.fluidSlot = fluidSlot; + return this; + } + + public GUITextureSet setCoverTab(UITexture coverNormal, UITexture coverHighlight, UITexture coverDisabled) { + this.coverTabNormal = coverNormal; + this.coverTabHighlight = coverHighlight; + this.coverTabDisabled = coverDisabled; + this.coverTabNormalFlipped = coverNormal.getFlipped(true, false); + this.coverTabHighlightFlipped = coverHighlight.getFlipped(true, false); + this.coverTabDisabledFlipped = coverDisabled.getFlipped(true, false); + return this; + } + + public GUITextureSet setTitleTab( + AdaptableUITexture titleNormal, AdaptableUITexture titleDark, AdaptableUITexture titleTabAngular) { + this.titleTabNormal = titleNormal; + this.titleTabDark = titleDark; + this.titleTabAngular = titleTabAngular; + return this; + } + + public GUITextureSet setGregTechLogo(UITexture gregtechLogo) { + this.gregtechLogo = gregtechLogo; + return this; + } + + // endregion + + // region getters + + public UITexture getMainBackground() { + return mainBackground != null ? mainBackground : DEFAULT.mainBackground; + } + + public UITexture getItemSlot() { + return itemSlot != null ? itemSlot : DEFAULT.itemSlot; + } + + public UITexture getFluidSlot() { + return fluidSlot != null ? fluidSlot : DEFAULT.fluidSlot; + } + + public UITexture getCoverTabNormal() { + return coverTabNormal != null ? coverTabNormal : DEFAULT.coverTabNormal; + } + + public UITexture getCoverTabHighlight() { + return coverTabHighlight != null ? coverTabHighlight : DEFAULT.coverTabHighlight; + } + + public UITexture getCoverTabDisabled() { + return coverTabDisabled != null ? coverTabDisabled : DEFAULT.coverTabDisabled; + } + + public UITexture getCoverTabNormalFlipped() { + return coverTabNormalFlipped != null ? coverTabNormalFlipped : DEFAULT.coverTabNormalFlipped; + } + + public UITexture getCoverTabHighlightFlipped() { + return coverTabHighlightFlipped != null ? coverTabHighlightFlipped : DEFAULT.coverTabHighlightFlipped; + } + + public UITexture getCoverTabDisabledFlipped() { + return coverTabDisabledFlipped != null ? coverTabDisabledFlipped : DEFAULT.coverTabDisabledFlipped; + } + + public AdaptableUITexture getTitleTabNormal() { + return titleTabNormal != null ? titleTabNormal : DEFAULT.titleTabNormal; + } + + public AdaptableUITexture getTitleTabDark() { + return titleTabDark != null ? titleTabDark : DEFAULT.titleTabDark; + } + + public AdaptableUITexture getTitleTabAngular() { + return titleTabAngular != null ? titleTabAngular : DEFAULT.titleTabAngular; + } + + public UITexture getGregTechLogo() { + return gregtechLogo != null ? gregtechLogo : DEFAULT.gregtechLogo; + } + + // endregion +} diff --git a/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java b/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java new file mode 100644 index 0000000000..40ebcea0f4 --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/IDataFollowerWidget.java @@ -0,0 +1,48 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.widget.Widget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.ISerializableObject; +import gregtech.common.gui.modularui.widget.DataControllerWidget; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * Widget whose state is controlled by specific data. + * Data can be anything, e.g. {@link ISerializableObject} or machine recipe mode. + * <br> No widgets implementing this interface should not sync; + * Instead, {@link DataControllerWidget} will sync data, either when this widget triggers update on client + * or data update is detected on server. + * @param <T> Data type stored in the parent widget + * @param <U> State type stored in this widget + * @see DataControllerWidget + */ +@SuppressWarnings("UnusedReturnValue") +public interface IDataFollowerWidget<T, U> { + + /** + * Sets function to get widget state from provided data. This function will be called when client receives data + * from server and {@link DataControllerWidget} updates all children, including this widget. + */ + Widget setDataToStateGetter(Function<T, U> dataToStateGetter); + + /** + * Sets setter called when this widget gets action from player. + * Basically the same functionality with widgets that have getter/setter. + */ + Widget setStateSetter(Consumer<U> setter); + + /** + * Updates state of this widget with provided data. + * On server {@link DataControllerWidget} won't propagate data update to this widget, + * so this method is client-only. + */ + @SideOnly(Side.CLIENT) + void updateState(T data); + + /** + * Called on {@link Widget#onPostInit}. + */ + default void onPostInit() {} +} diff --git a/src/main/java/gregtech/api/gui/modularui/SteamTexture.java b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java new file mode 100644 index 0000000000..9e52c0f874 --- /dev/null +++ b/src/main/java/gregtech/api/gui/modularui/SteamTexture.java @@ -0,0 +1,74 @@ +package gregtech.api.gui.modularui; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import gregtech.api.enums.SteamVariant; + +/** + * Wrapper for {@link UITexture}s used to + * ease in choosing between Bronze, Steel and Primitive textures. + */ +public class SteamTexture { + + private final UITexture bronzeTexture; + private final UITexture steelTexture; + private final UITexture primitiveTexture; + + private SteamTexture(UITexture bronzeTexture, UITexture steelTexture, UITexture primitiveTexture) { + this.bronzeTexture = bronzeTexture; + this.steelTexture = steelTexture; + this.primitiveTexture = primitiveTexture; + } + + public static SteamTexture fullImage(String mod, String location) { + return new SteamTexture( + UITexture.fullImage(mod, String.format(location, SteamVariant.BRONZE)), + UITexture.fullImage(mod, String.format(location, SteamVariant.STEEL)), + UITexture.fullImage(mod, String.format(location, SteamVariant.PRIMITIVE))); + } + + public static SteamTexture adaptableTexture( + String mod, String location, int imageWidth, int imageHeight, int borderWidthPixel) { + return new SteamTexture( + AdaptableUITexture.of( + mod, String.format(location, SteamVariant.BRONZE), imageWidth, imageHeight, borderWidthPixel), + AdaptableUITexture.of( + mod, String.format(location, SteamVariant.STEEL), imageWidth, imageHeight, borderWidthPixel), + AdaptableUITexture.of( + mod, + String.format(location, SteamVariant.PRIMITIVE), + imageWidth, + imageHeight, + borderWidthPixel)); + } + + public UITexture get(SteamVariant variant) { + switch (variant) { + case BRONZE: + return bronzeTexture; + case STEEL: + return steelTexture; + case PRIMITIVE: + return primitiveTexture; + default: + return null; + } + } + + public AdaptableUITexture getAdaptable(SteamVariant variant) { + switch (variant) { + case BRONZE: + return (AdaptableUITexture) bronzeTexture; + case STEEL: + return (AdaptableUITexture) steelTexture; + case PRIMITIVE: + return (AdaptableUITexture) primitiveTexture; + default: + return null; + } + } + + public UITexture get(boolean isHighPressure) { + return isHighPressure ? steelTexture : bronzeTexture; + } +} diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConfigurationCircuitSupport.java b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java index 59a70b450d..b2d32b2fc4 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IConfigurationCircuitSupport.java +++ b/src/main/java/gregtech/api/interfaces/IConfigurationCircuitSupport.java @@ -1,11 +1,11 @@ -package gregtech.api.interfaces.metatileentity; +package gregtech.api.interfaces; import gregtech.api.GregTech_API; import java.util.List; import net.minecraft.item.ItemStack; /** - * Implement this interface if your metatileentity supports configuration circuits + * Implement this interface if your tileentity (or metatileentity) supports configuration circuits * to resolve recipe conflicts. */ public interface IConfigurationCircuitSupport { diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index 29b0a56a89..59d048e618 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -1,14 +1,18 @@ package gregtech.api.interfaces.metatileentity; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Dyes; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IGetGUITextureSet; import gregtech.api.interfaces.tileentity.IGearEnergyTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IGregtechWailaProvider; import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Util; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -38,7 +42,8 @@ public interface IMetaTileEntity IFluidHandler, IGearEnergyTileEntity, IMachineBlockUpdateable, - IGregtechWailaProvider { + IGregtechWailaProvider, + IGetGUITextureSet { /** * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. * <p/> @@ -193,13 +198,28 @@ public interface IMetaTileEntity /** * @return the Server Side Container + * @deprecated Use ModularUI */ - Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity); + @Deprecated + default Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + throw new UnsupportedOperationException(); + } /** * @return the Client Side GUI Container + * @deprecated Use ModularUI + */ + @Deprecated + default Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + throw new UnsupportedOperationException(); + } + + /** + * For back compatibility, you need to override this if this MetaTileEntity uses ModularUI. */ - Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity); + default boolean useModularUI() { + return false; + } /** * From new ISidedInventory @@ -406,6 +426,17 @@ public interface IMetaTileEntity void onColorChangeClient(byte aColor); + /** + * @return Actual color shown on GUI + */ + default int getGUIColorization() { + if (getBaseMetaTileEntity() != null) { + return getBaseMetaTileEntity().getGUIColorization(); + } else { + return GT_Util.getRGBInt(Dyes.MACHINE_METAL.getRGBA()); + } + } + int getLightOpacity(); boolean allowGeneralRedstoneOutput(); @@ -461,4 +492,31 @@ public interface IMetaTileEntity default void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { /* do nothing */ } + + default int getGUIWidth() { + return 176; + } + + default int getGUIHeight() { + return 166; + } + + /* + * ModularUI Support + */ + default ItemStackHandler getInventoryHandler() { + return null; + } + + default String getLocalName() { + return "Unknown"; + } + + default boolean doesBindPlayerInventory() { + return true; + } + + default int getTextColorOrDefault(String textType, int defaultColor) { + return defaultColor; + } } diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java b/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java new file mode 100644 index 0000000000..d90d310dc8 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IAddGregtechLogo.java @@ -0,0 +1,7 @@ +package gregtech.api.interfaces.modularui; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; + +public interface IAddGregtechLogo { + default void addGregTechLogo(ModularWindow.Builder builder) {} +} diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java b/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java new file mode 100644 index 0000000000..70e33aa2c8 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IAddInventorySlots.java @@ -0,0 +1,14 @@ +package gregtech.api.interfaces.modularui; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; + +public interface IAddInventorySlots { + default void add1by1Slot(ModularWindow.Builder builder, IDrawable... background) {} + + default void add2by2Slots(ModularWindow.Builder builder, IDrawable... background) {} + + default void add3by3Slots(ModularWindow.Builder builder, IDrawable... background) {} + + default void add4by4Slots(ModularWindow.Builder builder, IDrawable... background) {} +} diff --git a/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java b/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java new file mode 100644 index 0000000000..7b70fd724c --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IAddUIWidgets.java @@ -0,0 +1,8 @@ +package gregtech.api.interfaces.modularui; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +public interface IAddUIWidgets { + default void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {} +} diff --git a/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java b/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java new file mode 100644 index 0000000000..426a24ad38 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IBindPlayerInventoryUI.java @@ -0,0 +1,9 @@ +package gregtech.api.interfaces.modularui; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +public interface IBindPlayerInventoryUI { + + void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext); +} diff --git a/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java b/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java new file mode 100644 index 0000000000..409523b008 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IGetGUITextureSet.java @@ -0,0 +1,9 @@ +package gregtech.api.interfaces.modularui; + +import gregtech.api.gui.modularui.GUITextureSet; + +public interface IGetGUITextureSet { + default GUITextureSet getGUITextureSet() { + return null; + } +} diff --git a/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java b/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java new file mode 100644 index 0000000000..a1f79d1568 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/modularui/IGetTitleColor.java @@ -0,0 +1,10 @@ +package gregtech.api.interfaces.modularui; + +import gregtech.api.enums.Dyes; +import gregtech.api.util.GT_Util; + +public interface IGetTitleColor { + default int getTitleColor() { + return GT_Util.getRGBaInt(Dyes.dyeWhite.getRGBA()); + } +} diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java index ddbb550dfc..3bcf441128 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java @@ -1,5 +1,8 @@ package gregtech.api.interfaces.tileentity; +import gregtech.api.enums.Dyes; +import gregtech.api.util.GT_Util; + public interface IColoredTileEntity { /** * @return 0 - 15 are Colors, while -1 means uncolored @@ -12,4 +15,12 @@ public interface IColoredTileEntity { * @param aColor the Color you want to set it to. -1 for reset. */ byte setColorization(byte aColor); + + /** + * @return Actual color shown on GUI + */ + default int getGUIColorization() { + return GT_Util.getRGBInt( + (getColorization() != -1 ? Dyes.get(getColorization()) : Dyes.MACHINE_METAL).getRGBA()); + } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index ad2af44e9e..b389c8be6c 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.IDescribable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddInventorySlots; +import gregtech.api.interfaces.modularui.IGetGUITextureSet; import gregtech.common.blocks.GT_Block_Machines; import java.util.ArrayList; import java.util.List; @@ -34,7 +36,9 @@ public interface IGregTechTileEntity IDigitalChest, IDescribable, IMachineBlockUpdateable, - IGregtechWailaProvider { + IGregtechWailaProvider, + IGetGUITextureSet, + IAddInventorySlots { /** * gets the Error displayed on the GUI */ diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java index 2464816045..7f31d17d11 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IHasWorldObjectAndCoords.java @@ -164,11 +164,19 @@ public interface IHasWorldObjectAndCoords { /** * Opens the GUI with this ID of this MetaTileEntity + * @deprecated Use ModularUI */ - boolean openGUI(EntityPlayer aPlayer, int aID); + @Deprecated + default boolean openGUI(EntityPlayer aPlayer, int aID) { + return false; + } /** * Opens the GUI with the ID = 0 of this TileEntity + * @deprecated Use ModularUI */ - boolean openGUI(EntityPlayer aPlayer); + @Deprecated + default boolean openGUI(EntityPlayer aPlayer) { + return false; + } } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index ebf0672815..395c73570c 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1671,6 +1671,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity GT_Log.err.println( "Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); + e.printStackTrace(); } return false; diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 1f6fb0c68d..23a247468a 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -7,25 +7,61 @@ import static gregtech.api.enums.GT_Values.NW; import static gregtech.api.enums.GT_Values.SIDE_DOWN; import static gregtech.api.enums.GT_Values.SIDE_UP; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import gregtech.GT_Mod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.IConfigurationCircuitSupport; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddInventorySlots; +import gregtech.api.interfaces.modularui.IGetGUITextureSet; import gregtech.api.interfaces.tileentity.IGTEnet; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.interfaces.tileentity.IIC2Enet; import gregtech.api.net.GT_Packet_Block_Event; +import gregtech.api.net.GT_Packet_SetConfigurationCircuit; +import gregtech.api.util.GT_TooltipDataCache; +import gregtech.api.util.GT_Util; import gregtech.api.util.GT_Utility; +import gregtech.common.gui.modularui.uifactory.SelectItemUIFactory; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import java.util.Arrays; +import java.util.List; import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; @@ -38,7 +74,14 @@ import net.minecraftforge.fluids.IFluidHandler; * <p/> * Basically everything a TileEntity should have. */ -public abstract class BaseTileEntity extends TileEntity implements IHasWorldObjectAndCoords, IIC2Enet, IGTEnet { +public abstract class BaseTileEntity extends TileEntity + implements IHasWorldObjectAndCoords, + IIC2Enet, + IGTEnet, + ITileWithModularUI, + IAddGregtechLogo, + IGetGUITextureSet, + IAddInventorySlots { protected boolean mInventoryChanged = false; /** @@ -138,11 +181,13 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje } @Override + @Deprecated public final boolean openGUI(EntityPlayer aPlayer) { return openGUI(aPlayer, 0); } @Override + @Deprecated public final boolean openGUI(EntityPlayer aPlayer, int aID) { if (aPlayer == null) return false; aPlayer.openGui(GT, aID, worldObj, xCoord, yCoord, zCoord); @@ -536,6 +581,37 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje return GT_Utility.trans(aKey, aEnglish); } + protected Supplier<Boolean> getValidator() { + return () -> !this.isDead(); + } + + public boolean useModularUI() { + return false; + } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext) { + if (!useModularUI()) return null; + + buildContext.setValidator(getValidator()); + final ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); + builder.setBackground(getGUITextureSet().getMainBackground()); + builder.setGuiTint(getGUIColorization()); + if (doesBindPlayerInventory()) { + bindPlayerInventoryUI(builder, buildContext); + } + addUIWidgets(builder, buildContext); + addTitleToUI(builder); + addCoverTabs(builder, buildContext); + final IConfigurationCircuitSupport csc = getConfigurationCircuitSupport(); + if (csc != null && csc.allowSelectCircuit()) { + addConfigurationCircuitSlot(builder); + } else { + addGregTechLogo(builder); + } + return builder.build(); + } + /* * IC2 Energy Compat */ @@ -571,4 +647,338 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(ic2EnergySink)); } } + + // === GUI stuff === + + public ItemStackHandler getInventoryHandler() { + return null; + } + + protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + + // Tooltip localization keys + public static final String BATTERY_SLOT_TOOLTIP = "GT5U.machines.battery_slot.tooltip", + BATTERY_SLOT_TOOLTIP_ALT = "GT5U.machines.battery_slot.tooltip.alternative", + UNUSED_SLOT_TOOLTIP = "GT5U.machines.unused_slot.tooltip", + SPECIAL_SLOT_TOOLTIP = "GT5U.machines.special_slot.tooltip", + FLUID_INPUT_TOOLTIP = "GT5U.machines.fluid_input_slot.tooltip", + FLUID_OUTPUT_TOOLTIP = "GT5U.machines.fluid_output_slot.tooltip", + STALLED_STUTTERING_TOOLTIP = "GT5U.machines.stalled_stuttering.tooltip", + STALLED_VENT_TOOLTIP = "GT5U.machines.stalled_vent.tooltip", + FLUID_TRANSFER_TOOLTIP = "GT5U.machines.fluid_transfer.tooltip", + ITEM_TRANSFER_TOOLTIP = "GT5U.machines.item_transfer.tooltip", + POWER_SOURCE_KEY = "GT5U.machines.powersource.", + NEI_TRANSFER_STEAM_TOOLTIP = "GT5U.machines.nei_transfer.steam.tooltip", + NEI_TRANSFER_VOLTAGE_TOOLTIP = "GT5U.machines.nei_transfer.voltage.tooltip"; + + public static final int TOOLTIP_DELAY = 5; + + /** + * Override this to add {@link com.gtnewhorizons.modularui.api.widget.Widget}s for your UI. + */ + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {} + + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.bindPlayerInventory( + buildContext.getPlayer(), 7, getGUITextureSet().getItemSlot()); + } + + public String getLocalName() { + return "Unknown"; + } + + protected void addTitleToUI(ModularWindow.Builder builder) { + addTitleToUI(builder, getLocalName()); + } + + protected void addTitleToUI(ModularWindow.Builder builder, String title) { + if (GT_Mod.gregtechproxy.mTitleTabStyle == 2) { + addTitleItemIconStyle(builder, title); + } else { + addTitleTextStyle(builder, title); + } + } + + protected void addTitleTextStyle(ModularWindow.Builder builder, String title) { + final int TAB_PADDING = 3; + final int TITLE_PADDING = 2; + int titleWidth = 0, titleHeight = 0; + if (NetworkUtils.isClient()) { + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + //noinspection unchecked + final List<String> titleLines = + fontRenderer.listFormattedStringToWidth(title, getGUIWidth() - (TAB_PADDING + TITLE_PADDING) * 2); + titleWidth = titleLines.size() > 1 + ? getGUIWidth() - (TAB_PADDING + TITLE_PADDING) * 2 + : fontRenderer.getStringWidth(title); + //noinspection PointlessArithmeticExpression + titleHeight = titleLines.size() * fontRenderer.FONT_HEIGHT + (titleLines.size() - 1) * 1; + } + + final DrawableWidget tab = new DrawableWidget(); + final TextWidget text = new TextWidget(title) + .setDefaultColor(getTitleColor()) + .setTextAlignment(Alignment.CenterLeft) + .setMaxWidth(titleWidth); + if (GT_Mod.gregtechproxy.mTitleTabStyle == 1) { + tab.setDrawable(getGUITextureSet().getTitleTabAngular()) + .setPos(0, -(titleHeight + TAB_PADDING) + 1) + .setSize(getGUIWidth(), titleHeight + TAB_PADDING * 2); + text.setPos(TAB_PADDING + TITLE_PADDING, -titleHeight + TAB_PADDING); + } else { + tab.setDrawable(getGUITextureSet().getTitleTabDark()) + .setPos(0, -(titleHeight + TAB_PADDING * 2) + 1) + .setSize(titleWidth + (TAB_PADDING + TITLE_PADDING) * 2, titleHeight + TAB_PADDING * 2 - 1); + text.setPos(TAB_PADDING + TITLE_PADDING, -titleHeight); + } + builder.widget(tab).widget(text); + } + + protected void addTitleItemIconStyle(ModularWindow.Builder builder, String title) { + builder.widget(new MultiChildWidget() + .addChild(new DrawableWidget() + .setDrawable(getGUITextureSet().getTitleTabNormal()) + .setPos(0, 0) + .setSize(24, 24)) + .addChild(new ItemDrawable(getStackForm(1)).asWidget().setPos(4, 4)) + .addTooltip(title) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(0, -24 + 3)); + } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.DEFAULT; + } + + protected int getTitleColor() { + return COLOR_TITLE.get(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget(new DrawableWidget() + .setDrawable(getGUITextureSet().getGregTechLogo()) + .setSize(17, 17) + .setPos(152, 63)); + } + + protected int getGUIWidth() { + return 176; + } + + protected int getGUIHeight() { + return 166; + } + + protected boolean doesBindPlayerInventory() { + return true; + } + + @Override + public void add1by1Slot(ModularWindow.Builder builder, IDrawable... background) { + final ItemStackHandler inventoryHandler = getInventoryHandler(); + if (inventoryHandler == null) return; + + if (background.length == 0) { + background = new IDrawable[] {getGUITextureSet().getItemSlot()}; + } + builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 1) + .startFromSlot(0) + .endAtSlot(0) + .background(background) + .build() + .setPos(79, 34)); + } + + @Override + public void add2by2Slots(ModularWindow.Builder builder, IDrawable... background) { + final ItemStackHandler inventoryHandler = getInventoryHandler(); + if (inventoryHandler == null) return; + + if (background.length == 0) { + background = new IDrawable[] {getGUITextureSet().getItemSlot()}; + } + builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 2) + .startFromSlot(0) + .endAtSlot(3) + .background(background) + .build() + .setPos(70, 25)); + } + + @Override + public void add3by3Slots(ModularWindow.Builder builder, IDrawable... background) { + final ItemStackHandler inventoryHandler = getInventoryHandler(); + if (inventoryHandler == null) return; + + if (background.length == 0) { + background = new IDrawable[] {getGUITextureSet().getItemSlot()}; + } + builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 3) + .startFromSlot(0) + .endAtSlot(8) + .background(background) + .build() + .setPos(61, 16)); + } + + @Override + public void add4by4Slots(ModularWindow.Builder builder, IDrawable... background) { + final ItemStackHandler inventoryHandler = getInventoryHandler(); + if (inventoryHandler == null) return; + + if (background.length == 0) { + background = new IDrawable[] {getGUITextureSet().getItemSlot()}; + } + builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .background(background) + .build() + .setPos(52, 7)); + } + + public void addCoverTabs(ModularWindow.Builder builder, UIBuildContext buildContext) { + /* Do nothing */ + } + + public IConfigurationCircuitSupport getConfigurationCircuitSupport() { + if (!(this instanceof IConfigurationCircuitSupport)) return null; + return (IConfigurationCircuitSupport) this; + } + + protected void addConfigurationCircuitSlot(ModularWindow.Builder builder) { + final ItemStackHandler inventoryHandler = getInventoryHandler(); + if (inventoryHandler == null) return; + + if (!(this instanceof IInventory)) return; + final IInventory inv = (IInventory) this; + + final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); + if (ccs == null) return; + + final AtomicBoolean dialogOpened = new AtomicBoolean(false); + builder.widget( + new SlotWidget(new BaseSlot(inventoryHandler, ccs.getCircuitSlot(), true)) { + @Override + protected void phantomClick(ClickData clickData, ItemStack cursorStack) { + final ItemStack newCircuit; + if (clickData.shift) { + if (clickData.mouseButton == 0) { + if (NetworkUtils.isClient() && !dialogOpened.get()) { + openSelectCircuitDialog(getContext(), dialogOpened); + } + return; + } else { + newCircuit = null; + } + } else { + final List<ItemStack> tCircuits = ccs.getConfigurationCircuits(); + final int index = GT_Utility.findMatchingStackInList(tCircuits, cursorStack); + if (index < 0) { + int curIndex = GT_Utility.findMatchingStackInList( + tCircuits, inv.getStackInSlot(ccs.getCircuitSlot())) + + 1; + if (clickData.mouseButton == 0) { + curIndex += 1; + } else { + curIndex -= 1; + } + curIndex = Math.floorMod(curIndex, tCircuits.size() + 1) - 1; + newCircuit = curIndex < 0 ? null : tCircuits.get(curIndex); + } else { + // set to whatever it is + newCircuit = tCircuits.get(index); + } + } + inv.setInventorySlotContents(ccs.getCircuitSlot(), newCircuit); + } + + @Override + protected void phantomScroll(int direction) { + phantomClick(new ClickData(direction > 0 ? 1 : 0, false, false, false)); + } + + @Override + public List<String> getExtraTooltip() { + return Arrays.asList( + EnumChatFormatting.DARK_GRAY + + EnumChatFormatting.getTextWithoutFormattingCodes( + StatCollector.translateToLocal( + "GT5U.machines.select_circuit.tooltip.1")), + EnumChatFormatting.DARK_GRAY + + EnumChatFormatting.getTextWithoutFormattingCodes( + StatCollector.translateToLocal( + "GT5U.machines.select_circuit.tooltip.2")), + EnumChatFormatting.DARK_GRAY + + EnumChatFormatting.getTextWithoutFormattingCodes( + StatCollector.translateToLocal( + "GT5U.machines.select_circuit.tooltip.3"))); + } + }.setOverwriteItemStackTooltip(list -> { + list.removeIf(line -> + line.contains(StatCollector.translateToLocal("gt.integrated_circuit.tooltip.0")) + || line.contains( + StatCollector.translateToLocal("gt.integrated_circuit.tooltip.1"))); + return list; + }) + .disableShiftInsert() + .setHandlePhantomActionClient(true) + .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setGTTooltip(() -> mTooltipCache.getData("GT5U.machines.select_circuit.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(ccs.getCircuitSlotX() - 1, ccs.getCircuitSlotY() - 1)); + } + + protected void openSelectCircuitDialog(ModularUIContext uiContext, AtomicBoolean dialogOpened) { + final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); + if (ccs == null) return; + + if (!(this instanceof IInventory)) return; + final IInventory inv = (IInventory) this; + + final List<ItemStack> circuits = ccs.getConfigurationCircuits(); + uiContext.openClientWindow(player -> new SelectItemUIFactory( + StatCollector.translateToLocal("GT5U.machines.select_circuit"), + getStackForm(0), + this::onCircuitSelected, + circuits, + GT_Utility.findMatchingStackInList(circuits, inv.getStackInSlot(ccs.getCircuitSlot()))) + .setAnotherWindow(true, dialogOpened) + .setGuiTint(getGUIColorization()) + .setCurrentGetter(() -> inv.getStackInSlot(ccs.getCircuitSlot())) + .createWindow(new UIBuildContext(player))); + } + + protected void onCircuitSelected(ItemStack selected) { + final IConfigurationCircuitSupport ccs = getConfigurationCircuitSupport(); + if (ccs == null) return; + + if (!(this instanceof IInventory)) return; + final IInventory inv = (IInventory) this; + + GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit(this, selected)); + // we will not do any validation on client side + // it doesn't get to actually decide what inventory contains anyway + inv.setInventorySlotContents(ccs.getCircuitSlot(), selected); + } + + protected int getTextColorOrDefault(String textType, int defaultColor) { + return defaultColor; + } + + protected Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x404040); + protected Supplier<Integer> COLOR_TITLE_WHITE = () -> getTextColorOrDefault("title_white", 0xfafaff); + protected Supplier<Integer> COLOR_TEXT_WHITE = () -> getTextColorOrDefault("text_white", 0xfafaff); + protected Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x404040); + protected Supplier<Integer> COLOR_TEXT_RED = () -> getTextColorOrDefault("text_red", 0xff0000); + + public int getGUIColorization() { + return GT_Util.getRGBaInt(Dyes.dyeWhite.getRGBA()); + } + + public ItemStack getStackForm(long aAmount) { + return null; + } } diff --git a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java index bf835b51bb..e2860d6292 100644 --- a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java @@ -2,9 +2,18 @@ package gregtech.api.metatileentity; import static gregtech.GT_Mod.GT_FML_LOGGER; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.modularui.IBindPlayerInventoryUI; +import gregtech.api.interfaces.modularui.IGetTitleColor; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Log; @@ -167,4 +176,123 @@ public abstract class CommonMetaTileEntity extends CoverableTileEntity implement final IMetaTileEntity meta = getMetaTileEntity(); return meta != null && meta.shouldJoinIc2Enet(); } + + /* + * Modular UI Support + */ + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (hasValidMetaTileEntity() && getMetaTileEntity() instanceof IAddUIWidgets) { + ((IAddUIWidgets) getMetaTileEntity()).addUIWidgets(builder, buildContext); + return; + } + super.addUIWidgets(builder, buildContext); + } + + @Override + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (hasValidMetaTileEntity() && getMetaTileEntity() instanceof IBindPlayerInventoryUI) { + ((IBindPlayerInventoryUI) getMetaTileEntity()).bindPlayerInventoryUI(builder, buildContext); + return; + } + super.bindPlayerInventoryUI(builder, buildContext); + } + + @Override + public IConfigurationCircuitSupport getConfigurationCircuitSupport() { + if (hasValidMetaTileEntity() && getMetaTileEntity() instanceof IConfigurationCircuitSupport) { + return (IConfigurationCircuitSupport) getMetaTileEntity(); + } + return null; + } + + @Override + public ItemStackHandler getInventoryHandler() { + if (hasValidMetaTileEntity()) { + return getMetaTileEntity().getInventoryHandler(); + } + return null; + } + + @Override + public boolean useModularUI() { + return hasValidMetaTileEntity() && getMetaTileEntity().useModularUI(); + } + + @Override + public String getLocalName() { + if (hasValidMetaTileEntity()) return getMetaTileEntity().getLocalName(); + return super.getLocalName(); + } + + @Override + protected int getGUIWidth() { + if (hasValidMetaTileEntity()) return getMetaTileEntity().getGUIWidth(); + + return super.getGUIWidth(); + } + + @Override + protected int getGUIHeight() { + if (hasValidMetaTileEntity()) return getMetaTileEntity().getGUIHeight(); + + return super.getGUIHeight(); + } + + @Override + protected boolean doesBindPlayerInventory() { + if (hasValidMetaTileEntity()) return getMetaTileEntity().doesBindPlayerInventory(); + + return super.doesBindPlayerInventory(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + if (hasValidMetaTileEntity() && getMetaTileEntity() instanceof IAddGregtechLogo) { + ((IAddGregtechLogo) getMetaTileEntity()).addGregTechLogo(builder); + return; + } + super.addGregTechLogo(builder); + } + + @Override + public ItemStack getStackForm(long aAmount) { + if (hasValidMetaTileEntity()) { + return getMetaTileEntity().getStackForm(aAmount); + } + return super.getStackForm(aAmount); + } + + @Override + public int getTitleColor() { + if (hasValidMetaTileEntity() && getMetaTileEntity() instanceof IGetTitleColor) { + return ((IGetTitleColor) getMetaTileEntity()).getTitleColor(); + } + return super.getTitleColor(); + } + + @Override + public int getGUIColorization() { + if (hasValidMetaTileEntity()) { + return getMetaTileEntity().getGUIColorization(); + } + return super.getGUIColorization(); + } + + @Override + protected int getTextColorOrDefault(String textType, int defaultColor) { + if (hasValidMetaTileEntity()) { + return getMetaTileEntity().getTextColorOrDefault(textType, defaultColor); + } + return defaultColor; + } + + @Override + public GUITextureSet getGUITextureSet() { + if (hasValidMetaTileEntity()) { + return getMetaTileEntity().getGUITextureSet(); + } + return super.getGUITextureSet(); + } } diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index 9511488a3f..580fc136e6 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -6,31 +6,52 @@ import static gregtech.api.enums.GT_Values.NW; import static gregtech.api.util.GT_LanguageManager.FACES; import static gregtech.api.util.GT_LanguageManager.getTranslation; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.math.MainAxisAlignment; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.Column; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_CoverUIBuildContext; +import gregtech.api.gui.modularui.GUITextureSet; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregtechWailaProvider; import gregtech.api.net.GT_Packet_RequestCoverData; import gregtech.api.net.GT_Packet_SendCoverData; +import gregtech.api.net.GT_Packet_TileEntityCoverGUI; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_CoverBehaviorBase; import gregtech.api.util.ISerializableObject; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Fluidfilter; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.IntStream; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; +import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; @@ -526,4 +547,134 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov } } } + + protected ModularWindow createCoverWindow(EntityPlayer player, byte side) { + final GT_CoverBehaviorBase<?> coverBehavior = getCoverBehaviorAtSideNew(side); + final GT_CoverUIBuildContext buildContext = + new GT_CoverUIBuildContext(player, getCoverIDAtSide(side), side, this, true); + return coverBehavior.createWindow(buildContext); + } + + protected static final int COVER_WINDOW_ID_START = 1; + + @Override + public void addCoverTabs(ModularWindow.Builder builder, UIBuildContext buildContext) { + final int COVER_TAB_LEFT = -16, + COVER_TAB_TOP = 1, + COVER_TAB_HEIGHT = 20, + COVER_TAB_WIDTH = 18, + COVER_TAB_SPACING = 2, + ICON_SIZE = 16; + final boolean flipHorizontally = GT_Mod.gregtechproxy.mCoverTabsFlipped; + + final Column columnWidget = new Column(); + builder.widget(columnWidget); + final int xPos = flipHorizontally ? (getGUIWidth() - COVER_TAB_LEFT - COVER_TAB_WIDTH) : COVER_TAB_LEFT; + if (GT_Mod.gregtechproxy.mCoverTabsVisible) { + columnWidget.setPos(xPos, COVER_TAB_TOP).setEnabled(widget -> ((Column) widget) + .getChildren().stream().anyMatch(Widget::isEnabled)); + } else { + columnWidget.setEnabled(false); + } + columnWidget.setAlignment(MainAxisAlignment.SPACE_BETWEEN).setSpace(COVER_TAB_SPACING); + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + final byte side = (byte) direction.ordinal(); + buildContext.addSyncedWindow(side + COVER_WINDOW_ID_START, player -> createCoverWindow(player, side)); + columnWidget.addChild(new MultiChildWidget() + .addChild( + new ButtonWidget() { + @Override + public IDrawable[] getBackground() { + final List<IDrawable> backgrounds = new ArrayList<>(); + final GUITextureSet tabIconSet = getGUITextureSet(); + + if (getCoverBehaviorAtSideNew(side).hasCoverGUI()) { + if (isHovering()) { + backgrounds.add( + flipHorizontally + ? tabIconSet.getCoverTabHighlightFlipped() + : tabIconSet.getCoverTabHighlight()); + } else { + backgrounds.add( + flipHorizontally + ? tabIconSet.getCoverTabNormalFlipped() + : tabIconSet.getCoverTabNormal()); + } + } else { + backgrounds.add( + flipHorizontally + ? tabIconSet.getCoverTabDisabledFlipped() + : tabIconSet.getCoverTabDisabled()); + } + return backgrounds.toArray(new IDrawable[] {}); + } + }.setOnClick((clickData, widget) -> onTabClicked(clickData, widget, side)) + .dynamicTooltip(() -> getCoverTabTooltip(side)) + .setSize(COVER_TAB_WIDTH, COVER_TAB_HEIGHT)) + .addChild(new ItemDrawable(() -> { + return getCoverItemAtSide(side); + }) + .asWidget() + .setPos( + (COVER_TAB_WIDTH - ICON_SIZE) / 2 + (flipHorizontally ? -1 : 1), + (COVER_TAB_HEIGHT - ICON_SIZE) / 2)) + .setEnabled(widget -> { + return getCoverItemAtSide(side) != null; + })); + } + } + + @SideOnly(Side.CLIENT) + protected List<String> getCoverTabTooltip(byte side) { + final String[] SIDE_TOOLTIPS = new String[] { + "GT5U.interface.coverTabs.down", + "GT5U.interface.coverTabs.up", + "GT5U.interface.coverTabs.north", + "GT5U.interface.coverTabs.south", + "GT5U.interface.coverTabs.west", + "GT5U.interface.coverTabs.east" + }; + final ItemStack coverItem = getCoverItemAtSide(side); + if (coverItem == null) return Collections.emptyList(); + boolean coverHasGUI = getCoverBehaviorAtSideNew(side).hasCoverGUI(); + + //noinspection unchecked + List<String> tooltip = coverItem.getTooltip(Minecraft.getMinecraft().thePlayer, true); + for (int i = 0; i < tooltip.size(); i++) { + if (i == 0) { + tooltip.set( + 0, + (coverHasGUI ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) + + StatCollector.translateToLocal(SIDE_TOOLTIPS[side]) + + (coverHasGUI ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET) + + tooltip.get(0)); + } else { + tooltip.set(i, EnumChatFormatting.GRAY + tooltip.get(i)); + } + } + return tooltip; + } + + protected void onTabClicked(Widget.ClickData clickData, Widget widget, byte side) { + if (isClientSide()) return; + + final GT_CoverBehaviorBase<?> coverBehavior = getCoverBehaviorAtSideNew(side); + if (coverBehavior.useModularUI()) { + widget.getContext().openSyncedWindow(side + COVER_WINDOW_ID_START); + } else { + final GT_Packet_TileEntityCoverGUI packet = new GT_Packet_TileEntityCoverGUI( + getXCoord(), + getYCoord(), + getZCoord(), + side, + getCoverIDAtSide(side), + getComplexCoverDataAtSide(side), + getWorld().provider.dimensionId, + widget.getContext().getPlayer().getEntityId(), + 0); + GT_Values.NW.sendToPlayer( + packet, (EntityPlayerMP) widget.getContext().getPlayer()); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 105ec073ec..ff9ac7517d 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -8,6 +8,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; +import gregtech.api.enums.Dyes; import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; @@ -1047,4 +1048,17 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } public void reloadLocks() {} + + @Override + public int getGUIColorization() { + Dyes dye = Dyes.dyeWhite; + if (GregTech_API.sColoredGUI) { + if (GregTech_API.sMachineMetalGUI) { + dye = Dyes.MACHINE_METAL; + } else if (getBaseMetaTileEntity() != null) { + dye = Dyes.getDyeFromIndex(getBaseMetaTileEntity().getColorization()); + } + } + return GT_Util.getRGBInt(dye.getRGBA()); + } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 5c8f1c33bb..586b52fd99 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -6,14 +6,19 @@ import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.pathing.IPathingGrid; import appeng.api.util.AECableType; import appeng.me.helpers.AENetworkProxy; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gnu.trove.list.TIntList; import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; +import gregtech.api.enums.Dyes; import gregtech.api.enums.SoundResource; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.GT_GUIColorOverride; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.metatileentity.IMachineCallback; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -23,12 +28,15 @@ import gregtech.api.util.GT_Config; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_TooltipDataCache; +import gregtech.api.util.GT_Util; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Client; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.function.Supplier; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.block.Block; @@ -71,6 +79,19 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac */ public final ItemStack[] mInventory; + /** + * Inventory wrapper for ModularUI + */ + public final ItemStackHandler inventoryHandler; + + protected GT_GUIColorOverride colorOverride; + protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + + @Override + public ItemStackHandler getInventoryHandler() { + return inventoryHandler; + } + public boolean doTickProfilingInThisTick = true; private MetaTileEntity mCallBackTile; @@ -107,6 +128,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); mInventory = new ItemStack[aInvSlotCount]; + inventoryHandler = new ItemStackHandler(mInventory); } /** @@ -115,6 +137,9 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public MetaTileEntity(String aName, int aInvSlotCount) { mInventory = new ItemStack[aInvSlotCount]; mName = aName; + inventoryHandler = new ItemStackHandler(mInventory); + colorOverride = new GT_GUIColorOverride( + getGUITextureSet().getMainBackground().location.getResourcePath()); } /** @@ -151,6 +176,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac getBaseMetaTileEntity().getMetaTileID()); } + @Override public String getLocalName() { return GT_LanguageManager.getTranslation("gt.blockmachines." + mName + ".name"); } @@ -396,6 +422,14 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } /** + * @return what type of texture does this machine use for GUI, + * i.e. Bronze, Steel, or Primitive + */ + public SteamVariant getSteamVariant() { + return SteamVariant.NONE; + } + + /** * @return true if this Device emits Energy at all */ public boolean isEnetOutput() { @@ -991,11 +1025,19 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac // } + /** + * @deprecated Use ModularUI + */ + @Deprecated @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return null; } + /** + * @deprecated Use ModularUI + */ + @Deprecated @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return null; @@ -1048,64 +1090,32 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower < V[0] - ? 1.0F - : aExplosionPower < V[1] - ? 2.0F - : aExplosionPower < V[2] - ? 3.0F - : aExplosionPower < V[3] - ? 4.0F - : aExplosionPower < V[4] - ? 5.0F - : aExplosionPower < V[4] * 2 - ? 6.0F - : aExplosionPower < V[5] - ? 7.0F - : aExplosionPower < V[6] - ? 8.0F - : aExplosionPower < V[7] - ? 9.0F - : aExplosionPower < V[8] - ? 10.0F - : aExplosionPower < V[8] * 2 - ? 11.0F - : aExplosionPower < V[9] - ? 12.0F - : aExplosionPower - < V[ - 10] - ? 13.0F - : aExplosionPower - < V[ - 11] - ? 14.0F - : aExplosionPower - < V[ - 12] - ? 15.0F - : aExplosionPower - < V[ - 12] - * 2 - ? 16.0F - : aExplosionPower - < V[ - 13] - ? 17.0F - : aExplosionPower - < V[ - 14] - ? 18.0F - : aExplosionPower - < V[ - 15] - ? 19.0F - : 20.0F; - int tX = getBaseMetaTileEntity().getXCoord(), - tY = getBaseMetaTileEntity().getYCoord(), - tZ = getBaseMetaTileEntity().getZCoord(); - World tWorld = getBaseMetaTileEntity().getWorld(); + // spotless:off + float tStrength = + aExplosionPower < V[0] ? 1.0F : + aExplosionPower < V[1] ? 2.0F : + aExplosionPower < V[2] ? 3.0F : + aExplosionPower < V[3] ? 4.0F : + aExplosionPower < V[4] ? 5.0F : + aExplosionPower < V[4] * 2 ? 6.0F : + aExplosionPower < V[5] ? 7.0F : + aExplosionPower < V[6] ? 8.0F : + aExplosionPower < V[7] ? 9.0F : + aExplosionPower < V[8] ? 10.0F : + aExplosionPower < V[8] * 2 ? 11.0F : + aExplosionPower < V[9] ? 12.0F : + aExplosionPower < V[10] ? 13.0F : + aExplosionPower < V[11] ? 14.0F : + aExplosionPower < V[12] ? 15.0F : + aExplosionPower < V[12] * 2 ? 16.0F : + aExplosionPower < V[13] ? 17.0F : + aExplosionPower < V[14] ? 18.0F : + aExplosionPower < V[15] ? 19.0F : 20.0F; + // spotless:on + final int tX = getBaseMetaTileEntity().getXCoord(); + final int tY = getBaseMetaTileEntity().getYCoord(); + final int tZ = getBaseMetaTileEntity().getZCoord(); + final World tWorld = getBaseMetaTileEntity().getWorld(); GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ); tWorld.setBlock(tX, tY, tZ, Blocks.air); if (GregTech_API.sMachineExplosions) @@ -1174,6 +1184,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac return false; } + // === AE2 compat === + @Optional.Method(modid = "appliedenergistics2") public AECableType getCableConnectionType(ForgeDirection forgeDirection) { return AECableType.NONE; @@ -1187,6 +1199,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Optional.Method(modid = "appliedenergistics2") public void gridChanged() {} + // === Waila compat === + @Override public void getWailaBody( ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { @@ -1218,4 +1232,38 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } return ""; } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.DEFAULT; + } + + @Override + public int getGUIColorization() { + Dyes dye = Dyes.dyeWhite; + if (this.colorOverride.sLoaded()) { + if (this.colorOverride.sGuiTintingEnabled() && getBaseMetaTileEntity() != null) { + dye = Dyes.getDyeFromIndex(getBaseMetaTileEntity().getColorization()); + return this.colorOverride.getGuiTintOrDefault(dye.mName, GT_Util.getRGBInt(dye.getRGBA())); + } + } else if (GregTech_API.sColoredGUI) { + if (GregTech_API.sMachineMetalGUI) { + dye = Dyes.MACHINE_METAL; + } else if (getBaseMetaTileEntity() != null) { + dye = Dyes.getDyeFromIndex(getBaseMetaTileEntity().getColorization()); + } + } + return GT_Util.getRGBInt(dye.getRGBA()); + } + + @Override + public int getTextColorOrDefault(String textType, int defaultColor) { + return colorOverride.getTextColorOrDefault(textType, defaultColor); + } + + protected Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x404040); + protected Supplier<Integer> COLOR_TITLE_WHITE = () -> getTextColorOrDefault("title_white", 0xfafaff); + protected Supplier<Integer> COLOR_TEXT_WHITE = () -> getTextColorOrDefault("text_white", 0xfafaff); + protected Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x404040); + protected Supplier<Integer> COLOR_TEXT_RED = () -> getTextColorOrDefault("text_red", 0xff0000); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 67c3c672ae..45c07cf4c3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -2,17 +2,19 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.api.enums.Textures; -import gregtech.api.gui.*; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -23,7 +25,8 @@ import net.minecraft.util.EnumChatFormatting; * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_TieredMachineBlock { +public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_TieredMachineBlock + implements IAddUIWidgets { public boolean mCharge = false, mDecharge = false; public int mBatteryCount = 0, mChargeableCount = 0; private long count = 0; @@ -208,42 +211,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 4: - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 9: - return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - case 16: - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 4: - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 9: - return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 16: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; @@ -357,4 +329,27 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier public boolean isGivingInformation() { return true; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + switch (mInventory.length) { + case 4: + getBaseMetaTileEntity().add2by2Slots(builder); + break; + case 9: + getBaseMetaTileEntity().add3by3Slots(builder); + break; + case 16: + getBaseMetaTileEntity().add4by4Slots(builder); + break; + default: + getBaseMetaTileEntity().add1by1Slot(builder); + break; + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 091c364b4f..ca5f255302 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.ItemData; @@ -85,8 +86,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -355,4 +355,9 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public int getTankPressure() { return -100; } + + @Override + public boolean useModularUI() { + return true; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 15ce40cebf..a07fb5fb0d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -4,25 +4,57 @@ import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_INPUT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_OUTPUT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_TRANSFER_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.ITEM_TRANSFER_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.NEI_TRANSFER_STEAM_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.NEI_TRANSFER_VOLTAGE_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.POWER_SOURCE_KEY; +import static gregtech.api.metatileentity.BaseTileEntity.SPECIAL_SLOT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.STALLED_STUTTERING_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.STALLED_VENT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.metatileentity.BaseTileEntity.UNUSED_SLOT_TOOLTIP; import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.SoundResource; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.SteamTexture; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; import gregtech.common.power.BasicMachineEUPower; import gregtech.common.power.Power; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; import java.util.Arrays; +import java.util.Collections; import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -39,6 +71,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; +import org.apache.commons.lang3.tuple.Pair; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -47,7 +80,7 @@ import net.minecraftforge.fluids.IFluidHandler; * Extend this class to make a simple Machine */ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank - implements IConfigurationCircuitSupport { + implements IConfigurationCircuitSupport, IAddUIWidgets { /** * return values for checkRecipe() @@ -369,6 +402,10 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return OTHER_SLOT_COUNT + mInputSlotCount; } + public int getSpecialSlotIndex() { + return 3; + } + @Override public int getStackDisplaySlot() { return 2; @@ -482,12 +519,20 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; if (!GT_Mod.gregtechproxy.mForceFreeFace) { - aBaseMetaTileEntity.openGUI(aPlayer); + if (useModularUI()) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } return true; } for (byte i = 0; i < 6; i++) { if (aBaseMetaTileEntity.getAirAtSide(i)) { - aBaseMetaTileEntity.openGUI(aPlayer); + if (useModularUI()) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } return true; } } @@ -495,11 +540,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return true; } + @Deprecated @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); } + @Deprecated @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_BasicMachine( @@ -685,7 +732,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { if (checkRecipe() == FOUND_AND_SUCCESSFULLY_USED_RECIPE) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + if (getSpecialSlot() != null && getSpecialSlot().stackSize <= 0) + mInventory[getSpecialSlotIndex()] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; for (int i = 0; i < mOutputItems.length; i++) { @@ -734,7 +782,15 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public void updateFluidDisplayItem() { + updateFluidOutputDisplayItem(); + updateFluidInputDisplayItem(); + } + + public void updateFluidOutputDisplayItem() { super.updateFluidDisplayItem(); + } + + public void updateFluidInputDisplayItem() { if (displaysInputFluid()) { int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; if (getFillableStack() == null) { @@ -771,7 +827,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected ItemStack getSpecialSlot() { - return mInventory[3]; + return mInventory[getSpecialSlotIndex()]; } protected ItemStack getOutputAt(int aIndex) { @@ -1231,6 +1287,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return mPower; } + // GUI stuff + + @Override + public boolean useModularUI() { + return getRecipeList() != null && getRecipeList().useModularUI; + } + @Override public int getCircuitSlotX() { return 153; @@ -1240,4 +1303,252 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public int getCircuitSlotY() { return 63; } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (!isSteampowered()) { + builder.widget(createFluidAutoOutputButton()); + builder.widget(createItemAutoOutputButton()); + } + + addIOSlots(builder); + + builder.widget(createChargerSlot(79, 62)); + if (getRecipeList() != null) { + builder.widget(setNEITransferRect( + createProgressBar( + isSteampowered() + ? getRecipeList().progressBarTextureSteam.get(getSteamVariant()) + : getRecipeList().progressBarTexture, + getRecipeList().getProgressBarImageSize(), + getRecipeList().progressBarDirection, + getRecipeList().progressBarPos, + getRecipeList().progressBarSize), + getRecipeList().mNEIName)); + addProgressBarSpecialTextures(builder); + } + builder.widget(createErrorStatusArea( + builder, + isSteampowered() ? GT_UITextures.PICTURE_STALLED_STEAM : GT_UITextures.PICTURE_STALLED_ELECTRICITY)); + } + + /** + * Adds item I/O, special item, and fluid I/O slots. + */ + protected void addIOSlots(ModularWindow.Builder builder) { + final boolean hasFluidInput = + getRecipeList() != null ? (getRecipeList().hasFluidInputs()) : (getCapacity() != 0); + final boolean hasFluidOutput = + getRecipeList() != null && getRecipeList().hasFluidOutputs(); + UIHelper.forEachSlots( + (i, backgrounds, pos) -> builder.widget(createItemInputSlot(i, backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createItemOutputSlot(i, backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createSpecialSlot(backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createFluidInputSlot(backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createFluidOutputSlot(backgrounds, pos)), + getGUITextureSet().getItemSlot(), + getGUITextureSet().getFluidSlot(), + getRecipeList(), + mInputSlotCount, + mOutputItems.length, + hasFluidInput ? 1 : 0, + hasFluidOutput ? 1 : 0, + getSteamVariant(), + Pos2d.ZERO); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createItemInputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getInputSlot() + index) + .setAccess(true, true) + .setBackground(backgrounds) + .setPos(pos); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createItemOutputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getOutputSlot() + index) + .setAccess(true, false) + .setBackground(backgrounds) + .setPos(pos); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getSpecialSlotIndex()) + .setAccess(true, true) + .disableShiftInsert() + .setGTTooltip(() -> mTooltipCache.getData( + getRecipeList() != null && getRecipeList().usesSpecialSlot() + ? SPECIAL_SLOT_TOOLTIP + : UNUSED_SLOT_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + protected FluidDisplaySlotWidget createFluidInputSlot(IDrawable[] backgrounds, Pos2d pos) { + return (FluidDisplaySlotWidget) new FluidDisplaySlotWidget( + inventoryHandler, OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length) + .setFluidAccessConstructor(() -> constructFluidAccess(true)) + .setIHasFluidDisplay(this) + .setCanDrain(true) + .setCanFill(true) + .setActionRealClick(FluidDisplaySlotWidget.Action.TRANSFER) + .setBeforeRealClick((clickData, widget) -> { + if (NetworkUtils.isClient()) { + // propagate display item content to actual fluid stored in this tank + setFillableStack(GT_Utility.getFluidFromDisplayStack( + widget.getMcSlot().getStack())); + } + return true; + }) + .setUpdateFluidDisplayItem(this::updateFluidInputDisplayItem) + .setGTTooltip(() -> mTooltipCache.getData(FLUID_INPUT_TOOLTIP, GT_Utility.formatNumbers(getCapacity()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + protected FluidDisplaySlotWidget createFluidOutputSlot(IDrawable[] backgrounds, Pos2d pos) { + return (FluidDisplaySlotWidget) createDrainableFluidSlot() + .setUpdateFluidDisplayItem(this::updateFluidOutputDisplayItem) + .setGTTooltip( + () -> mTooltipCache.getData(FLUID_OUTPUT_TOOLTIP, GT_Utility.formatNumbers(getCapacity()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + @Override + protected SlotWidget createChargerSlot(int x, int y) { + if (isSteampowered()) { + return (SlotWidget) createChargerSlot(x, y, UNUSED_SLOT_TOOLTIP, new String[0]) + .setBackground(getGUITextureSet().getItemSlot()); + } else { + return super.createChargerSlot(x, y); + } + } + + protected CycleButtonWidget createItemAutoOutputButton() { + return (CycleButtonWidget) new CycleButtonWidget() + .setToggle(() -> mItemTransfer, val -> mItemTransfer = val) + .setStaticTexture(GT_UITextures.OVERLAY_BUTTON_AUTOOUTPUT_ITEM) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setGTTooltip(() -> mTooltipCache.getData(ITEM_TRANSFER_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(25, 62) + .setSize(18, 18); + } + + protected CycleButtonWidget createFluidAutoOutputButton() { + return (CycleButtonWidget) new CycleButtonWidget() + .setToggle(() -> mFluidTransfer, val -> mFluidTransfer = val) + .setStaticTexture(GT_UITextures.OVERLAY_BUTTON_AUTOOUTPUT_FLUID) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setGTTooltip(() -> mTooltipCache.getData(FLUID_TRANSFER_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7, 62) + .setSize(18, 18); + } + + protected ProgressBar createProgressBar( + UITexture texture, int imageSize, ProgressBar.Direction direction, Pos2d pos, Size size) { + final ProgressBar ret = new ProgressBar(); + ret.setProgress(() -> maxProgresstime() != 0 ? (float) getProgresstime() / maxProgresstime() : 0) + .setTexture(texture, imageSize) + .setDirection(direction) + .setPos(pos) + .setSize(size); + return ret; + } + + public boolean hasNEITransferRect() { + return getRecipeList() != null; + } + + protected Widget setNEITransferRect(Widget widget, String transferRectID) { + if (hasNEITransferRect()) { + final Power powerInfo = getPower(); + final String transferRectTooltip; + if (isSteampowered()) { + transferRectTooltip = + StatCollector.translateToLocalFormatted(NEI_TRANSFER_STEAM_TOOLTIP, powerInfo.getTierString()); + } else { + transferRectTooltip = StatCollector.translateToLocalFormatted( + NEI_TRANSFER_VOLTAGE_TOOLTIP, powerInfo.getTierString()); + } + widget.setNEITransferRect(transferRectID, new Object[] {powerInfo}, transferRectTooltip); + } + return widget; + } + + protected void addProgressBarSpecialTextures(ModularWindow.Builder builder) { + if (isSteampowered()) { + for (Pair<SteamTexture, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTexturesSteam) { + builder.widget(new DrawableWidget() + .setDrawable(specialTexture.getLeft().get(getSteamVariant())) + .setSize(specialTexture.getRight().getLeft()) + .setPos(specialTexture.getRight().getRight())); + } + } else { + for (Pair<IDrawable, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTextures) { + builder.widget(new DrawableWidget() + .setDrawable(specialTexture.getLeft()) + .setSize(specialTexture.getRight().getLeft()) + .setPos(specialTexture.getRight().getRight())); + } + } + } + + protected DrawableWidget createErrorStatusArea(ModularWindow.Builder builder, IDrawable picture) { + return (DrawableWidget) new DrawableWidget() + .setDrawable(picture) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setEnabled(widget -> !widget.getTooltip().isEmpty()) + .dynamicTooltip(this::getErrorDescriptions) + .dynamicTooltipShift(this::getErrorDescriptionsShift) + .setPos(79, 44) + .setSize(18, 18) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> mStuttering, val -> mStuttering = val), + builder, + (widget, val) -> widget.notifyTooltipChange()) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer( + () -> getBaseMetaTileEntity().getErrorDisplayID(), + val -> getBaseMetaTileEntity().setErrorDisplayID(val)), + builder, + (widget, val) -> widget.notifyTooltipChange()); + } + + protected List<String> getErrorDescriptions() { + final GT_TooltipDataCache.TooltipData tooltip = getErrorTooltip(); + return tooltip != null ? tooltip.text : Collections.emptyList(); + } + + protected List<String> getErrorDescriptionsShift() { + final GT_TooltipDataCache.TooltipData tooltip = getErrorTooltip(); + return tooltip != null ? tooltip.shiftText : Collections.emptyList(); + } + + protected GT_TooltipDataCache.TooltipData getErrorTooltip() { + if (isSteampowered()) { + if ((getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0) { + return mTooltipCache.getData(STALLED_VENT_TOOLTIP); + } + } + if (mStuttering) { + return mTooltipCache.getData( + STALLED_STUTTERING_TOOLTIP, + StatCollector.translateToLocal(POWER_SOURCE_KEY + (isSteampowered() ? "steam" : "power"))); + } + return null; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index aa893c0bc2..049aaa45bf 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -8,6 +8,8 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.ParticleFX; import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.GUITextureSet; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; @@ -427,4 +429,14 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE TextureFactory.of(OVERLAY_PIPE_OUT) }; } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.BRONZE; + } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.STEAM.apply(getSteamVariant()); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java index d69ab3aa14..592d27f74f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java @@ -9,7 +9,9 @@ import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEEL_TOP; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; import gregtech.api.enums.Dyes; +import gregtech.api.enums.SteamVariant; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IGetTitleColor; import gregtech.api.render.TextureFactory; import gregtech.common.power.Power; import gregtech.common.power.SteamPower; @@ -20,7 +22,8 @@ import gregtech.common.power.SteamPower; * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEntity_BasicMachine_Bronze { +public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEntity_BasicMachine_Bronze + implements IGetTitleColor { public GT_MetaTileEntity_BasicMachine_Steel( int aID, String aName, @@ -188,4 +191,14 @@ public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEn TextureFactory.of(OVERLAY_PIPE_OUT) }; } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.STEEL; + } + + @Override + public int getTitleColor() { + return COLOR_TITLE_WHITE.get(); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index c1b734baf6..0207178559 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -1,12 +1,22 @@ package gregtech.api.metatileentity.implementations; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.api.enums.ItemList; import gregtech.api.gui.GT_Container_BasicTank; import gregtech.api.gui.GT_GUIContainer_BasicTank; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.IFluidAccess; import gregtech.api.interfaces.IHasFluidDisplayItem; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; +import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -20,7 +30,7 @@ import net.minecraftforge.fluids.FluidTankInfo; * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually */ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock - implements IHasFluidDisplayItem { + implements IHasFluidDisplayItem, IAddUIWidgets { public FluidStack mFluid; protected int mOpenerCount; @@ -90,6 +100,9 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier public abstract boolean displaysItemStack(); + /** + * @return If fluid amount is shown on FluidDisplayItem + */ public abstract boolean displaysStackSize(); public int getInputSlot() { @@ -141,11 +154,13 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier return getDrainableStack(); } + @Deprecated @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); } + @Deprecated @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); @@ -329,4 +344,79 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier protected void onEmptyingContainerWhenEmpty() { // Do nothing } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 16) + .setSize(71, 45)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_GAUGE) + .setPos(79, 34) + .setSize(18, 18)) + .widget(new SlotWidget(inventoryHandler, getInputSlot()) + .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN) + .setPos(79, 16)) + .widget(new SlotWidget(inventoryHandler, getOutputSlot()) + .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_OUT) + .setPos(79, 52)) + .widget(createDrainableFluidSlot() + .setBackground(GT_UITextures.TRANSPARENT) + .setPos(58, 41)) + .widget(new TextWidget("Liquid Amount") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 20)) + .widget(TextWidget.dynamicString( + () -> GT_Utility.parseNumberToString(mFluid != null ? mFluid.amount : 0)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(10, 30)); + } + + protected FluidDisplaySlotWidget createDrainableFluidSlot() { + return new FluidDisplaySlotWidget(inventoryHandler, getStackDisplaySlot()) + .setFluidAccessConstructor(() -> constructFluidAccess(false)) + .setIHasFluidDisplay(this) + .setCanDrain(true) + .setCanFill(!isDrainableStackSeparate()) + .setActionRealClick(FluidDisplaySlotWidget.Action.TRANSFER) + .setBeforeRealClick((clickData, widget) -> { + if (NetworkUtils.isClient()) { + // propagate display item content to actual fluid stored in this tank + setDrainableStack(GT_Utility.getFluidFromDisplayStack( + widget.getMcSlot().getStack())); + } + return true; + }); + } + + protected IFluidAccess constructFluidAccess(boolean aIsFillableStack) { + return new BasicTankFluidAccess(this, aIsFillableStack); + } + + protected static class BasicTankFluidAccess implements IFluidAccess { + protected final GT_MetaTileEntity_BasicTank mTank; + protected final boolean mIsFillableStack; + + public BasicTankFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { + this.mTank = aTank; + this.mIsFillableStack = aIsFillableStack; + } + + @Override + public void set(FluidStack stack) { + if (mIsFillableStack) mTank.setFillableStack(stack); + else mTank.setDrainableStack(stack); + } + + @Override + public FluidStack get() { + return mIsFillableStack ? mTank.getFillableStack() : mTank.getDrainableStack(); + } + + @Override + public int getCapacity() { + return mTank.getCapacity(); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 7354546002..6d327646fe 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -3,6 +3,11 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.Textures.BlockIcons.*; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; @@ -226,8 +231,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -429,4 +433,91 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } return super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); } + + @Override + public boolean useModularUI() { + return true; + } + + protected void addEmitEnergyButton(ModularWindow.Builder builder) { + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bOutput = !bOutput; + if (bOutput) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("116", "Emit Energy to Outputside")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("117", "Don't emit Energy")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_EMIT_ENERGY) + .setPos(7, 62) + .setSize(18, 18)); + } + + protected void addEmitRedstoneButton(ModularWindow.Builder builder) { + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bRedstoneIfFull = !bRedstoneIfFull; + if (bRedstoneIfFull) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), + GT_Utility.trans("118", "Emit Redstone if no Slot is free")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("119", "Don't emit Redstone")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_EMIT_REDSTONE) + .setPos(25, 62) + .setSize(18, 18)); + } + + protected void addInvertRedstoneButton(ModularWindow.Builder builder) { + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bInvert = !bInvert; + if (bInvert) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("120", "Invert Redstone")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("121", "Don't invert Redstone")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_INVERT_REDSTONE) + .setPos(43, 62) + .setSize(18, 18)); + } + + protected void addStockingModeButton(ModularWindow.Builder builder) { + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bStockingMode = !bStockingMode; + if (bStockingMode) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), + GT_Utility.trans( + "217", + "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly.")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), + GT_Utility.trans( + "218", + "Transfer size mode. Add exactly this many items in destination input slots as long as there is room.")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_STOCKING_MODE) + .setPos(61, 62) + .setSize(18, 18)); + } + + protected void addInventorySlots(ModularWindow.Builder builder) { + builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 9) + .endAtSlot(26) + .build() + .setPos(7, 4)); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java index bc4b82477d..e60ffe0f58 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java @@ -2,21 +2,21 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DATA_ACCESS; -import gregtech.api.gui.GT_Container_2by2; -import gregtech.api.gui.GT_Container_4by4; -import gregtech.api.gui.GT_GUIContainer_2by2; -import gregtech.api.gui.GT_GUIContainer_4by4; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_AssemblyLineUtils; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch { +public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch implements IAddUIWidgets { private int timeout = 4; public GT_MetaTileEntity_Hatch_DataAccess(int aID, String aName, String aNameRegional, int aTier) { @@ -71,34 +71,11 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 4: - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - default: - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 4: - return new GT_GUIContainer_2by2( - aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); - default: - return new GT_GUIContainer_4by4( - aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); - } - } - - @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return mTier >= 8 && !aBaseMetaTileEntity.isActive(); } @@ -150,4 +127,23 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch super.setInventorySlotContents(aIndex, aStack); GT_AssemblyLineUtils.processDataStick(aStack); } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + switch (mTier) { + case 4: + getBaseMetaTileEntity() + .add2by2Slots(builder, getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_CIRCUIT); + break; + default: + getBaseMetaTileEntity() + .add4by4Slots(builder, getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_CIRCUIT); + break; + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index cb2c869edc..ead36c10ab 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -4,6 +4,7 @@ import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; import gregtech.GT_Mod; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -93,8 +94,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -162,4 +162,9 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { public int getTankPressure() { return -100; } + + @Override + public boolean useModularUI() { + return true; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index f9daf9c605..b6ace5a630 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -2,10 +2,13 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.Textures.BlockIcons.*; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.GT_Mod; -import gregtech.api.gui.*; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; @@ -18,12 +21,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; -public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch implements IConfigurationCircuitSupport { +public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch + implements IConfigurationCircuitSupport, IAddUIWidgets { public GT_Recipe_Map mRecipeMap = null; public boolean disableSort; public boolean disableFilter = true; @@ -108,26 +111,11 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 1: - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 2: - return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - default: - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - } - - @Override public int getCircuitSlotX() { return 153; } @@ -147,22 +135,6 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 2: - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 5: - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 10: - return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 17: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - default: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - } - } - - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { updateSlots(); @@ -287,4 +259,27 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im public int getCircuitSlot() { return getSlots(mTier); } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + switch (mTier) { + case 0: + getBaseMetaTileEntity().add1by1Slot(builder); + break; + case 1: + getBaseMetaTileEntity().add2by2Slots(builder); + break; + case 2: + getBaseMetaTileEntity().add3by3Slots(builder); + break; + default: + getBaseMetaTileEntity().add4by4Slots(builder); + break; + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index d0752d9f0d..98164c6863 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -7,16 +7,21 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDL import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DUCTTAPE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MAINTENANCE; +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.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.gui.GT_Container_2by2; -import gregtech.api.gui.GT_Container_MaintenanceHatch; -import gregtech.api.gui.GT_GUIContainer_2by2; -import gregtech.api.gui.GT_GUIContainer_MaintenanceHatch; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; @@ -28,13 +33,12 @@ import ic2.core.item.ItemToolbox; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; -public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch { +public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch implements IAddUIWidgets { private static ItemStack[] sAutoMaintenanceInputs; public boolean mWrench = false, mScrewdriver = false, @@ -173,27 +177,15 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch if (--tStack.stackSize == 0) { aPlayer.inventory.mainInventory[aPlayer.inventory.currentItem] = null; } - } else aBaseMetaTileEntity.openGUI(aPlayer); + } else GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } else { - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } return true; } return false; } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mAuto) return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - return new GT_Container_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); - } - public void updateSlots() { for (int i = 0; i < mInventory.length; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; @@ -311,8 +303,8 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } private void applyToolbox(ItemStack aStack, EntityPlayer aPlayer) { - ItemToolbox aToolbox = (ItemToolbox) aStack.getItem(); - IHasGui aToolboxGUI = aToolbox.getInventory(aPlayer, aStack); + final ItemToolbox aToolbox = (ItemToolbox) aStack.getItem(); + final IHasGui aToolboxGUI = aToolbox.getInventory(aPlayer, aStack); for (int i = 0; i < aToolboxGUI.getSizeInventory(); i++) { if (aToolboxGUI.getStackInSlot(i) != null) { onToolClick(aToolboxGUI.getStackInSlot(i), aPlayer, aToolboxGUI); @@ -341,4 +333,43 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } return false; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (mAuto) { + getBaseMetaTileEntity().add2by2Slots(builder); + } else { + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.SLOT_MAINTENANCE) + .setPos(78, 33) + .setSize(20, 20)) + .widget( + new SlotWidget(BaseSlot.empty()) { + @Override + public boolean handleDragAndDrop(ItemStack draggedStack, int button) { + return false; + } + + @Override + protected void phantomClick(ClickData clickData, ItemStack cursorStack) { + if (cursorStack == null) return; + onToolClick(cursorStack, getContext().getPlayer()); + if (cursorStack.stackSize < 1) { + getContext().getPlayer().inventory.setItemStack(null); + } + if (getContext().getPlayer() instanceof EntityPlayerMP) { + ((EntityPlayerMP) getContext().getPlayer()).updateHeldItem(); + } + } + }.setBackground(GT_UITextures.TRANSPARENT).setPos(79, 34)) + .widget(new TextWidget("Click with Tool to repair.") + .setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(8, 12)); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index d65370901b..3e1b39c1fd 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -38,12 +38,28 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { super(aID, aName, aNameRegional, aTier, 0, ""); } + public GT_MetaTileEntity_Hatch_Muffler( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { this(aName, aTier, new String[] {aDescription}, aTextures); } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); + this(aName, aTier, 0, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Muffler( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); setInValidFacings(ForgeDirection.DOWN); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java index 3d4b24ef93..66c5401bd7 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java @@ -2,21 +2,27 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_INPUT_HATCH_2x2; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_2by2_Fluid; -import gregtech.api.gui.GT_GUIContainer_2by2_Fluid; +import gregtech.api.interfaces.IFluidAccess; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; +import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_Input { +public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_Input implements IAddUIWidgets { public FluidStack[] mStoredFluid; public int mCapacityPer; @@ -62,6 +68,11 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ } } + @Override + public boolean displaysStackSize() { + return true; + } + public FluidStack[] getStoredFluid() { return mStoredFluid; } @@ -245,16 +256,6 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_2by2_Fluid(aPlayerInventory, aBaseMetaTileEntity, "Quadruple Input Hatch"); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_2by2_Fluid(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && mStoredFluid != null) { for (int i = 0; i < getMaxType(); i++) { @@ -274,11 +275,89 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public void updateFluidDisplayItem() { for (int i = 0; i < 4; i++) { - if (getFluid(i) == null || getFluid(i).amount <= 0) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[i], true, true)) mInventory[i] = null; - } else { - mInventory[i] = GT_Utility.getFluidDisplayStack(getFluid(i), true, !displaysStackSize()); - } + updateFluidDisplayItem(i); + } + } + + public void updateFluidDisplayItem(int index) { + if (getFluid(index) == null || getFluid(index).amount <= 0) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[index], true, true)) mInventory[index] = null; + } else { + mInventory[index] = GT_Utility.getFluidDisplayStack(getFluid(index), true, !displaysStackSize()); + } + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final int SLOT_NUMBER = 4; + final Pos2d[] positions = new Pos2d[] { + new Pos2d(70, 25), new Pos2d(88, 25), new Pos2d(70, 43), new Pos2d(88, 43), + }; + + for (int i = 0; i < SLOT_NUMBER; i++) { + final int slotId = i; + builder.widget(new FluidDisplaySlotWidget(inventoryHandler, slotId) + .setFluidAccessConstructor(() -> constructFluidAccess(slotId)) + .setIHasFluidDisplay(this) + .setCanDrain(true) + .setCanFill(!isDrainableStackSeparate()) + .setActionRealClick(FluidDisplaySlotWidget.Action.TRANSFER) + .setBeforeRealClick((clickData, widget) -> { + if (NetworkUtils.isClient()) { + // propagate display item content to actual fluid stored in this tank + setFluid( + GT_Utility.getFluidFromDisplayStack( + widget.getMcSlot().getStack()), + slotId); + } + ItemStack tStackHeld = + widget.getContext().getPlayer().inventory.getItemStack(); + FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackHeld, true); + return constructFluidAccess(slotId).isMatch(tFluidHeld, slotId); + }) + .setUpdateFluidDisplayItem(() -> updateFluidDisplayItem(slotId)) + .setBackground(ModularUITextures.FLUID_SLOT) + .setPos(positions[slotId])); + } + } + + protected MultiFluidAccess constructFluidAccess(int aSlot) { + return new MultiFluidAccess(this, aSlot); + } + + protected static class MultiFluidAccess implements IFluidAccess { + private final GT_MetaTileEntity_Hatch_MultiInput mTank; + private final int mSlot; + + public MultiFluidAccess(GT_MetaTileEntity_Hatch_MultiInput aTank, int aSlot) { + this.mTank = aTank; + this.mSlot = aSlot; + } + + public boolean isMatch(FluidStack stack, int slot) { + if (!mTank.hasFluid(stack)) return true; + if (stack == null) return true; + return stack.equals(mTank.getFluid(slot)); + } + + @Override + public void set(FluidStack stack) { + mTank.setFluid(stack, mSlot); + } + + @Override + public FluidStack get() { + return mTank.getFluid(mSlot); + } + + @Override + public int getCapacity() { + return mTank.getCapacity(); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index dabdd7dbb8..11ffa6e802 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -3,19 +3,27 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.GT_Mod; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IFluidLockable; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import gregtech.common.gui.GT_Container_OutputHatch; -import gregtech.common.gui.GT_GUIContainer_OutputHatch; +import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; import java.lang.ref.WeakReference; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -23,7 +31,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch implements IFluidLockable { +public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch implements IFluidLockable, IAddUIWidgets { private String lockedFluidName = null; private WeakReference<EntityPlayer> playerThatLockedfluid = null; public byte mMode = 0; @@ -97,8 +105,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -181,17 +188,21 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl return false; } + public int getLockedDisplaySlot() { + return 3; + } + @Override public void updateFluidDisplayItem() { super.updateFluidDisplayItem(); - if (lockedFluidName == null || mMode < 8) mInventory[3] = null; + if (lockedFluidName == null || mMode < 8) mInventory[getLockedDisplaySlot()] = null; else { FluidStack tLockedFluid = FluidRegistry.getFluidStack(lockedFluidName, 1); // Because getStackDisplaySlot() only allow return one int, this place I only can manually set. if (tLockedFluid != null) { - mInventory[3] = GT_Utility.getFluidDisplayStack(tLockedFluid, false, true); + mInventory[getLockedDisplaySlot()] = GT_Utility.getFluidDisplayStack(tLockedFluid, false, true); } else { - mInventory[3] = null; + mInventory[getLockedDisplaySlot()] = null; } } } @@ -199,17 +210,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl @Override public boolean isValidSlot(int aIndex) { // Because getStackDisplaySlot() only allow return one int, this place I only can manually set. - return aIndex != getStackDisplaySlot() && aIndex != 3; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_OutputHatch(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_OutputHatch(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + return aIndex != getStackDisplaySlot() && aIndex != getLockedDisplaySlot(); } @Override @@ -464,4 +465,48 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl .getUnlocalizedName())) }; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(98, 16) + .setSize(71, 45)) + .widget(new FluidDisplaySlotWidget(inventoryHandler, getLockedDisplaySlot()) + .setIHasFluidDisplay(this) + .setActionRealClick(FluidDisplaySlotWidget.Action.LOCK) + .setActionDragAndDrop(FluidDisplaySlotWidget.Action.LOCK) + .setBeforeClick((clickData, widget) -> { + if (NetworkUtils.isClient()) { + // propagate display item content to actual fluid stored in this tank + setDrainableStack( + GT_Utility.getFluidFromDisplayStack(mInventory[getStackDisplaySlot()])); + } + return true; + }) + .setBackground(GT_UITextures.TRANSPARENT) + .setPos(149, 41)) + .widget(new TextWidget("Locked Fluid") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(101, 20)) + .widget(TextWidget.dynamicString(() -> { + ItemStack lockedDisplayStack = mInventory[getLockedDisplaySlot()]; + return lockedDisplayStack == null ? "None" : lockedDisplayStack.getDisplayName(); + }) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setTextAlignment(Alignment.CenterLeft) + .setMaxWidth(65) + .setPos(101, 30)) + // #updateFluidDisplayItem invalidates locked fluid slot + // if lockedFluidName == null or mMode is incorrect + .widget(new FakeSyncWidget.StringSyncer(() -> lockedFluidName, val -> lockedFluidName = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> mMode, val -> mMode = val)); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index 5b08f7ae69..ad1c799708 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -4,20 +4,22 @@ import static gregtech.api.enums.Textures.BlockIcons.ITEM_OUT_SIGN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.GT_Mod; -import gregtech.api.gui.*; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; import gregtech.api.util.extensions.ArrayExt; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { +public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch implements IAddUIWidgets { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { this(aID, aName, aNameRegional, aTier, getSlots(aTier)); } @@ -101,39 +103,10 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 1: - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 2: - return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - default: - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 1: - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 2: - return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - default: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - } - } - /** * Attempt to store as many items as possible into the internal inventory of this output bus. * If you need atomicity you should use {@link gregtech.api.interfaces.tileentity.IHasInventory#addStackToSlot(int, ItemStack)} @@ -185,7 +158,8 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick & 0x7) == 0) { - IInventory tTileEntity = aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); + final IInventory tTileEntity = + aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTileEntity != null) { moveMultipleItemStacks( aBaseMetaTileEntity, @@ -208,4 +182,27 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { } } } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + switch (mTier) { + case 0: + getBaseMetaTileEntity().add1by1Slot(builder); + break; + case 1: + getBaseMetaTileEntity().add2by2Slots(builder); + break; + case 2: + getBaseMetaTileEntity().add3by3Slots(builder); + break; + default: + getBaseMetaTileEntity().add4by4Slots(builder); + break; + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index bf0ccd5001..c67785664c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -5,12 +5,21 @@ import static mcp.mobius.waila.api.SpecialChars.GREEN; import static mcp.mobius.waila.api.SpecialChars.RED; import static mcp.mobius.waila.api.SpecialChars.RESET; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; -import gregtech.api.gui.GT_Container_MultiMachine; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; @@ -19,13 +28,14 @@ import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; import java.util.ArrayList; import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -36,7 +46,8 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; -public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { +public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity + implements IAddGregtechLogo, IAddUIWidgets { public static boolean disableMaintenance; public boolean mMachine = false, @@ -241,23 +252,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine( - aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); - } - - @Override public byte getTileEntityBaseType() { return 2; } @@ -1261,7 +1260,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { tag.setInteger("maxProgress", mMaxProgresstime); tag.setBoolean("incompleteStructure", (getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0); - IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); + final IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); if (tileEntity != null) { tag.setBoolean("isActive", tileEntity.isActive()); } @@ -1269,7 +1268,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { protected void setMufflers(boolean state) { for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) { - IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity(); + final IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity(); if (iGTTileEntity != null && !iGTTileEntity.isDead()) { iGTTileEntity.setActive(state); } @@ -1286,4 +1285,121 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public List<GT_MetaTileEntity_Hatch> getExoticEnergyHatches() { return mExoticEnergyHatches; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(143, 75)); + final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); + builder.widget(inventorySlot.setPos(151, 4)); + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, inventorySlot); + builder.widget(screenElements); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) {} + + protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { + screenElements.setSynced(false).setSpace(0).setPos(10, 7); + + screenElements + .widget(new TextWidget(GT_Utility.trans("132", "Pipe is loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mWrench)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mWrench, val -> mWrench = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("133", "Screws are loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mScrewdriver)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mScrewdriver, val -> mScrewdriver = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("134", "Something is stuck.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mSoftHammer)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mSoftHammer, val -> mSoftHammer = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("135", "Platings are dented.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mHardHammer)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mHardHammer, val -> mHardHammer = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("136", "Circuitry burned out.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mSolderingTool)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mSolderingTool, val -> mSolderingTool = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("137", "That doesn't belong there.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mCrowbar)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mCrowbar, val -> mCrowbar = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mMachine)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mMachine, val -> mMachine = val)); + screenElements.widget(new TextWidget("Too Uncertain.") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> (getBaseMetaTileEntity().getErrorDisplayID() & 128) != 0)); + screenElements.widget(new TextWidget("Invalid Parameters.") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> (getBaseMetaTileEntity().getErrorDisplayID() & 256) != 0)); + + screenElements + .widget(new TextWidget(GT_Utility.trans("139", "Hit with Soft Mallet")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 + && !getBaseMetaTileEntity().isActive())) + .widget(new FakeSyncWidget.IntegerSyncer( + () -> getBaseMetaTileEntity().getErrorDisplayID(), + val -> getBaseMetaTileEntity().setErrorDisplayID(val))) + .widget(new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isActive(), + val -> getBaseMetaTileEntity().setActive(val))); + screenElements.widget(new TextWidget(GT_Utility.trans("140", "to (re-)start the Machine")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 + && !getBaseMetaTileEntity().isActive())); + screenElements.widget(new TextWidget(GT_Utility.trans("141", "if it doesn't start.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 + && !getBaseMetaTileEntity().isActive())); + screenElements.widget(new TextWidget(GT_Utility.trans("142", "Running perfectly.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 + && getBaseMetaTileEntity().isActive())); + + screenElements.widget(new TextWidget(GT_Utility.trans("143", "Missing Mining Pipe")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> { + if (getBaseMetaTileEntity().getErrorDisplayID() == 0 + && this instanceof GT_MetaTileEntity_DrillerBase) { + final ItemStack tItem = inventorySlot.getMcSlot().getStack(); + return tItem == null + || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L)); + } + return false; + })); + screenElements.widget(new TextWidget(GT_Utility.trans("144", "Missing Turbine Rotor")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> { + if (getBaseMetaTileEntity().getErrorDisplayID() == 0 + && this instanceof GT_MetaTileEntity_LargeTurbine) { + final ItemStack tItem = inventorySlot.getMcSlot().getStack(); + return tItem == null + || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE + && tItem.getItemDamage() >= 170 + && tItem.getItemDamage() <= 177); + } + return false; + })); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java index 44d40e5a67..f146b39635 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java @@ -1,14 +1,24 @@ package gregtech.api.metatileentity.implementations; -import gregtech.api.gui.GT_Container_SpecialFilter; -import gregtech.api.gui.GT_GUIContainer_SpecialFilter; +import com.gtnewhorizons.modularui.api.drawable.Text; +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.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; +import gregtech.api.util.GT_Utility; +import java.util.Collections; +import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_Buffer { +public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_Buffer implements IAddUIWidgets { public static final int BUFFER_SLOT_COUNT = 9; public static final int SPECIAL_SLOT_INDEX = 9; public boolean bNBTAllowed = false; @@ -35,16 +45,6 @@ public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_ return aIndex < 9; } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_SpecialFilter(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_SpecialFilter(aPlayerInventory, aBaseMetaTileEntity); - } - public abstract void clickTypeIcon(boolean aRightClick, ItemStack aHandStack); @Override @@ -69,4 +69,87 @@ public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_ } protected abstract boolean isStackAllowed(ItemStack aStack); + + protected List<Text> getEmptySlotTooltip() { + return null; + } + + protected List<String> getItemExtraTooltip() { + return null; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + addEmitEnergyButton(builder); + addEmitRedstoneButton(builder); + addInvertRedstoneButton(builder); + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bInvertFilter = !bInvertFilter; + if (bInvertFilter) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("124", "Invert Filter")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), + GT_Utility.trans("125", "Don't invert Filter")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_INVERT_FILTER) + .setPos(61, 62) + .setSize(18, 18)) + .widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + bNBTAllowed = !bNBTAllowed; + if (bNBTAllowed) { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("126", "Ignore NBT")); + } else { + GT_Utility.sendChatToPlayer( + widget.getContext().getPlayer(), GT_Utility.trans("127", "NBT has to match")); + } + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_NBT) + .setPos(79, 62) + .setSize(18, 18)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_ARROW_24_WHITE.apply(27, false)) + .setPos(6, 19) + .setSize(27, 24)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_ARROW_24_BLUE.apply(42, true)) + .setPos(53, 19) + .setSize(42, 24)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_ARROW_24_RED.apply(19, true)) + .setPos(152, 19) + .setSize(19, 24)) + .widget( + new SlotWidget(BaseSlot.phantom(inventoryHandler, 9)) { + @Override + protected void phantomClick(ClickData clickData, ItemStack cursorStack) { + clickTypeIcon(clickData.mouseButton != 0, cursorStack); + } + + @Override + public void buildTooltip(List<Text> tooltip) { + if (getEmptySlotTooltip() != null) { + tooltip.addAll(getEmptySlotTooltip()); + } + super.buildTooltip(tooltip); + } + + @Override + public List<String> getExtraTooltip() { + if (getItemExtraTooltip() != null) { + return getItemExtraTooltip(); + } + return Collections.emptyList(); + } + }.disableShiftInsert().setPos(34, 22).setBackground(GT_UITextures.BUTTON_STANDARD)) + .widget(SlotGroup.ofItemHandler(inventoryHandler, 3) + .endAtSlot(8) + .build() + .setPos(97, 4)); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java index a4d6fc0e6b..4b01454a02 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java @@ -1,7 +1,13 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.GT; +import static gregtech.api.metatileentity.BaseTileEntity.BATTERY_SLOT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.BATTERY_SLOT_TOOLTIP_ALT; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; @@ -111,4 +117,36 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit * @param aTextures is the optional Array you can give to the Constructor. */ public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); + + protected SlotWidget createChargerSlot(int x, int y) { + final String batterySlotTooltipKey; + final Object[] batterySlotTooltipArgs; + final String pTier1 = powerTierName(mTier); + if (mTier == GT_Values.VN.length - 1) { + batterySlotTooltipKey = BATTERY_SLOT_TOOLTIP_ALT; + batterySlotTooltipArgs = new String[] {pTier1}; + } else { + batterySlotTooltipKey = BATTERY_SLOT_TOOLTIP; + batterySlotTooltipArgs = new String[] {pTier1, powerTierName((byte) (mTier + 1))}; + } + return createChargerSlot(x, y, batterySlotTooltipKey, batterySlotTooltipArgs); + } + + protected SlotWidget createChargerSlot(int x, int y, String tooltipKey, Object[] tooltipArgs) { + return (SlotWidget) new SlotWidget(inventoryHandler, rechargerSlotStartIndex()) + .disableShiftInsert() + .setGTTooltip(() -> mTooltipCache.getData(tooltipKey, tooltipArgs)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_CHARGER) + .setPos(x, y); + } + + /** + * Apply proper coloration to a machine's power tier short name + * @param machineTier + * @return colored power tier short name + */ + private String powerTierName(byte machineTier) { + return GT_Values.TIER_COLORS[machineTier] + GT_Values.VN[machineTier]; + } } diff --git a/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java b/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java index 385ae310f1..8161680b1e 100644 --- a/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java +++ b/src/main/java/gregtech/api/multitileentity/base/BaseMultiTileEntity.java @@ -251,6 +251,11 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity } @Override + public boolean useModularUI() { + return true; + } + + @Override public long getTimer() { return 0; } @@ -1373,4 +1378,9 @@ public abstract class BaseMultiTileEntity extends CoverableTileEntity return getCoverBehaviorAtSideNew(aSide) .letsItemsOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), aSlot, this); } + + @Override + public ItemStack getStackForm(long aAmount) { + return new ItemStack(Item.getItemById(getMultiTileEntityRegistryID()), (int) aAmount, getMultiTileEntityID()); + } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java index 9f32ad4bae..62ff6bd7e9 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java +++ b/src/main/java/gregtech/api/net/GT_Packet_GtTileEntityGuiRequest.java @@ -2,6 +2,7 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.GT_Proxy; import io.netty.buffer.ByteBuf; @@ -103,7 +104,11 @@ public class GT_Packet_GtTileEntityGuiRequest extends GT_Packet_New { parentGuiId); GT_Values.NW.sendToPlayer(packet, player); } else if (guiId == 0) { - gtTile.openGUI(player); + if (gtTile.getMetaTileEntity() != null && gtTile.getMetaTileEntity().useModularUI()) { + GT_UIInfos.openGTTileEntityUI(gtTile, player); + } else { + gtTile.openGUI(player); + } } } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java index 0561b18ac1..eff095b0fc 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java +++ b/src/main/java/gregtech/api/net/GT_Packet_SetConfigurationCircuit.java @@ -2,9 +2,10 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.network.ByteBufUtils; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasInventory; +import gregtech.api.metatileentity.BaseTileEntity; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; import io.netty.buffer.ByteBuf; @@ -35,6 +36,10 @@ public class GT_Packet_SetConfigurationCircuit extends GT_Packet_New { this(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), circuit); } + public GT_Packet_SetConfigurationCircuit(BaseTileEntity tile, ItemStack circuit) { + this(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), circuit); + } + public GT_Packet_SetConfigurationCircuit(int x, short y, int z, ItemStack circuit) { super(false); @@ -84,18 +89,18 @@ public class GT_Packet_SetConfigurationCircuit extends GT_Packet_New { @Override public void process(IBlockAccess aWorld) { - World world = DimensionManager.getWorld(dimId); + final World world = DimensionManager.getWorld(dimId); if (world == null) return; - TileEntity tile = world.getTileEntity(mX, mY, mZ); - if (!(tile instanceof IGregTechTileEntity) || ((IGregTechTileEntity) tile).isDead()) return; - IMetaTileEntity mte = ((IGregTechTileEntity) tile).getMetaTileEntity(); - if (!(mte instanceof IConfigurationCircuitSupport)) return; - IConfigurationCircuitSupport machine = (IConfigurationCircuitSupport) mte; + + final TileEntity tile = world.getTileEntity(mX, mY, mZ); + if (!(tile instanceof BaseTileEntity) || ((BaseTileEntity) tile).isDead()) return; + + final IConfigurationCircuitSupport machine = ((BaseTileEntity) tile).getConfigurationCircuitSupport(); + if (machine == null) return; if (!machine.allowSelectCircuit()) return; machine.getConfigurationCircuits().stream() .filter(stack -> GT_Utility.areStacksEqual(stack, circuit)) .findFirst() - .ifPresent(stack -> - ((IGregTechTileEntity) tile).setInventorySlotContents(machine.getCircuitSlot(), stack)); + .ifPresent(stack -> ((IHasInventory) tile).setInventorySlotContents(machine.getCircuitSlot(), stack)); } } diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java index e190648bef..65194a7390 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntityCoverGUI.java @@ -188,35 +188,23 @@ public class GT_Packet_TileEntityCoverGUI extends GT_Packet_New { IGregTechTileEntity gtTile = ((IGregTechTileEntity) tile); gtTile.setCoverDataAtSide(side, coverData); // Set it client side to read later. - GuiScreen gui = (GuiScreen) getCoverGUI(side, thePlayer, thePlayer.worldObj, gtTile); - // If it's one of this mod's covers, tell it to exit to the GUI with the specified ID (-1 is ignored) - if (gui instanceof GT_GUICover) { - ((GT_GUICover) gui).setParentGuiId(parentGuiId); + GT_CoverBehaviorBase<?> cover = gtTile.getCoverBehaviorAtSideNew(side); + if (cover.hasCoverGUI()) { + GuiScreen gui = (GuiScreen) cover.getClientGUI( + side, + gtTile.getCoverIDAtSide(side), + gtTile.getComplexCoverDataAtSide(side), + gtTile, + thePlayer, + thePlayer.worldObj); + // If it's one of this mod's covers, tell it to exit to the GUI with the specified ID (-1 is + // ignored) + if (gui instanceof GT_GUICover) { + ((GT_GUICover) gui).setParentGuiId(parentGuiId); + } + Minecraft.getMinecraft().displayGuiScreen(gui); } - Minecraft.getMinecraft().displayGuiScreen(gui); } } } - - /** - * Gets the specified cover's GUI object, if one exists - * @param aSide Block side (0 through 5) - * @param aPlayer Current player - * @param aWorld Current world - * @param aGtTile IGregTechTileEntity instance - * @return The specified cover's GUI, if one exists - */ - private Object getCoverGUI(byte aSide, EntityPlayer aPlayer, World aWorld, IGregTechTileEntity aGtTile) { - GT_CoverBehaviorBase<?> cover = aGtTile.getCoverBehaviorAtSideNew(aSide); - if (cover.hasCoverGUI()) { - return cover.getClientGUI( - aSide, - aGtTile.getCoverIDAtSide(aSide), - aGtTile.getComplexCoverDataAtSide(aSide), - aGtTile, - aPlayer, - aWorld); - } - return null; - } } diff --git a/src/main/java/gregtech/api/objects/GT_Cover_None.java b/src/main/java/gregtech/api/objects/GT_Cover_None.java index dac48449d1..e0cd5aa061 100644 --- a/src/main/java/gregtech/api/objects/GT_Cover_None.java +++ b/src/main/java/gregtech/api/objects/GT_Cover_None.java @@ -7,7 +7,6 @@ import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.ISerializableObject; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; public class GT_Cover_None extends GT_CoverBehavior { @@ -161,17 +160,6 @@ public class GT_Cover_None extends GT_CoverBehavior { } @Override - protected Object getClientGUIImpl( - byte aSide, - int aCoverID, - ISerializableObject.LegacyCoverData aCoverVariable, - ICoverable aTileEntity, - EntityPlayer aPlayer, - World aWorld) { - return null; - } - - @Override protected boolean onCoverRemovalImpl( byte aSide, int aCoverID, diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java index 3bbb4f9ae5..f3b8f7a9fb 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java @@ -3,6 +3,7 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.E; import gregtech.api.enums.GT_Values; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.net.GT_Packet_TileEntityCoverGUI; @@ -28,7 +29,7 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl super(ISerializableObject.LegacyCoverData.class, coverTexture); } - private static int convert(ISerializableObject.LegacyCoverData data) { + protected static int convert(ISerializableObject.LegacyCoverData data) { return data == null ? 0 : data.get(); } @@ -106,6 +107,7 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl return onCoverShiftRightclick(aSide, aCoverID, convert(aCoverVariable), aTileEntity, aPlayer); } + @Deprecated @Override protected Object getClientGUIImpl( byte aSide, @@ -318,15 +320,20 @@ public abstract class GT_CoverBehavior extends GT_CoverBehaviorBase<ISerializabl if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; mPlayerNotified = false; - GT_Values.NW.sendToPlayer( - new GT_Packet_TileEntityCoverGUI( - aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), - (EntityPlayerMP) aPlayer); + if (useModularUI()) { + GT_UIInfos.openCoverUI(aTileEntity, aPlayer, aSide); + } else { + GT_Values.NW.sendToPlayer( + new GT_Packet_TileEntityCoverGUI( + aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), + (EntityPlayerMP) aPlayer); + } return true; } return false; } + @Deprecated public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { return null; } diff --git a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java index 1092a24307..b793a9b489 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehaviorBase.java @@ -2,11 +2,22 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.E; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.gui.GT_GUIColorOverride; +import gregtech.api.gui.modularui.GT_CoverUIBuildContext; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.net.GT_Packet_TileEntityCoverGUI; import gregtech.api.objects.GT_ItemStack; +import java.util.function.Supplier; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -34,6 +45,7 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { protected GT_CoverBehaviorBase(Class<T> typeToken, ITexture coverTexture) { this.typeToken = typeToken; this.coverFGTexture = coverTexture; + this.colorOverride = new GT_GUIColorOverride(guiTexturePath); } public abstract T createDataObject(int aLegacyData); @@ -216,6 +228,7 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { return onCoverShiftRightClickImpl(aSide, aCoverID, forceCast(aCoverVariable), aTileEntity, aPlayer); } + @Deprecated public final Object getClientGUI( byte aSide, int aCoverID, @@ -404,6 +417,136 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { } // endregion + // region UI stuff + + protected GT_TooltipDataCache mTooltipCache = new GT_TooltipDataCache(); + protected GT_GUIColorOverride colorOverride; + private static final String guiTexturePath = "gregtech:textures/gui/GuiCover.png"; + + /** + * For back compatibility, you need to override this if this cover uses ModularUI. + */ + public boolean useModularUI() { + return false; + } + + public ModularWindow createWindow(GT_CoverUIBuildContext buildContext) { + return new UIFactory(buildContext).createWindow(); + } + + /** + * Creates {@link ModularWindow} for this cover. + * This is separated from base class, as attaching the same covers in different sides of the same tile + * needs different UI with different context. + */ + protected class UIFactory { + + private final GT_CoverUIBuildContext uiBuildContext; + + public UIFactory(GT_CoverUIBuildContext buildContext) { + this.uiBuildContext = buildContext; + } + + public ModularWindow createWindow() { + ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.setGuiTint(getUIBuildContext().getGuiColorization()); + if (doesBindPlayerInventory() && !getUIBuildContext().isAnotherWindow()) { + builder.bindPlayerInventory(getUIBuildContext().getPlayer()); + } + addTitleToUI(builder); + addUIWidgets(builder); + if (getUIBuildContext().isAnotherWindow()) { + builder.widget(ButtonWidget.closeWindowButton(true).setPos(getGUIWidth() - 15, 3)); + } + return builder.build(); + } + + /** + * Override this to add widgets for your UI. + */ + protected void addUIWidgets(ModularWindow.Builder builder) {} + + public GT_CoverUIBuildContext getUIBuildContext() { + return uiBuildContext; + } + + /** + * Can return null when cover data is invalid e.g. tile is broken or cover is removed + */ + @Nullable + public T getCoverData() { + if (isCoverValid()) { + return forceCast(getUIBuildContext() + .getTile() + .getComplexCoverDataAtSide(getUIBuildContext().getCoverSide())); + } else { + return null; + } + } + + public boolean setCoverData(T data) { + if (isCoverValid()) { + getUIBuildContext() + .getTile() + .receiveCoverData( + getUIBuildContext().getCoverSide(), + getUIBuildContext().getCoverID(), + data, + getUIBuildContext().getPlayer() instanceof EntityPlayerMP + ? (EntityPlayerMP) getUIBuildContext().getPlayer() + : null); + return true; + } else { + return false; + } + } + + public boolean isCoverValid() { + return !getUIBuildContext().getTile().isDead() + && getUIBuildContext() + .getTile() + .getCoverBehaviorAtSideNew( + getUIBuildContext().getCoverSide()) + != GregTech_API.sNoBehavior; + } + + protected void addTitleToUI(ModularWindow.Builder builder) { + ItemStack coverItem = GT_Utility.intToStack(getUIBuildContext().getCoverID()); + if (coverItem != null) { + builder.widget(new ItemDrawable(coverItem) + .asWidget() + .setPos(5, 5) + .setSize(16, 16)) + .widget(new TextWidget(coverItem.getDisplayName()) + .setDefaultColor(COLOR_TITLE.get()) + .setPos(25, 9)); + } + } + + protected int getGUIWidth() { + return 176; + } + + protected int getGUIHeight() { + return 107; + } + + protected boolean doesBindPlayerInventory() { + return false; + } + + protected int getTextColorOrDefault(String textType, int defaultColor) { + return colorOverride.getTextColorOrDefault(textType, defaultColor); + } + + protected Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x222222); + protected Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x555555); + protected Supplier<Integer> COLOR_TEXT_WARN = () -> getTextColorOrDefault("text_warn", 0xff0000); + } + + // endregion + // region impl protected Block getFacadeBlockImpl(byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity) { @@ -494,15 +637,20 @@ public abstract class GT_CoverBehaviorBase<T extends ISerializableObject> { byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer) { if (hasCoverGUI() && aPlayer instanceof EntityPlayerMP) { lastPlayer = aPlayer; - GT_Values.NW.sendToPlayer( - new GT_Packet_TileEntityCoverGUI( - aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), - (EntityPlayerMP) aPlayer); + if (useModularUI()) { + GT_UIInfos.openCoverUI(aTileEntity, aPlayer, aSide); + } else { + GT_Values.NW.sendToPlayer( + new GT_Packet_TileEntityCoverGUI( + aSide, aCoverID, aCoverVariable, aTileEntity, (EntityPlayerMP) aPlayer), + (EntityPlayerMP) aPlayer); + } return true; } return false; } + @Deprecated protected Object getClientGUIImpl( byte aSide, int aCoverID, T aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, World aWorld) { return null; diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index a498754451..40ba7fe60f 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -3,11 +3,26 @@ package gregtech.api.util; import static gregtech.api.enums.GT_Values.*; import codechicken.nei.PositionedStack; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; +import gnu.trove.map.TByteObjectMap; +import gnu.trove.map.hash.TByteObjectHashMap; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.SteamTexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.objects.GT_FluidStack; @@ -15,11 +30,15 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.extensions.ArrayExt; +import gregtech.common.gui.modularui.UIHelper; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator; -import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack; import ic2.core.Ic2Items; +import java.awt.*; import java.util.*; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; +import javax.annotation.Nullable; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -30,6 +49,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -721,7 +742,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } /** - * Use {@link GT_Recipe_Map#getInputPositionedStacks(GT_Recipe)} instead + * Use {@link GT_Recipe_Map#getItemInputPositions} or {@link GT_Recipe_Map#getSpecialItemPosition} or {@link GT_Recipe_Map#getFluidInputPositions} instead */ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated @@ -730,7 +751,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } /** - * Use {@link GT_Recipe_Map#getOutputPositionedStacks(GT_Recipe)} instead + * Use {@link GT_Recipe_Map#getItemOutputPositions} or {@link GT_Recipe_Map#getFluidOutputPositions} instead */ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated @@ -974,6 +995,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } + @SuppressWarnings("StaticInitializerReferencesSubClass") public static class GT_Recipe_Map { /** * Contains all Recipe Maps @@ -985,117 +1007,139 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final Map<String, GT_Recipe_Map> sIndexedMappings = new HashMap<>(); public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map( - new HashSet<>(500), - "gt.recipe.orewasher", - "Ore Washing Plant", - null, - RES_PATH_GUI + "basicmachines/OreWasher", - 1, - 3, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(500), + "gt.recipe.orewasher", + "Ore Washing Plant", + null, + RES_PATH_GUI + "basicmachines/OreWasher", + 1, + 3, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_BATH, ProgressBar.Direction.CIRCULAR_CW); public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map( - new HashSet<>(1000), - "gt.recipe.thermalcentrifuge", - "Thermal Centrifuge", - null, - RES_PATH_GUI + "basicmachines/ThermalCentrifuge", - 1, - 3, - 1, - 0, - 2, - E, - 1, - E, - true, - true); + new HashSet<>(1000), + "gt.recipe.thermalcentrifuge", + "Thermal Centrifuge", + null, + RES_PATH_GUI + "basicmachines/ThermalCentrifuge", + 1, + 3, + 1, + 0, + 2, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map( - new HashSet<>(750), - "gt.recipe.compressor", - "Compressor", - null, - RES_PATH_GUI + "basicmachines/Compressor", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(750), + "gt.recipe.compressor", + "Compressor", + null, + RES_PATH_GUI + "basicmachines/Compressor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_COMPRESSOR) + .setProgressBar(GT_UITextures.PROGRESSBAR_COMPRESS, ProgressBar.Direction.RIGHT) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_COMPRESSOR_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_COMPRESS_STEAM); public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map( - new HashSet<>(250), - "gt.recipe.extractor", - "Extractor", - null, - RES_PATH_GUI + "basicmachines/Extractor", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(250), + "gt.recipe.extractor", + "Extractor", + null, + RES_PATH_GUI + "basicmachines/Extractor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_EXTRACT_STEAM); public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler( - new HashSet<>(0), - "ic.recipe.recycler", - "Recycler", - "ic2.recycler", - RES_PATH_GUI + "basicmachines/Recycler", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - false); + new HashSet<>(0), + "ic.recipe.recycler", + "Recycler", + "ic2.recycler", + RES_PATH_GUI + "basicmachines/Recycler", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_RECYCLE) + .setProgressBar(GT_UITextures.PROGRESSBAR_RECYCLE, ProgressBar.Direction.CIRCULAR_CW); public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace( - new HashSet<>(0), - "mc.recipe.furnace", - "Furnace", - "smelting", - RES_PATH_GUI + "basicmachines/E_Furnace", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - false); + new HashSet<>(0), + "mc.recipe.furnace", + "Furnace", + "smelting", + RES_PATH_GUI + "basicmachines/E_Furnace", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_FURNACE) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_FURNACE_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_ARROW_STEAM); public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave( - new HashSet<>(0), - "gt.recipe.microwave", - "Microwave", - "smelting", - RES_PATH_GUI + "basicmachines/E_Furnace", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - false); + new HashSet<>(0), + "gt.recipe.microwave", + "Microwave", + "smelting", + RES_PATH_GUI + "basicmachines/E_Furnace", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + false) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_FURNACE) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); /** Set {@code aSpecialValue = -100} to bypass the disassembler tier check and default recipe duration. */ public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map( @@ -1113,590 +1157,712 @@ public class GT_Recipe implements Comparable<GT_Recipe> { 1, E, true, - false); + false) { + @Override + public IDrawable getOverlayForSlot(boolean isFluid, boolean isOutput, int index, boolean isSpecial) { + if (isOutput) { + switch (index) { + case 0: + case 2: + case 6: + case 8: + return GT_UITextures.OVERLAY_SLOT_CIRCUIT; + case 4: + return GT_UITextures.OVERLAY_SLOT_WRENCH; + } + } + return super.getOverlayForSlot(isFluid, isOutput, index, isSpecial); + } + }.setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_WRENCH) + .setProgressBar(GT_UITextures.PROGRESSBAR_ASSEMBLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map( - new HashSet<>(300), - "gt.recipe.scanner", - "Scanner", - null, - RES_PATH_GUI + "basicmachines/Scanner", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(300), + "gt.recipe.scanner", + "Scanner", + null, + RES_PATH_GUI + "basicmachines/Scanner", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_MICROSCOPE) + .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map( - new HashSet<>(200), - "gt.recipe.rockbreaker", - "Rock Breaker", - null, - RES_PATH_GUI + "basicmachines/RockBreaker", - 1, - 1, - 0, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(200), + "gt.recipe.rockbreaker", + "Rock Breaker", + null, + RES_PATH_GUI + "basicmachines/RockBreaker", + 2, + 1, + 0, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE) + .setProgressBar(GT_UITextures.PROGRESSBAR_MACERATE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map( - new HashSet<>(1000), - "gt.recipe.byproductlist", - "Ore Byproduct List", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 6, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(1000), + "gt.recipe.byproductlist", + "Ore Byproduct List", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 6, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sReplicatorFakeRecipes = new ReplicatorFakeMap( - new HashSet<>(100), - "gt.recipe.replicator", - "Replicator", - null, - RES_PATH_GUI + "basicmachines/Replicator", - 0, - 1, - 0, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(100), + "gt.recipe.replicator", + "Replicator", + null, + RES_PATH_GUI + "basicmachines/Replicator", + 0, + 1, + 0, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_UUM) + .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); // public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<>(30), // "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, // true); - public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map( - new HashSet<>(110), - "gt.recipe.fakeAssemblylineProcess", - "Assemblyline Process", - null, - RES_PATH_GUI + "FakeAssemblyline", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - false); + public static final GT_Recipe_Map sAssemblylineVisualRecipes = new GT_Recipe_Map_AssemblyLineFake( + new HashSet<>(110), + "gt.recipe.fakeAssemblylineProcess", + "Assemblyline Process", + null, + RES_PATH_GUI + "FakeAssemblyline", + 16, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_ORB) + .setUsualFluidInputCount(4); public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map( - new HashSet<>(20000), - "gt.recipe.plasmaarcfurnace", - "Plasma Arc Furnace", - null, - RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", - 1, - 4, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(20000), + "gt.recipe.plasmaarcfurnace", + "Plasma Arc Furnace", + null, + RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", + 1, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map( - new HashSet<>(20000), - "gt.recipe.arcfurnace", - "Arc Furnace", - null, - RES_PATH_GUI + "basicmachines/ArcFurnace", - 1, - 4, - 1, - 1, - 3, - E, - 1, - E, - true, - true); + new HashSet<>(20000), + "gt.recipe.arcfurnace", + "Arc Furnace", + null, + RES_PATH_GUI + "basicmachines/ArcFurnace", + 1, + 4, + 1, + 1, + 3, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer( - new HashSet<>(5), - "gt.recipe.printer", - "Printer", - null, - RES_PATH_GUI + "basicmachines/Printer", - 1, - 1, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(5), + "gt.recipe.printer", + "Printer", + null, + RES_PATH_GUI + "basicmachines/Printer", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_PAGE_BLANK) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_PAGE_PRINTED) + .setSlotOverlay(false, false, true, true, GT_UITextures.OVERLAY_SLOT_DATA_STICK) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sSifterRecipes = new GT_Recipe_Map( - new HashSet<>(105), - "gt.recipe.sifter", - "Sifter", - null, - RES_PATH_GUI + "basicmachines/Sifter", - 1, - 9, - 0, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(105), + "gt.recipe.sifter", + "Sifter", + null, + RES_PATH_GUI + "basicmachines/Sifter", + 1, + 9, + 0, + 0, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_SIFT, ProgressBar.Direction.DOWN); public static final GT_Recipe_Map sPressRecipes = new GT_Recipe_Map_FormingPress( - new HashSet<>(300), - "gt.recipe.press", - "Forming Press", - null, - RES_PATH_GUI + "basicmachines/Press", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(300), + "gt.recipe.press", + "Forming Press", + null, + RES_PATH_GUI + "basicmachines/Press", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_PRESS_1) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_PRESS_2) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_PRESS_3) + .setProgressBar(GT_UITextures.PROGRESSBAR_COMPRESS, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sLaserEngraverRecipes = new GT_Recipe_Map( - new HashSet<>(810), - "gt.recipe.laserengraver", - "Precision Laser Engraver", - null, - RES_PATH_GUI + "basicmachines/LaserEngraverNEI", - 2, - 1, - 0, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(810), + "gt.recipe.laserengraver", + "Precision Laser Engraver", + null, + RES_PATH_GUI + "basicmachines/LaserEngraverNEI", + 2, + 1, + 0, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_LENS) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(2) + .setUsualFluidOutputCount(2); public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map( - new HashSet<>(900), - "gt.recipe.mixer", - "Mixer", - null, - RES_PATH_GUI + "basicmachines/Mixer6", - 9, - 4, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(900), + "gt.recipe.mixer", + "Mixer", + null, + RES_PATH_GUI + "basicmachines/Mixer6", + 9, + 4, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_MIXER, ProgressBar.Direction.CIRCULAR_CW); public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map( - new HashSet<>(300), - "gt.recipe.autoclave", - "Autoclave", - null, - RES_PATH_GUI + "basicmachines/Autoclave4", - 2, - 4, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(300), + "gt.recipe.autoclave", + "Autoclave", + null, + RES_PATH_GUI + "basicmachines/Autoclave4", + 2, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setSlotOverlay(false, true, true, GT_UITextures.OVERLAY_SLOT_GEM) + .setSlotOverlay(false, true, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map( - new HashSet<>(50), - "gt.recipe.electromagneticseparator", - "Electromagnetic Separator", - null, - RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", - 1, - 3, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(50), + "gt.recipe.electromagneticseparator", + "Electromagnetic Separator", + null, + RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", + 1, + 3, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_MAGNET, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map( - new HashSet<>(300), - "gt.recipe.polarizer", - "Electromagnetic Polarizer", - null, - RES_PATH_GUI + "basicmachines/Polarizer", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(300), + "gt.recipe.polarizer", + "Electromagnetic Polarizer", + null, + RES_PATH_GUI + "basicmachines/Polarizer", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_MAGNET, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator( - new HashSet<>(16600), - "gt.recipe.macerator", - "Pulverization", - null, - RES_PATH_GUI + "basicmachines/Macerator4", - 1, - 4, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(16600), + "gt.recipe.macerator", + "Pulverization", + null, + RES_PATH_GUI + "basicmachines/Macerator4", + 1, + 4, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_MACERATE, ProgressBar.Direction.RIGHT) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_CRUSHED_ORE_STEAM) + .setSlotOverlaySteam(true, GT_UITextures.OVERLAY_SLOT_DUST_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_MACERATE_STEAM); public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map( - new HashSet<>(2550), - "gt.recipe.chemicalbath", - "Chemical Bath", - null, - RES_PATH_GUI + "basicmachines/ChemicalBath", - 1, - 3, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(2550), + "gt.recipe.chemicalbath", + "Chemical Bath", + null, + RES_PATH_GUI + "basicmachines/ChemicalBath", + 1, + 3, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_BATH, ProgressBar.Direction.CIRCULAR_CW); public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner( - new HashSet<>(2100), - "gt.recipe.fluidcanner", - "Fluid Canning Machine", - null, - RES_PATH_GUI + "basicmachines/FluidCanner", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(2100), + "gt.recipe.fluidcanner", + "Fluid Canning Machine", + null, + RES_PATH_GUI + "basicmachines/FluidCanner", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setProgressBar(GT_UITextures.PROGRESSBAR_CANNER, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map( - new HashSet<>(450), - "gt.recipe.brewer", - "Brewing Machine", - null, - RES_PATH_GUI + "basicmachines/PotionBrewer", - 1, - 0, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(450), + "gt.recipe.brewer", + "Brewing Machine", + null, + RES_PATH_GUI + "basicmachines/PotionBrewer", + 1, + 0, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CAULDRON) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map( - new HashSet<>(10), - "gt.recipe.fluidheater", - "Fluid Heater", - null, - RES_PATH_GUI + "basicmachines/FluidHeater", - 1, - 0, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(10), + "gt.recipe.fluidheater", + "Fluid Heater", + null, + RES_PATH_GUI + "basicmachines/FluidHeater", + 1, + 0, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_HEATER_1) + .setSlotOverlay(true, true, GT_UITextures.OVERLAY_SLOT_HEATER_2) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map( - new HashSet<>(400), - "gt.recipe.distillery", - "Distillery", - null, - RES_PATH_GUI + "basicmachines/Distillery", - 1, - 1, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(400), + "gt.recipe.distillery", + "Distillery", + null, + RES_PATH_GUI + "basicmachines/Distillery", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_BEAKER_1) + .setSlotOverlay(true, true, GT_UITextures.OVERLAY_SLOT_BEAKER_2) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map( - new HashSet<>(50), - "gt.recipe.fermenter", - "Fermenter", - null, - RES_PATH_GUI + "basicmachines/Fermenter", - 0, - 0, - 0, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(50), + "gt.recipe.fermenter", + "Fermenter", + null, + RES_PATH_GUI + "basicmachines/Fermenter", + 0, + 0, + 0, + 1, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sFluidSolidficationRecipes = new GT_Recipe_Map( - new HashSet<>(35000), - "gt.recipe.fluidsolidifier", - "Fluid Solidifier", - null, - RES_PATH_GUI + "basicmachines/FluidSolidifier", - 1, - 1, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(35000), + "gt.recipe.fluidsolidifier", + "Fluid Solidifier", + null, + RES_PATH_GUI + "basicmachines/FluidSolidifier", + 1, + 1, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_MOLD) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sFluidExtractionRecipes = new GT_Recipe_Map( - new HashSet<>(15000), - "gt.recipe.fluidextractor", - "Fluid Extractor", - null, - RES_PATH_GUI + "basicmachines/FluidExtractor", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(15000), + "gt.recipe.fluidextractor", + "Fluid Extractor", + null, + RES_PATH_GUI + "basicmachines/FluidExtractor", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sBoxinatorRecipes = new GT_Recipe_Map( - new HashSet<>(2500), - "gt.recipe.packager", - "Packager", - null, - RES_PATH_GUI + "basicmachines/Packager", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(2500), + "gt.recipe.packager", + "Packager", + null, + RES_PATH_GUI + "basicmachines/Packager", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_BOX) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_BOXED) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sUnboxinatorRecipes = new GT_Recipe_Map_Unboxinator( - new HashSet<>(2500), - "gt.recipe.unpackager", - "Unpackager", - null, - RES_PATH_GUI + "basicmachines/Unpackager", - 1, - 2, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(2500), + "gt.recipe.unpackager", + "Unpackager", + null, + RES_PATH_GUI + "basicmachines/Unpackager", + 1, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_BOXED) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sFusionRecipes = new GT_Recipe_Map( - new HashSet<>(50), - "gt.recipe.fusionreactor", - "Fusion Reactor", - null, - RES_PATH_GUI + "basicmachines/FusionReactor", - 0, - 0, - 0, - 2, - 1, - "Start: ", - 1, - " EU", - true, - true); + new HashSet<>(50), + "gt.recipe.fusionreactor", + "Fusion Reactor", + null, + RES_PATH_GUI + "basicmachines/FusionReactor", + 0, + 0, + 0, + 2, + 1, + "Start: ", + 1, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(2); public static final GT_Recipe_Map sComplexFusionRecipes = new GT_Recipe_Map_ComplexFusion( - new HashSet<>(50), - "gt.recipe.complexfusionreactor", - "Complex Fusion Reactor", - null, - RES_PATH_GUI + "basicmachines/ComplexFusionReactor", - 3, - 0, - 0, - 2, - 1, - "Start: ", - 1, - " EU", - true, - true); + new HashSet<>(50), + "gt.recipe.complexfusionreactor", + "Complex Fusion Reactor", + null, + RES_PATH_GUI + "basicmachines/ComplexFusionReactor", + 3, + 0, + 0, + 2, + 1, + "Start: ", + 1, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(16) + .setUsualFluidOutputCount(16) + .setNEITransferRect(new Rectangle(79, 34, 18, 18)) + .setNEIGregTechLogoPos(80, 61); public static final GT_Recipe_Map sCentrifugeRecipes = new GT_Recipe_Map( - new HashSet<>(1200), - "gt.recipe.centrifuge", - "Centrifuge", - null, - RES_PATH_GUI + "basicmachines/Centrifuge", - 2, - 6, - 0, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(1200), + "gt.recipe.centrifuge", + "Centrifuge", + null, + RES_PATH_GUI + "basicmachines/Centrifuge", + 2, + 6, + 0, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE_FLUID) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sElectrolyzerRecipes = new GT_Recipe_Map( - new HashSet<>(300), - "gt.recipe.electrolyzer", - "Electrolyzer", - null, - RES_PATH_GUI + "basicmachines/Electrolyzer", - 2, - 6, - 0, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(300), + "gt.recipe.electrolyzer", + "Electrolyzer", + null, + RES_PATH_GUI + "basicmachines/Electrolyzer", + 2, + 6, + 0, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_CHARGER) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_CHARGER_FLUID) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sBlastRecipes = new GT_Recipe_Map( - new HashSet<>(800), - "gt.recipe.blastfurnace", - "Blast Furnace", - null, - RES_PATH_GUI + "basicmachines/Default", - 6, - 6, - 1, - 0, - 1, - "Heat Capacity: ", - 1, - " K", - false, - true); - public static final GT_Recipe_Map sPlasmaForgeRecipes = new GT_Recipe_Map_PlasmaForge( - new HashSet<>(20), - "gt.recipe.plasmaforge", - "DTPF", - null, - RES_PATH_GUI + "basicmachines/PlasmaForge", - 1, - 1, - 0, - 0, - 1, - "Heat Capacity: ", - 1, - " K", - false, - true); + new HashSet<>(800), + "gt.recipe.blastfurnace", + "Blast Furnace", + null, + RES_PATH_GUI + "basicmachines/Default", + 6, + 6, + 1, + 0, + 1, + "Heat Capacity: ", + 1, + " K", + false, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map sPlasmaForgeRecipes = new GT_Recipe_Map_LargeNEI( + new HashSet<>(20), + "gt.recipe.plasmaforge", + "DTPF", + null, + RES_PATH_GUI + "basicmachines/PlasmaForge", + 9, + 9, + 0, + 0, + 1, + "Heat Capacity: ", + 1, + " K", + false, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(9) + .setUsualFluidOutputCount(9); public static final GT_Recipe_Map sPrimitiveBlastRecipes = new GT_Recipe_Map( - new HashSet<>(200), - "gt.recipe.primitiveblastfurnace", - "Primitive Blast Furnace", - null, - RES_PATH_GUI + "basicmachines/Default", - 3, - 3, - 1, - 0, - 1, - E, - 1, - E, - false, - true); + new HashSet<>(200), + "gt.recipe.primitiveblastfurnace", + "Primitive Blast Furnace", + null, + RES_PATH_GUI + "basicmachines/Default", + 3, + 3, + 1, + 0, + 1, + E, + 1, + E, + false, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sImplosionRecipes = new GT_Recipe_Map( - new HashSet<>(900), - "gt.recipe.implosioncompressor", - "Implosion Compressor", - null, - RES_PATH_GUI + "basicmachines/Default", - 2, - 2, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(900), + "gt.recipe.implosioncompressor", + "Implosion Compressor", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 2, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_IMPLOSION) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_EXPLOSIVE) + .setProgressBar(GT_UITextures.PROGRESSBAR_COMPRESS, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map( - new HashSet<>(305), - "gt.recipe.vacuumfreezer", - "Vacuum Freezer", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - E, - 1, - E, - false, - true); + new HashSet<>(305), + "gt.recipe.vacuumfreezer", + "Vacuum Freezer", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + E, + 1, + E, + false, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map( - new HashSet<>(1170), - "gt.recipe.chemicalreactor", - "Chemical Reactor", - null, - RES_PATH_GUI + "basicmachines/ChemicalReactor", - 2, - 2, - 1, - 0, - 1, - E, - 1, - E, - true, - true); - public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor(); - public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower(); - public static final GT_Recipe_Map_OilCracker sCrackingRecipes = new GT_Recipe_Map_OilCracker(); + new HashSet<>(1170), + "gt.recipe.chemicalreactor", + "Chemical Reactor", + null, + RES_PATH_GUI + "basicmachines/ChemicalReactor", + 2, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_MOLECULAR_1) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_MOLECULAR_2) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_MOLECULAR_3) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_VIAL_1) + .setSlotOverlay(true, true, GT_UITextures.OVERLAY_SLOT_VIAL_2) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor() + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(6) + .setUsualFluidOutputCount(6); + public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower() + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT) + .setUsualFluidOutputCount(11); + public static final GT_Recipe_Map_OilCracker sCrackingRecipes = + (GT_Recipe_Map_OilCracker) new GT_Recipe_Map_OilCracker() + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW_MULTIPLE, ProgressBar.Direction.RIGHT) + .setUsualFluidInputCount(2); /** * Use sCrackingRecipes instead */ @@ -1704,294 +1870,341 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final GT_Recipe_Map sCrakingRecipes = sCrackingRecipes; public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map( - new HashSet<>(150), - "gt.recipe.pyro", - "Pyrolyse Oven", - null, - RES_PATH_GUI + "basicmachines/Default", - 2, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(150), + "gt.recipe.pyro", + "Pyrolyse Oven", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map( - new HashSet<>(450), - "gt.recipe.wiremill", - "Wiremill", - null, - RES_PATH_GUI + "basicmachines/Wiremill", - 2, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(450), + "gt.recipe.wiremill", + "Wiremill", + null, + RES_PATH_GUI + "basicmachines/Wiremill", + 2, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_WIREMILL) + .setProgressBar(GT_UITextures.PROGRESSBAR_WIREMILL, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map( - new HashSet<>(5000), - "gt.recipe.metalbender", - "Bending Machine", - null, - RES_PATH_GUI + "basicmachines/Bender", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(5000), + "gt.recipe.metalbender", + "Bending Machine", + null, + RES_PATH_GUI + "basicmachines/Bender", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_BENDER) + .setProgressBar(GT_UITextures.PROGRESSBAR_BENDING, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map( - new HashSet<>(12000), - "gt.recipe.alloysmelter", - "Alloy Smelter", - null, - RES_PATH_GUI + "basicmachines/AlloySmelter", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(12000), + "gt.recipe.alloysmelter", + "Alloy Smelter", + null, + RES_PATH_GUI + "basicmachines/AlloySmelter", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_FURNACE) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_FURNACE_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_ARROW_STEAM); public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler( - new HashSet<>(8200), - "gt.recipe.assembler", - "Assembler", - null, - RES_PATH_GUI + "basicmachines/Assembler2", - 9, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(8200), + "gt.recipe.assembler", + "Assembler", + null, + RES_PATH_GUI + "basicmachines/Assembler2", + 9, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CIRCUIT) + .setProgressBar(GT_UITextures.PROGRESSBAR_ASSEMBLE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler( - new HashSet<>(605), - "gt.recipe.circuitassembler", - "Circuit Assembler", - null, - RES_PATH_GUI + "basicmachines/CircuitAssembler", - 6, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true, - !Loader.isModLoaded("neicustomdiagram")); + new HashSet<>(605), + "gt.recipe.circuitassembler", + "Circuit Assembler", + null, + RES_PATH_GUI + "basicmachines/CircuitAssembler", + 6, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setNEIUnificateOutput(!Loader.isModLoaded("neicustomdiagram")) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CIRCUIT) + .setProgressBar(GT_UITextures.PROGRESSBAR_CIRCUIT_ASSEMBLER, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map( - new HashSet<>(900), - "gt.recipe.canner", - "Canning Machine", - null, - RES_PATH_GUI + "basicmachines/Canner", - 2, - 2, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(900), + "gt.recipe.canner", + "Canning Machine", + null, + RES_PATH_GUI + "basicmachines/Canner", + 2, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_CANNER) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_CANISTER) + .setProgressBar(GT_UITextures.PROGRESSBAR_CANNER, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map( - new HashSet<>(100), - "gt.recipe.cncmachine", - "CNC Machine", - null, - RES_PATH_GUI + "basicmachines/Default", - 2, - 1, - 2, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(100), + "gt.recipe.cncmachine", + "CNC Machine", + null, + RES_PATH_GUI + "basicmachines/Default", + 2, + 1, + 2, + 1, + 1, + E, + 1, + E, + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map( - new HashSet<>(1150), - "gt.recipe.lathe", - "Lathe", - null, - RES_PATH_GUI + "basicmachines/Lathe", - 1, - 2, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(1150), + "gt.recipe.lathe", + "Lathe", + null, + RES_PATH_GUI + "basicmachines/Lathe", + 1, + 2, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_ROD_1) + .setSlotOverlay(false, true, true, GT_UITextures.OVERLAY_SLOT_ROD_2) + .setSlotOverlay(false, true, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_LATHE, ProgressBar.Direction.RIGHT) + .addSpecialTexture(5, 18, 98, 24, GT_UITextures.PROGRESSBAR_LATHE_BASE); public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map( - new HashSet<>(5125), - "gt.recipe.cuttingsaw", - "Cutting Machine", - null, - RES_PATH_GUI + "basicmachines/Cutter4", - 2, - 4, - 1, - 1, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(5125), + "gt.recipe.cuttingsaw", + "Cutting Machine", + null, + RES_PATH_GUI + "basicmachines/Cutter4", + 2, + 4, + 1, + 1, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_BOX) + .setSlotOverlay(false, true, true, GT_UITextures.OVERLAY_SLOT_CUTTER_SLICED) + .setSlotOverlay(false, true, false, GT_UITextures.OVERLAY_SLOT_DUST) + .setProgressBar(GT_UITextures.PROGRESSBAR_CUT, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map( - new HashSet<>(20), - "gt.recipe.slicer", - "Slicing Machine", - null, - RES_PATH_GUI + "basicmachines/Slicer", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(20), + "gt.recipe.slicer", + "Slicing Machine", + null, + RES_PATH_GUI + "basicmachines/Slicer", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, true, GT_UITextures.OVERLAY_SLOT_SQUARE) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_SLICE_SHAPE) + .setSlotOverlay(false, true, GT_UITextures.OVERLAY_SLOT_SLICER_SLICED) + .setProgressBar(GT_UITextures.PROGRESSBAR_SLICE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map( - new HashSet<>(13000), - "gt.recipe.extruder", - "Extruder", - null, - RES_PATH_GUI + "basicmachines/Extruder", - 2, - 1, - 2, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(13000), + "gt.recipe.extruder", + "Extruder", + null, + RES_PATH_GUI + "basicmachines/Extruder", + 2, + 1, + 2, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, false, GT_UITextures.OVERLAY_SLOT_EXTRUDER_SHAPE) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRUDE, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map( - new HashSet<>(3800), - "gt.recipe.hammer", - "Forge Hammer", - null, - RES_PATH_GUI + "basicmachines/Hammer", - 1, - 1, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(3800), + "gt.recipe.hammer", + "Forge Hammer", + null, + RES_PATH_GUI + "basicmachines/Hammer", + 1, + 1, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_HAMMER) + .setProgressBar(GT_UITextures.PROGRESSBAR_HAMMER, ProgressBar.Direction.DOWN) + .addSpecialTexture(20, 6, 78, 42, GT_UITextures.PROGRESSBAR_HAMMER_BASE) + .setSlotOverlaySteam(false, GT_UITextures.OVERLAY_SLOT_HAMMER_STEAM) + .setProgressBarSteam(GT_UITextures.PROGRESSBAR_HAMMER_STEAM) + .addSpecialTextureSteam(20, 6, 78, 42, GT_UITextures.PROGRESSBAR_HAMMER_BASE_STEAM); public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map( - new HashSet<>(2), - "gt.recipe.uuamplifier", - "Amplifabricator", - null, - RES_PATH_GUI + "basicmachines/Amplifabricator", - 1, - 0, - 1, - 0, - 1, - E, - 1, - E, - true, - true); + new HashSet<>(2), + "gt.recipe.uuamplifier", + "Amplifabricator", + null, + RES_PATH_GUI + "basicmachines/Amplifabricator", + 1, + 0, + 1, + 0, + 1, + E, + 1, + E, + true, + true) + .setSlotOverlay(false, false, GT_UITextures.OVERLAY_SLOT_CENTRIFUGE) + .setSlotOverlay(true, true, GT_UITextures.OVERLAY_SLOT_UUA) + .setProgressBar(GT_UITextures.PROGRESSBAR_EXTRACT, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map( - new HashSet<>(2), - "gt.recipe.massfab", - "Mass Fabrication", - null, - RES_PATH_GUI + "basicmachines/Massfabricator", - 1, - 0, - 1, - 0, - 8, - E, - 1, - E, - true, - true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(20), - "gt.recipe.dieselgeneratorfuel", - "Combustion Generator Fuels", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(20), - "gt.recipe.extremedieselgeneratorfuel", - "Extreme Diesel Engine Fuel", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(25), - "gt.recipe.gasturbinefuel", - "Gas Turbine Fuel", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); + new HashSet<>(2), + "gt.recipe.massfab", + "Mass Fabrication", + null, + RES_PATH_GUI + "basicmachines/Massfabricator", + 1, + 0, + 1, + 0, + 8, + E, + 1, + E, + true, + true) + .setSlotOverlay(true, false, GT_UITextures.OVERLAY_SLOT_UUA) + .setSlotOverlay(true, true, GT_UITextures.OVERLAY_SLOT_UUM) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sDieselFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(20), + "gt.recipe.dieselgeneratorfuel", + "Combustion Generator Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(20), + "gt.recipe.extremedieselgeneratorfuel", + "Extreme Diesel Engine Fuel", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sTurbineFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(25), + "gt.recipe.gasturbinefuel", + "Gas Turbine Fuel", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel( new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", @@ -2008,150 +2221,161 @@ public class GT_Recipe implements Comparable<GT_Recipe> { " EU", true, false); - public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(15), - "gt.recipe.semifluidboilerfuels", - "Semifluid Boiler Fuels", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(100), - "gt.recipe.plasmageneratorfuels", - "Plasma Generator Fuels", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(100), - "gt.recipe.magicfuels", - "Magic Energy Absorber Fuels", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.smallnaquadahreactor", - "Naquadah Reactor MkI", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.largenaquadahreactor", - "Naquadah Reactor MkII", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.fluidnaquadahreactor", - "Naquadah Reactor MkIII", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.hugenaquadahreactor", - "Naquadah Reactor MkIV", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.extrahugenaquadahreactor", - "Naquadah Reactor MkV", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); - public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel( - new HashSet<>(1), - "gt.recipe.fluidfuelnaquadahreactor", - "Fluid Naquadah Reactor", - null, - RES_PATH_GUI + "basicmachines/Default", - 1, - 1, - 0, - 0, - 1, - "Fuel Value: ", - 1000, - " EU", - true, - true); + public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(15), + "gt.recipe.semifluidboilerfuels", + "Semifluid Boiler Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sPlasmaFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(100), + "gt.recipe.plasmageneratorfuels", + "Plasma Generator Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sMagicFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(100), + "gt.recipe.magicfuels", + "Magic Energy Absorber Fuels", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.smallnaquadahreactor", + "Naquadah Reactor MkI", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.largenaquadahreactor", + "Naquadah Reactor MkII", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.fluidnaquadahreactor", + "Naquadah Reactor MkIII", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sExtremeNaquadahReactorFuels = + (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.hugenaquadahreactor", + "Naquadah Reactor MkIV", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sUltraHugeNaquadahReactorFuels = + (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.extrahugenaquadahreactor", + "Naquadah Reactor MkV", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); + public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = (GT_Recipe_Map_Fuel) new GT_Recipe_Map_Fuel( + new HashSet<>(1), + "gt.recipe.fluidfuelnaquadahreactor", + "Fluid Naquadah Reactor", + null, + RES_PATH_GUI + "basicmachines/Default", + 1, + 1, + 0, + 0, + 1, + "Fuel Value: ", + 1000, + " EU", + true, + true) + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); public static final GT_Recipe_Map sMultiblockElectrolyzerRecipes = new GT_Recipe_Map( new HashSet<>(300), "gt.recipe.largeelectrolyzer", @@ -2201,7 +2425,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { true, false); public static final GT_Recipe_Map_LargeBoilerFakeFuels sLargeBoilerFakeFuels = - new GT_Recipe_Map_LargeBoilerFakeFuels(); + (GT_Recipe_Map_LargeBoilerFakeFuels) new GT_Recipe_Map_LargeBoilerFakeFuels() + .setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT); /** * HashMap of Recipes based on their Items @@ -2237,7 +2462,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { mMinimalInputItems, mMinimalInputFluids, mAmperage; - public final boolean mNEIAllowed, mShowVoltageAmperageInNEI, mNEIUnificateOutput; + public final boolean mNEIAllowed, mShowVoltageAmperageInNEI; + + /** + * Whether to show oredict equivalent outputs when NEI is queried to show recipe + */ + public boolean mNEIUnificateOutput = true; /** * Unique identifier for this recipe map. Generated from aUnlocalizedName and a few other parameters. @@ -2256,6 +2486,87 @@ public class GT_Recipe implements Comparable<GT_Recipe> { private boolean mUsesSpecialSlot = false; /** + * How many fluid inputs does this recipemap has at most. Currently used only for NEI slot placements + * and does not actually restrict number of fluids used in the recipe. + */ + private int usualFluidInputCount; + + /** + * How many fluid outputs does this recipemap has at most. Currently used only for NEI slot placements + * and does not actually restrict number of fluids used in the recipe. + */ + private int usualFluidOutputCount; + + /** + * Whether to use ModularUI for slot placements. + */ + public boolean useModularUI = false; + + /** + * Overlays used for GUI. + * 1 = If it's fluid slot. + * 2 = If it's output slot. + * 4 = If it's first slot in the same section, e.g. first slot in the item output slots + * 8 = If it's special item slot. + */ + private final TByteObjectMap<IDrawable> slotOverlays = new TByteObjectHashMap<>(); + + /** + * Overlays used for GUI on steam machine. + * 1 = If it's fluid slot. + * 2 = If it's output slot. + * 4 = If it's first slot in the same section, e.g. first slot in the item output slots + * 8 = If it's special item slot. + */ + private final TByteObjectMap<SteamTexture> slotOverlaysSteam = new TByteObjectHashMap<>(); + + /** + * Progressbar used for BasicMachine GUI and/or NEI. + * Unless specified, size should be (20, 36), consisting of two parts; + * First is (20, 18) size of "empty" image at the top, + * Second is (20, 18) size of "filled" image at the bottom. + */ + public UITexture progressBarTexture = GT_UITextures.PROGRESSBAR_ARROW; + + /** + * Progressbar used for steam machine GUI and/or NEI. + * Unless specified, size should be (20, 36), consisting of two parts; + * First is (20, 18) size of "empty" image at the top, + * Second is (20, 18) size of "filled" image at the bottom. + */ + public SteamTexture progressBarTextureSteam; + + public ProgressBar.Direction progressBarDirection = ProgressBar.Direction.RIGHT; + + public Size progressBarSize = new Size(20, 18); + + public Pos2d progressBarPos = new Pos2d(78, 24); + + public Rectangle neiTransferRect = new Rectangle( + progressBarPos.x - (16 / 2), progressBarPos.y, progressBarSize.width + 16, progressBarSize.height); + + /** + * Image size in direction of progress. Used for non-smooth rendering. + */ + private int progressBarImageSize; + + /** + * Additional textures shown on GUI. + */ + public final List<Pair<IDrawable, Pair<Size, Pos2d>>> specialTextures = new ArrayList<>(); + + /** + * Additional textures shown on steam machine GUI. + */ + public final List<Pair<SteamTexture, Pair<Size, Pos2d>>> specialTexturesSteam = new ArrayList<>(); + + public Pos2d neiGregTechLogoPos = new Pos2d(152, 63); + + public Pos2d neiBackgroundOffset = new Pos2d(2, 3); + + public Size neiBackgroundSize = new Size(172, 82); + + /** * Initialises a new type of Recipe Handler. * * @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a pre-initialised Size. @@ -2268,7 +2579,6 @@ public class GT_Recipe implements Comparable<GT_Recipe> { * @param aNEISpecialValueMultiplier the Value the Special Value is getting Multiplied with before displaying * @param aNEISpecialValuePost the String after the Special Value. Usually for a Unit or something. * @param aNEIAllowed if NEI is allowed to display this Recipe Handler in general. - * @param aNEIUnificateOutput if NEI generate oredict equivalents */ public GT_Recipe_Map( Collection<GT_Recipe> aRecipeList, @@ -2285,12 +2595,10 @@ public class GT_Recipe implements Comparable<GT_Recipe> { int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, - boolean aNEIAllowed, - boolean aNEIUnificateOutput) { + boolean aNEIAllowed) { sMappings.add(this); mNEIAllowed = aNEIAllowed; mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI; - mNEIUnificateOutput = aNEIUnificateOutput; mRecipeList = aRecipeList; mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName; mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png"; @@ -2317,6 +2625,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { throw new IllegalArgumentException("Duplicate recipe map registered: " + mUniqueIdentifier); } + @Deprecated public GT_Recipe_Map( Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, @@ -2332,7 +2641,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, - boolean aNEIAllowed) { + boolean aNEIAllowed, + boolean aNEIUnificateOutput) { this( aRecipeList, aUnlocalizedName, @@ -2348,8 +2658,138 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, - aNEIAllowed, - true); + aNEIAllowed); + setNEIUnificateOutput(aNEIUnificateOutput); + } + + public GT_Recipe_Map setNEIUnificateOutput(boolean mNEIUnificateOutput) { + this.mNEIUnificateOutput = mNEIUnificateOutput; + return this; + } + + public GT_Recipe_Map useModularUI(boolean use) { + this.useModularUI = use; + return this; + } + + public GT_Recipe_Map setSlotOverlay( + boolean isFluid, boolean isOutput, boolean isFirst, boolean isSpecial, IDrawable slotOverlay) { + useModularUI(true); + this.slotOverlays.put( + (byte) ((isFluid ? 1 : 0) + (isOutput ? 2 : 0) + (isFirst ? 4 : 0) + (isSpecial ? 8 : 0)), + slotOverlay); + return this; + } + + public GT_Recipe_Map setSlotOverlay(boolean isFluid, boolean isOutput, boolean isFirst, IDrawable slotOverlay) { + return setSlotOverlay(isFluid, isOutput, isFirst, false, slotOverlay); + } + + public GT_Recipe_Map setSlotOverlay(boolean isFluid, boolean isOutput, IDrawable slotOverlay) { + return setSlotOverlay(isFluid, isOutput, true, slotOverlay) + .setSlotOverlay(isFluid, isOutput, false, slotOverlay); + } + + public GT_Recipe_Map setSlotOverlaySteam( + boolean isFluid, boolean isOutput, boolean isFirst, boolean isSpecial, SteamTexture slotOverlay) { + useModularUI(true); + this.slotOverlaysSteam.put( + (byte) ((isFluid ? 1 : 0) + (isOutput ? 2 : 0) + (isFirst ? 4 : 0) + (isSpecial ? 8 : 0)), + slotOverlay); + return this; + } + + public GT_Recipe_Map setSlotOverlaySteam(boolean isOutput, boolean isFirst, SteamTexture slotOverlay) { + return setSlotOverlaySteam(false, isOutput, isFirst, false, slotOverlay); + } + + public GT_Recipe_Map setSlotOverlaySteam(boolean isOutput, SteamTexture slotOverlay) { + return setSlotOverlaySteam(false, isOutput, true, false, slotOverlay) + .setSlotOverlaySteam(false, isOutput, false, false, slotOverlay); + } + + public GT_Recipe_Map setProgressBar(UITexture progressBarTexture, ProgressBar.Direction progressBarDirection) { + useModularUI(true); + this.progressBarTexture = progressBarTexture; + this.progressBarDirection = progressBarDirection; + return this; + } + + public GT_Recipe_Map setProgressBar(UITexture progressBarTexture) { + return setProgressBar(progressBarTexture, ProgressBar.Direction.RIGHT); + } + + public GT_Recipe_Map setProgressBarSteam(SteamTexture progressBarTexture) { + this.progressBarTextureSteam = progressBarTexture; + return this; + } + + public GT_Recipe_Map setProgressBarSize(int x, int y) { + useModularUI(true); + this.progressBarSize = new Size(x, y); + return this; + } + + public GT_Recipe_Map setProgressBarPos(int x, int y) { + useModularUI(true); + this.progressBarPos = new Pos2d(x, y); + return this; + } + + public GT_Recipe_Map setProgressBarImageSize(int progressBarImageSize) { + useModularUI(true); + this.progressBarImageSize = progressBarImageSize; + return this; + } + + public GT_Recipe_Map setNEITransferRect(Rectangle neiTransferRect) { + useModularUI(true); + this.neiTransferRect = neiTransferRect; + return this; + } + + public GT_Recipe_Map addSpecialTexture(int width, int height, int x, int y, IDrawable texture) { + useModularUI(true); + specialTextures.add( + new ImmutablePair<>(texture, new ImmutablePair<>(new Size(width, height), new Pos2d(x, y)))); + return this; + } + + public GT_Recipe_Map addSpecialTextureSteam(int width, int height, int x, int y, SteamTexture texture) { + useModularUI(true); + specialTexturesSteam.add( + new ImmutablePair<>(texture, new ImmutablePair<>(new Size(width, height), new Pos2d(x, y)))); + return this; + } + + public GT_Recipe_Map setUsualFluidInputCount(int usualFluidInputCount) { + useModularUI(true); + this.usualFluidInputCount = usualFluidInputCount; + return this; + } + + public GT_Recipe_Map setUsualFluidOutputCount(int usualFluidOutputCount) { + useModularUI(true); + this.usualFluidOutputCount = usualFluidOutputCount; + return this; + } + + public GT_Recipe_Map setNEIGregTechLogoPos(int x, int y) { + useModularUI(true); + this.neiGregTechLogoPos = new Pos2d(x, y); + return this; + } + + public GT_Recipe_Map setNEIBackgroundOffset(int x, int y) { + useModularUI(true); + this.neiBackgroundOffset = new Pos2d(x, y); + return this; + } + + public GT_Recipe_Map setNEIBackgroundSize(int width, int height) { + useModularUI(true); + this.neiBackgroundSize = new Size(width, height); + return this; } public GT_Recipe addRecipe( @@ -2786,18 +3226,184 @@ public class GT_Recipe implements Comparable<GT_Recipe> { return mUsesSpecialSlot; } + public int getUsualFluidInputCount() { + return Math.max(usualFluidInputCount, hasFluidInputs() ? 1 : 0); + } + + public int getUsualFluidOutputCount() { + return Math.max(usualFluidOutputCount, hasFluidOutputs() ? 1 : 0); + } + + @Nullable + public IDrawable getOverlayForSlot(boolean isFluid, boolean isOutput, int index, boolean isSpecial) { + byte overlayKey = + (byte) ((isFluid ? 1 : 0) + (isOutput ? 2 : 0) + (index == 0 ? 4 : 0) + (isSpecial ? 8 : 0)); + if (slotOverlays.containsKey(overlayKey)) { + return slotOverlays.get(overlayKey); + } + return null; + } + + @Nullable + public SteamTexture getOverlayForSlotSteam(boolean isFluid, boolean isOutput, int index, boolean isSpecial) { + byte overlayKey = + (byte) ((isFluid ? 1 : 0) + (isOutput ? 2 : 0) + (index == 0 ? 4 : 0) + (isSpecial ? 8 : 0)); + if (slotOverlaysSteam.containsKey(overlayKey)) { + return slotOverlaysSteam.get(overlayKey); + } + return null; + } + + @Nullable + public SteamTexture getOverlayForSlotSteam(boolean isOutput, boolean isFirst) { + byte overlayKey = (byte) ((isOutput ? 2 : 0) + (isFirst ? 4 : 0)); + if (slotOverlaysSteam.containsKey(overlayKey)) { + return slotOverlaysSteam.get(overlayKey); + } + return null; + } + + public int getProgressBarImageSize() { + if (progressBarImageSize != 0) { + return progressBarImageSize; + } + switch (progressBarDirection) { + case UP: + case DOWN: + return progressBarSize.height; + case CIRCULAR_CW: + return Math.max(progressBarSize.width, progressBarSize.height); + default: + return progressBarSize.width; + } + } + /** - * Overriding this method and getOutputPositionedStacks allows custom NEI stack placement - * @return A list of input stacks + * Adds slot backgrounds, progressBar, etc. */ + public ModularWindow.Builder createNEITemplate( + IItemHandlerModifiable itemInputsInventory, + IItemHandlerModifiable itemOutputsInventory, + IItemHandlerModifiable specialSlotInventory, + IItemHandlerModifiable fluidInputsInventory, + IItemHandlerModifiable fluidOutputsInventory, + Supplier<Float> progressSupplier, + Pos2d windowOffset) { + ModularWindow.Builder builder = + ModularWindow.builder(neiBackgroundSize).setBackground(ModularUITextures.VANILLA_BACKGROUND); + + UIHelper.forEachSlots( + (i, backgrounds, pos) -> builder.widget(SlotWidget.phantom(itemInputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> builder.widget(SlotWidget.phantom(itemOutputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> { + if (usesSpecialSlot()) + builder.widget(SlotWidget.phantom(specialSlotInventory, 0) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)); + }, + (i, backgrounds, pos) -> builder.widget(SlotWidget.phantom(fluidInputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> builder.widget(SlotWidget.phantom(fluidOutputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + ModularUITextures.ITEM_SLOT, + ModularUITextures.FLUID_SLOT, + this, + mUsualInputCount, + mUsualOutputCount, + getUsualFluidInputCount(), + getUsualFluidOutputCount(), + SteamVariant.NONE, + windowOffset); + + addProgressBarUI(builder, progressSupplier, windowOffset); + addGregTechLogoUI(builder, windowOffset); + + for (Pair<IDrawable, Pair<Size, Pos2d>> specialTexture : specialTextures) { + builder.widget(new DrawableWidget() + .setDrawable(specialTexture.getLeft()) + .setSize(specialTexture.getRight().getLeft()) + .setPos(specialTexture.getRight().getRight().add(windowOffset))); + } + + return builder; + } + + protected void addProgressBarUI( + ModularWindow.Builder builder, Supplier<Float> progressSupplier, Pos2d windowOffset) { + builder.widget(new ProgressBar() + .setTexture(progressBarTexture, 20) + .setDirection(progressBarDirection) + .setProgress(progressSupplier) + .setSynced(false, false) + .setPos(progressBarPos.add(windowOffset)) + .setSize(progressBarSize)); + } + + protected void addGregTechLogoUI(ModularWindow.Builder builder, Pos2d windowOffset) { + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT) + .setSize(17, 17) + .setPos(neiGregTechLogoPos.add(windowOffset))); + } + + /** + * Overriding this method allows custom NEI stack placement + */ + public List<Pos2d> getItemInputPositions(int itemInputCount) { + return UIHelper.getItemInputPositions(itemInputCount); + } + + /** + * Overriding this method allows custom NEI stack placement + */ + public List<Pos2d> getItemOutputPositions(int itemOutputCount) { + return UIHelper.getItemOutputPositions(itemOutputCount); + } + + /** + * Overriding this method allows custom NEI stack placement + */ + public Pos2d getSpecialItemPosition() { + return UIHelper.getSpecialItemPosition(); + } + + /** + * Overriding this method allows custom NEI stack placement + */ + public List<Pos2d> getFluidInputPositions(int fluidInputCount) { + return UIHelper.getFluidInputPositions(fluidInputCount); + } + + /** + * Overriding this method allows custom NEI stack placement + */ + public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getFluidOutputPositions(fluidOutputCount); + } + + /** + * Use {@link #getItemInputPositions} or {@link #getSpecialItemPosition} or {@link #getFluidInputPositions} instead + */ + @Deprecated public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { return null; } /** - * Overriding this method and getInputPositionedStacks allows custom NEI stack placement - * @return A list of output stacks + * Use {@link #getItemOutputPositions} or {@link #getFluidOutputPositions} instead */ + @Deprecated public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { return null; } @@ -2810,6 +3416,155 @@ public class GT_Recipe implements Comparable<GT_Recipe> { // ----------------------------------------------------------------------------------------------------------------- /** + * Nicely display NEI with many items and fluids. + * Remember to call {@link GT_Recipe_Map#setUsualFluidInputCount} and {@link GT_Recipe_Map#setUsualFluidOutputCount}. + * If row count >= 6, it doesn't fit in 2 recipes per page, so change it via IMC. + */ + public static class GT_Recipe_Map_LargeNEI extends GT_Recipe_Map { + + private static final int xDirMaxCount = 3; + private static final int yOrigin = 8; + + public GT_Recipe_Map_LargeNEI( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); + useModularUI(true); + setNEIGregTechLogoPos(80, 62); + } + + @Override + public List<Pos2d> getItemInputPositions(int itemInputCount) { + return UIHelper.getItemGridPositions(itemInputCount, 16, yOrigin, xDirMaxCount, 3); + } + + @Override + public List<Pos2d> getItemOutputPositions(int itemOutputCount) { + return UIHelper.getItemGridPositions(itemOutputCount, 106, yOrigin, xDirMaxCount, 3); + } + + @Override + public List<Pos2d> getFluidInputPositions(int fluidInputCount) { + return UIHelper.getItemGridPositions( + fluidInputCount, 16, yOrigin + getItemRowCount() * 18, xDirMaxCount, 3); + } + + @Override + public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getItemGridPositions( + fluidOutputCount, 106, yOrigin + getItemRowCount() * 18, xDirMaxCount, 3); + } + + @Override + public ModularWindow.Builder createNEITemplate( + IItemHandlerModifiable itemInputsInventory, + IItemHandlerModifiable itemOutputsInventory, + IItemHandlerModifiable specialSlotInventory, + IItemHandlerModifiable fluidInputsInventory, + IItemHandlerModifiable fluidOutputsInventory, + Supplier<Float> progressSupplier, + Pos2d windowOffset) { + // Delay setter so that calls to #setUsualFluidInputCount and #setUsualFluidOutputCount are considered + setNEIBackgroundSize(172, 82 + (Math.max(getItemRowCount() + getFluidRowCount() - 4, 0)) * 18); + return super.createNEITemplate( + itemInputsInventory, + itemOutputsInventory, + specialSlotInventory, + fluidInputsInventory, + fluidOutputsInventory, + progressSupplier, + windowOffset); + } + + private int getItemRowCount() { + return (Math.max(mUsualInputCount, mUsualOutputCount) - 1) / xDirMaxCount + 1; + } + + private int getFluidRowCount() { + return (Math.max(getUsualFluidInputCount(), getUsualFluidOutputCount()) - 1) / xDirMaxCount + 1; + } + } + + /** + * Display fluids where normally items are placed on NEI. + */ + public static class GT_Recipe_Map_FluidOnly extends GT_Recipe_Map { + + public GT_Recipe_Map_FluidOnly( + Collection<GT_Recipe> aRecipeList, + String aUnlocalizedName, + String aLocalName, + String aNEIName, + String aNEIGUIPath, + int aUsualInputCount, + int aUsualOutputCount, + int aMinimalInputItems, + int aMinimalInputFluids, + int aAmperage, + String aNEISpecialValuePre, + int aNEISpecialValueMultiplier, + String aNEISpecialValuePost, + boolean aShowVoltageAmperageInNEI, + boolean aNEIAllowed) { + super( + aRecipeList, + aUnlocalizedName, + aLocalName, + aNEIName, + aNEIGUIPath, + aUsualInputCount, + aUsualOutputCount, + aMinimalInputItems, + aMinimalInputFluids, + aAmperage, + aNEISpecialValuePre, + aNEISpecialValueMultiplier, + aNEISpecialValuePost, + aShowVoltageAmperageInNEI, + aNEIAllowed); + useModularUI(true); + } + + @Override + public List<Pos2d> getFluidInputPositions(int fluidInputCount) { + return UIHelper.getItemInputPositions(fluidInputCount); + } + + @Override + public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getItemOutputPositions(fluidOutputCount); + } + } + + /** * Abstract Class for general Recipe Handling of non GT Recipes */ public abstract static class GT_Recipe_Map_NonGTRecipes extends GT_Recipe_Map { @@ -4060,44 +4815,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> { int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, - boolean aNEIAllowed, - boolean aNEIUnificateOutput) { - super( - aRecipeList, - aUnlocalizedName, - aLocalName, - aNEIName, - aNEIGUIPath, - aUsualInputCount, - aUsualOutputCount, - aMinimalInputItems, - aMinimalInputFluids, - aAmperage, - aNEISpecialValuePre, - aNEISpecialValueMultiplier, - aNEISpecialValuePost, - aShowVoltageAmperageInNEI, - aNEIAllowed, - aNEIUnificateOutput); - } - - public GT_Recipe_Map_Assembler( - Collection<GT_Recipe> aRecipeList, - String aUnlocalizedName, - String aLocalName, - String aNEIName, - String aNEIGUIPath, - int aUsualInputCount, - int aUsualOutputCount, - int aMinimalInputItems, - int aMinimalInputFluids, - int aAmperage, - String aNEISpecialValuePre, - int aNEISpecialValueMultiplier, - String aNEISpecialValuePost, - boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - this( + super( aRecipeList, aUnlocalizedName, aLocalName, @@ -4112,8 +4831,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, - aNEIAllowed, - true); + aNEIAllowed); } @Override @@ -4614,10 +5332,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } - public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map { + public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map_LargeNEI { private static final int TOTAL_INPUT_COUNT = 6; private static final int OUTPUT_COUNT = 6; - private static final int FLUID_OUTPUT_COUNT = 6; public GT_Recipe_Map_LargeChemicalReactor() { super( @@ -4626,7 +5343,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/LCRNEI", - 2, + TOTAL_INPUT_COUNT, OUTPUT_COUNT, 0, 0, @@ -4742,83 +5459,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aEUt, aSpecialValue); } - - @Override - public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { - int itemLimit = Math.min(recipe.mInputs.length, TOTAL_INPUT_COUNT); - int fluidLimit = Math.min(recipe.mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit); - int inputlimit = itemLimit + fluidLimit; - int j = 0; - - ArrayList<PositionedStack> inputStacks = new ArrayList<>(inputlimit); - - for (int i = 0; i < itemLimit; i++, j++) { - if (recipe.mInputs == null || (recipe.mInputs[i] == null && (i == 0 && itemLimit == 1))) { - if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() - + " has errored!"); - else GT_Log.out.println("recipe " + recipe + " has errored!"); - - new Exception("Recipe Fixme").printStackTrace(GT_Log.out); - } - - if ((recipe.mInputs != null && recipe.mInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add( - new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); - else - inputStacks.add(new FixedPositionedStack( - new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); - } - - for (int i = 0; i < fluidLimit; i++, j++) { - if (recipe.mFluidInputs == null || recipe.mFluidInputs[i] == null) { - if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() - + " has errored!"); - else GT_Log.out.println("recipe " + recipe + " has errored!"); - - new Exception("Recipe Fixme").printStackTrace(GT_Log.out); - } - - if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) - || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), - 48 - j % 3 * 18, - (j >= 3 ? 5 : 23))); - } - - return inputStacks; - } - - @Override - public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { - int itemLimit = Math.min(recipe.mOutputs.length, OUTPUT_COUNT); - int fluidLimit = Math.min(recipe.mFluidOutputs.length, FLUID_OUTPUT_COUNT); - ArrayList<PositionedStack> outputStacks = new ArrayList<>(itemLimit + fluidLimit); - - int j = 0; - - for (int i = 0; i < itemLimit; i++, j++) { - outputStacks.add( - new FixedPositionedStack(recipe.mOutputs[i].copy(), 102 + j % 3 * 18, (j >= 3 ? 5 : 23))); - } - - for (int i = 0; i < fluidLimit; i++, j++) { - outputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), - 102 + j % 3 * 18, - (j >= 3 ? 5 : 23))); - } - - return outputStacks; - } } public static class GT_Recipe_Map_DistillationTower extends GT_Recipe_Map { - private static final int TOTAL_INPUT_COUNT = 6; - private static final int FLUID_OUTPUT_COUNT = 11; - private static final int ROW_SIZE = 3; public GT_Recipe_Map_DistillationTower() { super( @@ -4828,7 +5471,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> { null, RES_PATH_GUI + "basicmachines/DistillationTower", 2, - 4, + 1, 0, 0, 1, @@ -4837,70 +5480,33 @@ public class GT_Recipe implements Comparable<GT_Recipe> { E, true, true); + setNEIGregTechLogoPos(80, 62); } @Override - public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { - int itemLimit = Math.min(recipe.mInputs.length, TOTAL_INPUT_COUNT); - int fluidLimit = Math.min(recipe.mFluidInputs.length, TOTAL_INPUT_COUNT - itemLimit); - int inputlimit = itemLimit + fluidLimit; - int j = 0; - - ArrayList<PositionedStack> inputStacks = new ArrayList<>(inputlimit); - - for (int i = 0; i < itemLimit; i++, j++) { - if (recipe.mInputs == null || (recipe.mInputs[i] == null && (i == 0 && itemLimit == 1))) { - if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() - + " has errored!"); - else GT_Log.out.println("recipe " + recipe + " has errored!"); - new Exception("Recipe Fixme").printStackTrace(GT_Log.out); - } - - if ((recipe.mInputs != null && recipe.mInputs[i] != null) || !GT_Values.allow_broken_recipemap) - inputStacks.add( - new FixedPositionedStack(recipe.mInputs[i].copy(), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); - else - inputStacks.add(new FixedPositionedStack( - new ItemStack(Items.command_block_minecart), 48 - j % 3 * 18, (j >= 3 ? 5 : 23))); - } - - for (int i = 0; i < fluidLimit; i++, j++) { - if (recipe.mFluidInputs == null || recipe.mFluidInputs[i] == null) { - if (recipe.mOutputs != null && recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) - GT_Log.out.println("recipe " + recipe + " Output 0:" + recipe.mOutputs[0].getDisplayName() - + " has errored!"); - else GT_Log.out.println("recipe " + recipe + " has errored!"); - new Exception("Recipe Fixme").printStackTrace(GT_Log.out); + public IDrawable getOverlayForSlot(boolean isFluid, boolean isOutput, int index, boolean isSpecial) { + if (isOutput) { + if (isFluid) { + return GT_UITextures.OVERLAY_SLOTS_NUMBER[index + 1]; + } else { + return GT_UITextures.OVERLAY_SLOTS_NUMBER[0]; } - - if ((recipe.mFluidInputs != null && recipe.mFluidInputs[i] != null) - || !GT_Values.allow_broken_recipemap) - inputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[i], true), - 48 - j % 3 * 18, - (j >= 3 ? 5 : 23))); } - - return inputStacks; + return super.getOverlayForSlot(isFluid, false, index, isSpecial); } @Override - public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { - int fluidLimit = Math.min(recipe.mFluidOutputs.length, FLUID_OUTPUT_COUNT); - ArrayList<PositionedStack> outputStacks = new ArrayList<>(1 + fluidLimit); - - if (recipe.mOutputs.length > 0 && recipe.mOutputs[0] != null) { - outputStacks.add(new FixedPositionedStack(recipe.getOutput(0), 102, 52)); - } + public List<Pos2d> getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(106, 62)); + } - for (int i = 0; i < fluidLimit; i++) { - int x = 102 + ((i + 1) % ROW_SIZE) * 18; - int y = 52 - ((i + 1) / ROW_SIZE) * 18; - outputStacks.add( - new FixedPositionedStack(GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[i], true), x, y)); + @Override + public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + List<Pos2d> results = new ArrayList<>(); + for (int i = 1; i < fluidOutputCount + 1; i++) { + results.add(new Pos2d(106 + (i % 3) * 18, 62 - (i / 3) * 18)); } - return outputStacks; + return results; } } @@ -5059,9 +5665,9 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } - public static class GT_Recipe_Map_PlasmaForge extends GT_Recipe_Map { + public static class GT_Recipe_Map_ComplexFusion extends GT_Recipe_Map { - public GT_Recipe_Map_PlasmaForge( + public GT_Recipe_Map_ComplexFusion( Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, @@ -5092,60 +5698,56 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, - aNEIAllowed, - true); + aNEIAllowed); } @Override - public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { - ArrayList<PositionedStack> inputStacks = new ArrayList<>(); - int i = 0; - if (recipe.mInputs != null) { - for (int j = 0; j < recipe.mInputs.length; j++, i++) { - if (recipe.mInputs[j] == NI) continue; - inputStacks.add( - new FixedPositionedStack(recipe.mInputs[j].copy(), 12 + 18 * (i % 3), 5 + 18 * (i / 3))); - } - } - if (recipe.mFluidInputs != null) { - for (int j = 0; j < recipe.mFluidInputs.length; j++, i++) { - if (recipe.mFluidInputs[j] == NF) continue; - inputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), - 12 + 18 * (i % 3), - 5 + 18 * (i / 3))); - } - } - return inputStacks; + public GT_Recipe addRecipe( + int[] aOutputChances, + FluidStack[] aFluidInputs, + FluidStack[] aFluidOutputs, + int aDuration, + int aEUt, + int aSpecialValue) { + return addRecipe( + new GT_Recipe( + false, + null, + null, + null, + aOutputChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue), + false, + false, + false); } @Override - public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { - ArrayList<PositionedStack> outputStacks = new ArrayList<>(); - int i = 0; - if (recipe.mOutputs != null) { - for (int j = 0; j < recipe.mOutputs.length; j++, i++) { - if (recipe.mOutputs[j] == NI) continue; - outputStacks.add( - new FixedPositionedStack(recipe.mOutputs[j].copy(), 102 + 18 * (i % 3), 5 + 18 * (i / 3))); - } + public List<Pos2d> getFluidInputPositions(int fluidInputCount) { + List<Pos2d> results = new ArrayList<>(); + for (int i = 0; i < fluidInputCount; i++) { + results.add(new Pos2d(7 + (i % 4) * 18, 9 + (i / 4) * 18)); } - if (recipe.mFluidOutputs != null) { - for (int j = 0; j < recipe.mFluidOutputs.length; j++, i++) { - if (recipe.mFluidOutputs[j] == NF) continue; - outputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), - 102 + 18 * (i % 3), - 5 + 18 * (i / 3))); - } + return results; + } + + @Override + public List<Pos2d> getFluidOutputPositions(int fluidOutputCount) { + List<Pos2d> results = new ArrayList<>(); + for (int i = 0; i < fluidOutputCount; i++) { + results.add(new Pos2d(97 + (i % 4) * 18, 9 + (i / 4) * 18)); } - return outputStacks; + return results; } } - public static class GT_Recipe_Map_ComplexFusion extends GT_Recipe_Map { + public static class GT_Recipe_Map_AssemblyLineFake extends GT_Recipe_Map { - public GT_Recipe_Map_ComplexFusion( + public GT_Recipe_Map_AssemblyLineFake( Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, @@ -5176,65 +5778,65 @@ public class GT_Recipe implements Comparable<GT_Recipe> { aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, - aNEIAllowed, - true); + aNEIAllowed); + setNEITransferRect(new Rectangle(146, 26, 10, 18)); } @Override - public GT_Recipe addRecipe( - int[] aOutputChances, - FluidStack[] aFluidInputs, - FluidStack[] aFluidOutputs, - int aDuration, - int aEUt, - int aSpecialValue) { - return addRecipe( - new GT_Recipe( - false, - null, - null, - null, - aOutputChances, - aFluidInputs, - aFluidOutputs, - aDuration, - aEUt, - aSpecialValue), - false, - false, - false); + public List<Pos2d> getItemInputPositions(int itemInputCount) { + List<Pos2d> results = new ArrayList<>(); + for (int i = 0; i < itemInputCount; i++) { + results.add(new Pos2d(16 + (i % 4) * 18, 8 + (i / 4) * 18)); + } + return results; } @Override - public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) { - ArrayList<PositionedStack> inputStacks = new ArrayList<>(); - int i = 0; - if (recipe.mFluidInputs != null) { - for (int j = 0; j < recipe.mFluidInputs.length; j++, i++) { - if (recipe.mFluidInputs[j] == NF) continue; - inputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true), - 3 + 18 * (i % 4), - -1 + 18 * (i / 4))); - } - } - return inputStacks; + public List<Pos2d> getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(142, 8)); } @Override - public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) { - ArrayList<PositionedStack> outputStacks = new ArrayList<>(); - int i = 0; - if (recipe.mFluidOutputs != null) { - for (int j = 0; j < recipe.mFluidOutputs.length; j++, i++) { - if (recipe.mFluidOutputs[j] == NF) continue; - outputStacks.add(new FixedPositionedStack( - GT_Utility.getFluidDisplayStack(recipe.mFluidOutputs[j], true), - 93 + 18 * (i % 4), - -1 + 18 * (i / 4))); - } + public Pos2d getSpecialItemPosition() { + return new Pos2d(142, 44); + } + + @Override + public List<Pos2d> getFluidInputPositions(int fluidInputCount) { + List<Pos2d> results = new ArrayList<>(); + for (int i = 0; i < fluidInputCount; i++) { + results.add(new Pos2d(106, 8 + i * 18)); } - return outputStacks; + return results; + } + + @Override + protected void addProgressBarUI( + ModularWindow.Builder builder, Supplier<Float> progressSupplier, Pos2d windowOffset) { + int bar1Width = 17; + int bar2Width = 18; + builder.widget(new ProgressBar() + .setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_1, 17) + .setDirection(ProgressBar.Direction.RIGHT) + .setProgress(() -> progressSupplier.get() * ((float) (bar1Width + bar2Width) / bar1Width)) + .setSynced(false, false) + .setPos(new Pos2d(88, 8).add(windowOffset)) + .setSize(bar1Width, 72)); + builder.widget(new ProgressBar() + .setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_2, 18) + .setDirection(ProgressBar.Direction.RIGHT) + .setProgress(() -> (progressSupplier.get() - ((float) bar1Width / (bar1Width + bar2Width))) + * ((float) (bar1Width + bar2Width) / bar2Width)) + .setSynced(false, false) + .setPos(new Pos2d(124, 8).add(windowOffset)) + .setSize(bar2Width, 72)); + builder.widget(new ProgressBar() + .setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_3, 18) + .setDirection(ProgressBar.Direction.UP) + .setProgress(progressSupplier) + .setSynced(false, false) + .setPos(new Pos2d(146, 26).add(windowOffset)) + .setSize(10, 18)); } } } |