diff options
Diffstat (limited to 'src/main/java/gregtech/api/gui')
33 files changed, 913 insertions, 646 deletions
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; + } +} |