From dba5dc11db2df1bfe025b15d3252f4808fc36dd0 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:04:55 -0600 Subject: Add number formatting to overlooked spot --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 57f7073e24..2b1f956177 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 @@ -206,7 +206,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } else { if (mInventory[getStackDisplaySlot()] == null) mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + GT_Utility.formatNumbers(aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); } } else { long tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); -- cgit From 18ded5ca058e81b941f1d51a9f24b51f4cc70a6e Mon Sep 17 00:00:00 2001 From: Florexiz Date: Mon, 27 Sep 2021 17:59:33 +0300 Subject: Implemented limiting mode for input busses (same as in singleblocks) --- .../GT_MetaTileEntity_Hatch_InputBus.java | 29 +++++++++++++++++++--- src/main/resources/assets/gregtech/lang/en_US.lang | 4 +++ 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 cfb4d33150..f7bfbf2b38 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 @@ -8,6 +8,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ClientPreference; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.extensions.ArrayExt; @@ -23,6 +24,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public boolean disableSort; public boolean disableFilter = false; + public boolean disableLimited = true; public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier) { this(id, name, nameRegional, tier, getSlots(tier)); @@ -162,6 +164,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { super.saveNBTData(aNBT); aNBT.setBoolean("disableSort", disableSort); aNBT.setBoolean("disableFilter", disableFilter); + aNBT.setBoolean("disableLimited", disableLimited); } @Override @@ -169,6 +172,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { super.loadNBTData(aNBT); disableSort = aNBT.getBoolean("disableSort"); disableFilter = aNBT.getBoolean("disableFilter"); + disableLimited = aNBT.getBoolean("disableLimited"); } @Override @@ -176,8 +180,18 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return; if (aPlayer.isSneaking()) { - disableSort = !disableSort; - GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled"))); + if(disableSort) { + disableSort = false; + } else { + if(disableLimited) { + disableLimited = false; + } else { + disableSort = true; + disableLimited = true; + } + } + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableSort." + disableSort) + " " + + StatCollector.translateToLocal("GT5U.hatch.disableLimited." + disableLimited)); } else { disableFilter = !disableFilter; GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + disableFilter)); @@ -196,6 +210,15 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)); + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)) + && (disableLimited || limitedAllowPutStack(aIndex, aStack)); + } + + protected boolean limitedAllowPutStack(int aIndex, ItemStack aStack) { + for (int i = 0; i < getSizeInventory(); i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) + return i == aIndex; + return mInventory[aIndex] == null; } } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index e173f9cfea..fba0af15df 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -72,6 +72,10 @@ GT5U.machines.voidoveflow.disabled=Overflow voiding disabled GT5U.hatch.disableFilter.true=Input Filter Off GT5U.hatch.disableFilter.false=Input Filter On +GT5U.hatch.disableSort.true=Sorting mode: OFF +GT5U.hatch.disableSort.false=Sorting mode: ON +GT5U.hatch.disableLimited.true=Limiting mode: OFF +GT5U.hatch.disableLimited.false=Limiting mode: ON GT5U.multiblock.pollution=Pollution reduced to GT5U.multiblock.energy=Stored Energy -- cgit From 1fd51482b1e301314697b0307703808d89f85589 Mon Sep 17 00:00:00 2001 From: Florexiz Date: Mon, 27 Sep 2021 20:18:03 +0300 Subject: Limiting mode now disabled for already existing busses --- .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 f7bfbf2b38..611b3759e2 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 @@ -172,7 +172,8 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { super.loadNBTData(aNBT); disableSort = aNBT.getBoolean("disableSort"); disableFilter = aNBT.getBoolean("disableFilter"); - disableLimited = aNBT.getBoolean("disableLimited"); + if(aNBT.hasKey("disableLimited")) + disableLimited = aNBT.getBoolean("disableLimited"); } @Override -- cgit From e6002581e33535ea312c9c673b5b78555e3179e1 Mon Sep 17 00:00:00 2001 From: Florexiz Date: Tue, 28 Sep 2021 10:05:45 +0300 Subject: Replaced get() with get_nocopy() --- .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 611b3759e2..5a0a2b680f 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 @@ -218,7 +218,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { protected boolean limitedAllowPutStack(int aIndex, ItemStack aStack) { for (int i = 0; i < getSizeInventory(); i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get_nocopy(aStack), mInventory[i])) return i == aIndex; return mInventory[aIndex] == null; } -- cgit From 2eb9ef0cd4f00419e20fc56b0acef5a6707ee010 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Tue, 5 Oct 2021 20:46:59 +0800 Subject: allow single block generators accept long value the single block Naq V gens fuel value is over max int, so it will fail to accept. --- .../GT_MetaTileEntity_BasicGenerator.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 2b1f956177..bb7b795c36 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 @@ -222,6 +222,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || solidFuelOverride(mInventory[getInputSlot()]))) { long tFuelValue = getFuelValue(mInventory[getInputSlot()]); + if (tFuelValue <= 0) tFuelValue = getFuelValue(mInventory[getInputSlot()], true); //System.out.println(" tFuelValue : " + tFuelValue ); if (tFuelValue > 0) { ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); @@ -279,7 +280,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(aLiquid) / 100; if(val> Integer.MAX_VALUE){ - throw new ArithmeticException("Integer LOOPBACK!"); + val = 0; } return (int) val; } @@ -291,13 +292,35 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (tFuel != null){ long val=(long)tFuel.mSpecialValue * 10L /*<- 1000mb/100 */ * getEfficiency(); if(val> Integer.MAX_VALUE){ - throw new ArithmeticException("Integer LOOPBACK!"); + val = 0; } return (int) val; } return 0; } + public long getFuelValue(FluidStack aLiquid, boolean aLong) { + //System.out.println("Fluid stack check"); + GT_Recipe_Map tRecipes = getRecipes(); + if (aLiquid == null || !(tRecipes instanceof GT_Recipe.GT_Recipe_Map_Fuel)) return 0; + GT_Recipe.GT_Recipe_Map_Fuel tFuels = (GT_Recipe.GT_Recipe_Map_Fuel) tRecipes; + GT_Recipe tFuel = tFuels.findFuel(aLiquid); + if (tFuel == null) { + return 0; + } + return (long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(aLiquid) / 100; + } + + public long getFuelValue(ItemStack aStack, boolean aLong) { + //System.out.println("Item stack check"); + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null){ + return (long)tFuel.mSpecialValue * 10L /*<- 1000mb/100 */ * getEfficiency(); + } + return 0; + } + public ItemStack getEmptyContainer(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); @@ -307,7 +330,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(aStack, true) > 0) || (getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true), true) > 0); } @Override -- cgit From e2ad60c325be21de9b6f4c8e906603d8caf7381f Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Sat, 9 Oct 2021 15:03:51 +0800 Subject: add GUI for output hatch fluid lock --- .../GT_MetaTileEntity_Hatch_Output.java | 139 +++++++++++++-------- .../common/gui/GT_Container_OutputHatch.java | 123 ++++++++++++++++++ .../common/gui/GT_GUIContainer_OutputHatch.java | 39 ++++++ .../assets/gregtech/textures/gui/OutputHatch.png | Bin 0 -> 2728 bytes 4 files changed, 252 insertions(+), 49 deletions(-) create mode 100644 src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java create mode 100644 src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java create mode 100644 src/main/resources/assets/gregtech/textures/gui/OutputHatch.png (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 bb23452220..eb75094a02 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 @@ -6,39 +6,39 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; +import gregtech.common.gui.GT_Container_OutputHatch; +import gregtech.common.gui.GT_GUIContainer_OutputHatch; 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; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; -import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.*; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { - private String lockedFluidName = null; - private EntityPlayer playerThatLockedfluid = null; + private String lockedFluidName = null; + private EntityPlayer playerThatLockedfluid = null; public byte mMode = 0; public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, new String[]{ - "Fluid Output for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L", - "Right click with screwdriver to restrict output", - "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", - "Restricted Output Hatches are given priority for Multiblock Fluid output"}); + super(aID, aName, aNameRegional, aTier, 4, new String[]{ + "Fluid Output for Multiblocks", + "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L", + "Right click with screwdriver to restrict output", + "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", + "Restricted Output Hatches are given priority for Multiblock Fluid output"}); } public GT_MetaTileEntity_Hatch_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); + super(aName, aTier, 4, aDescription, aTextures); } public GT_MetaTileEntity_Hatch_Output(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); + super(aName, aTier, 4, aDescription, aTextures); } @Override @@ -150,6 +150,39 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { return false; } + @Override + public void updateFluidDisplayItem() { + super.updateFluidDisplayItem(); + if (lockedFluidName == null || mMode < 8) mInventory[3] = null; + else { + FluidStack tLockedFluid = FluidRegistry.getFluidStack(lockedFluidName.replace("fluid.", "") + .replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 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); + } + else { + mInventory[3] = null; + } + } + } + + @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()); + } + @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; @@ -170,9 +203,9 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return; if (aPlayer.isSneaking()) { - mMode = (byte) ((mMode + 9) % 10); + mMode = (byte) ((mMode + 9) % 10); } else { - mMode = (byte) ((mMode + 1) % 10); + mMode = (byte) ((mMode + 1) % 10); } String inBrackets; switch (mMode) { @@ -209,29 +242,30 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { this.setLockedFluidName(null); break; case 8: - playerThatLockedfluid = aPlayer; - if (mFluid == null) { + playerThatLockedfluid = aPlayer; + if (mFluid == null) { this.setLockedFluidName(null); - inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); - } else { - this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); - inBrackets = this.getDrainableStack().getLocalizedName(); - } + inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); + } else { + this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); + inBrackets = this.getDrainableStack().getLocalizedName(); + } GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.1", "Outputs items and 1 specific Fluid"), inBrackets)); break; case 9: - playerThatLockedfluid = aPlayer; - if (mFluid == null) { + playerThatLockedfluid = aPlayer; + if (mFluid == null) { this.setLockedFluidName(null); - inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); - } else { - this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); - inBrackets = this.getDrainableStack().getLocalizedName(); - } + inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); + } else { + this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName()); + inBrackets = this.getDrainableStack().getLocalizedName(); + } GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.2", "Outputs 1 specific Fluid"), inBrackets)); break; } } + private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) { if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return false; @@ -260,6 +294,11 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { } return false; } + + public byte getMode() { + return mMode; + } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { if (tryToLockHatch(aPlayer, aSide)) @@ -269,7 +308,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public String trans(String aKey, String aEnglish){ - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); } public boolean outputsSteam() { @@ -283,44 +322,46 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public boolean outputsItems() { return mMode % 4 < 2 && mMode != 9; } - + public boolean isFluidLocked(){ - return mMode == 8 || mMode == 9; + return mMode == 8 || mMode == 9; } - + public String getLockedFluidName() { - return lockedFluidName; + return lockedFluidName; } - + public void setLockedFluidName(String lockedFluidName) { - this.lockedFluidName = lockedFluidName; + this.lockedFluidName = lockedFluidName; } @Override public int getTankPressure() { return +100; } - + @Override protected void onEmptyingContainerWhenEmpty() { - if (this.lockedFluidName == null && this.mFluid != null) { - this.setLockedFluidName(this.mFluid.getUnlocalizedName()); - GT_Utility.sendChatToPlayer(playerThatLockedfluid, String.format(trans("151.4","Sucessfully locked Fluid to %s"), mFluid.getLocalizedName())); - } + if (this.lockedFluidName == null && this.mFluid != null) { + this.setLockedFluidName(this.mFluid.getUnlocalizedName()); + GT_Utility.sendChatToPlayer(playerThatLockedfluid, String.format(trans("151.4","Sucessfully locked Fluid to %s"), mFluid.getLocalizedName())); + } } + @Override public boolean isGivingInformation() { return true; } + @Override public String[] getInfoData() { return new String[]{ - EnumChatFormatting.BLUE + "Output Hatch" + EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName()) + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid == null ? 0 : mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L"+ EnumChatFormatting.RESET, - lockedFluidName == null ? "Not Locked" : ("Locked to " + StatCollector.translateToLocal(getLockedFluidName())) + EnumChatFormatting.BLUE + "Output Hatch" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName()) + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid == null ? 0 : mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L"+ EnumChatFormatting.RESET, + lockedFluidName == null ? "Not Locked" : ("Locked to " + StatCollector.translateToLocal(getLockedFluidName())) }; } -} +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java b/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java new file mode 100644 index 0000000000..1006acebf1 --- /dev/null +++ b/src/main/java/gregtech/common/gui/GT_Container_OutputHatch.java @@ -0,0 +1,123 @@ +package gregtech.common.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import java.nio.ByteBuffer; + +public class GT_Container_OutputHatch extends GT_Container_BasicTank { + + private ByteBuffer buffer; + private String fluidName = ""; + private byte mMode; + + public GT_Container_OutputHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); + addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); + addSlotToContainer(new GT_Slot_Render(mTileEntity, 3, 150, 42)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex == 3 && aMouseclick < 2) { + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) mTileEntity.getMetaTileEntity(); + FluidStack tReadyLockFluid = GT_Utility.getFluidForFilledItem(aPlayer.inventory.getItemStack(), true); + byte tMode = tHatch.getMode(); + // If player click the locker slot with empty or the same fluid cell, clear the lock fluid + if (tReadyLockFluid == null || (tMode >= 8 && tReadyLockFluid.getUnlocalizedName().equals(tHatch.getLockedFluidName()))) { + tHatch.setLockedFluidName(null); + GT_Utility.sendChatToPlayer(aPlayer, trans("300", "Fluid Lock Cleared.")); + tHatch.mMode = 0; + fluidName = ""; + } + else { + tHatch.setLockedFluidName(tReadyLockFluid.getUnlocalizedName()); + GT_Utility.sendChatToPlayer(aPlayer, String.format(trans("151.4", "Sucessfully locked Fluid to %s"), tReadyLockFluid.getLocalizedName())); + tHatch.mMode = 9; + fluidName = tReadyLockFluid.getUnlocalizedName(); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void addCraftingToCrafters(ICrafting clientHandle) { + buffer.putInt(0, fluidName.length()); + buffer.put(Integer.BYTES, mMode); + for (int i = 0; i < fluidName.length(); i++) { + buffer.putChar(Integer.BYTES + Character.BYTES * i + 1, fluidName.charAt(i)); + } + sendStateUpdate(clientHandle); + super.addCraftingToCrafters(clientHandle); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (buffer == null) { + buffer = ByteBuffer.allocate(256); + } + if(mTileEntity.isServerSide()) { + GT_MetaTileEntity_Hatch_Output tile = (GT_MetaTileEntity_Hatch_Output) mTileEntity.getMetaTileEntity(); + if (tile == null) return; + fluidName = tile.getLockedFluidName() == null ? "" : tile.getLockedFluidName(); + mMode = tile.getMode(); + buffer.putInt(0, fluidName.length()); + buffer.put(Integer.BYTES, mMode); + for (int i = 0; i < fluidName.length(); i++) { + buffer.putChar(Integer.BYTES + Character.BYTES * i + 1, fluidName.charAt(i)); + } + for (Object clientHandle : this.crafters) { + sendStateUpdate((ICrafting) clientHandle); + } + } + } + + private void sendStateUpdate(ICrafting clientHandle) { + final int bytes = Character.BYTES * fluidName.length() + Integer.BYTES + 1; + for (int i = 0; i < bytes; i++) { + clientHandle.sendProgressBarUpdate(this, i + 110, buffer.get(i)); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int index, int value) { + super.updateProgressBar(index, value); + index = index - 110; + if(index >= 0 && index < buffer.capacity()) { + buffer.put(index, (byte) value); + } + } + + @SideOnly(Side.CLIENT) + public String getFluidName() { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < buffer.getInt(0); ++i) { + sb.append(buffer.getChar(i * Character.BYTES + Integer.BYTES + 1)); + } + byte mode = buffer.get(Integer.BYTES); + FluidStack tFluid = FluidRegistry.getFluidStack(sb.toString().replace("fluid.", "") + .replace(".name", "").replace("ic2.fluid", "ic2").toLowerCase(), 1); + if (tFluid == null || mode < 8) return "Empty"; + else return tFluid.getLocalizedName().replace("fluid.", ""); + } +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java new file mode 100644 index 0000000000..1adf66c1b7 --- /dev/null +++ b/src/main/java/gregtech/common/gui/GT_GUIContainer_OutputHatch.java @@ -0,0 +1,39 @@ +package gregtech.common.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +public class GT_GUIContainer_OutputHatch extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GT_GUIContainer_OutputHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new GT_Container_OutputHatch(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "OutputHatch.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); + fontRendererObj.drawString(mName, 8, 6, 4210752); + if (mContainer != null) { + fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); + fontRendererObj.drawString(GT_Utility.parseNumberToString(((GT_Container_OutputHatch) mContainer).mContent), 10, 30, 16448255); + fontRendererObj.drawString("Locked Fluid", 101, 20, 16448255); + fontRendererObj.drawString(((GT_Container_OutputHatch) mContainer).getFluidName(), 101, 30, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/textures/gui/OutputHatch.png b/src/main/resources/assets/gregtech/textures/gui/OutputHatch.png new file mode 100644 index 0000000000..e0fd3f527e Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/gui/OutputHatch.png differ -- cgit From e1e7c6d1e708fe24767a0a278ffc1324e77e809f Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Wed, 13 Oct 2021 13:36:22 +0800 Subject: add indicator on hatches --- src/main/java/gregtech/GT_Mod.java | 1 + src/main/java/gregtech/api/enums/Textures.java | 4 ++++ .../implementations/GT_MetaTileEntity_Hatch_Input.java | 10 ++++++++-- .../GT_MetaTileEntity_Hatch_InputBus.java | 10 +++++++--- .../implementations/GT_MetaTileEntity_Hatch_Output.java | 10 ++++++++-- .../GT_MetaTileEntity_Hatch_OutputBus.java | 10 ++++++++-- src/main/java/gregtech/common/GT_Proxy.java | 5 +++++ .../gregtech/textures/blocks/iconsets/FLUID_IN_SIGN.png | Bin 0 -> 1692 bytes .../gregtech/textures/blocks/iconsets/FLUID_OUT_SIGN.png | Bin 0 -> 1699 bytes .../gregtech/textures/blocks/iconsets/ITEM_IN_SIGN.png | Bin 0 -> 1700 bytes .../gregtech/textures/blocks/iconsets/ITEM_OUT_SIGN.png | Bin 0 -> 1696 bytes 11 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_IN_SIGN.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_OUT_SIGN.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_IN_SIGN.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_OUT_SIGN.png (limited to 'src/main/java/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 5266eb246c..777cea09e5 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -337,6 +337,7 @@ public class GT_Mod implements IGT_Mod { gregtechproxy.mRenderTileAmbientOcclusion = GregTech_API.sClientDataFile.get("render", "TileAmbientOcclusion", true); gregtechproxy.mRenderGlowTextures = GregTech_API.sClientDataFile.get("render", "GlowTextures", true); gregtechproxy.mRenderFlippedMachinesFlipped = GregTech_API.sClientDataFile.get("render", "RenderFlippedMachinesFlipped", true); + gregtechproxy.mRenderIndicatorsOnHatch = GregTech_API.sClientDataFile.get("render", "RenderIndicatorsOnHatch", true); gregtechproxy.mMaxEqualEntitiesAtOneSpot = tMainConfig.get(aTextGeneral, "MaxEqualEntitiesAtOneSpot", 3).getInt(3); gregtechproxy.mSkeletonsShootGTArrows = tMainConfig.get(aTextGeneral, "SkeletonsShootGTArrows", 16).getInt(16); diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index c4c18b8725..6baa3c260e 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -468,6 +468,10 @@ public class Textures { OVERLAY_PIPE, OVERLAY_PIPE_IN, OVERLAY_PIPE_OUT, + FLUID_OUT_SIGN, + FLUID_IN_SIGN, + ITEM_IN_SIGN, + ITEM_OUT_SIGN, OVERLAY_MUFFLER, OVERLAY_CONTROLLER, 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 fd7eb0fc94..a0fc7abcc7 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 @@ -1,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -10,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @@ -31,12 +33,16 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override 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 5a0a2b680f..96667ddb8c 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 @@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; +import static gregtech.api.enums.Textures.BlockIcons.*; public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; @@ -53,12 +53,16 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override 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 eb75094a02..0919961af0 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 @@ -1,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -17,6 +18,7 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @@ -43,12 +45,16 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override 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 f997f5f489..60832dd4d9 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 @@ -1,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import gregtech.GT_Mod; import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -12,6 +13,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +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; @@ -50,12 +52,16 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} : + new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 282542c152..ae95184062 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -230,6 +230,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { */ public boolean mRenderFlippedMachinesFlipped = true; + /** + * This enables indicators on input/output hatches + */ + public boolean mRenderIndicatorsOnHatch = true; + public static final int GUI_ID_COVER_SIDE_BASE = 10; // Takes GUI ID 10 - 15 public static Map oreDictBurnTimes = new HashMap<>(); diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_IN_SIGN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_IN_SIGN.png new file mode 100644 index 0000000000..a78a13db69 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_IN_SIGN.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_OUT_SIGN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_OUT_SIGN.png new file mode 100644 index 0000000000..60aa2fe90a Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/FLUID_OUT_SIGN.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_IN_SIGN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_IN_SIGN.png new file mode 100644 index 0000000000..10dd12f753 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_IN_SIGN.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_OUT_SIGN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_OUT_SIGN.png new file mode 100644 index 0000000000..831650cb28 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/ITEM_OUT_SIGN.png differ -- cgit From 0a5c21841fa3eb0ad581173868a06983e0bc0baf Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:18:55 +0800 Subject: Make Input Bus and Input Hatch to remember recipe map This recipe map is used to filter input. After chunk load, there will be a short delay between event "chunk finished loading" and "multiblock controller sets the recipe map". Not remembering it makes the hatch to temporarily accept arbitrary input until that happens. --- .../implementations/GT_MetaTileEntity_Hatch_Input.java | 14 ++++++++++++++ .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 3 +++ src/main/java/gregtech/api/util/GT_Recipe.java | 13 +++++++++++++ 3 files changed, 30 insertions(+) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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 a0fc7abcc7..2ff1e87348 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 @@ -9,6 +9,7 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; @@ -65,6 +66,19 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { return new GT_MetaTileEntity_Hatch_Input(mName, mTier, mDescriptionArray, mTextures); } + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (mRecipeMap != null) + aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRecipeMap = GT_Recipe_Map.sIndexedMappings.getOrDefault(aNBT.getString("recipeMap"), null); + } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) 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 96667ddb8c..37a98162b8 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 @@ -169,6 +169,8 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { aNBT.setBoolean("disableSort", disableSort); aNBT.setBoolean("disableFilter", disableFilter); aNBT.setBoolean("disableLimited", disableLimited); + if (mRecipeMap != null) + aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); } @Override @@ -178,6 +180,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { disableFilter = aNBT.getBoolean("disableFilter"); if(aNBT.hasKey("disableLimited")) disableLimited = aNBT.getBoolean("disableLimited"); + mRecipeMap = GT_Recipe_Map.sIndexedMappings.getOrDefault(aNBT.getString("recipeMap"), null); } @Override diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 6130adfaef..118d1e31a8 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -572,6 +572,10 @@ public class GT_Recipe implements Comparable { * Contains all Recipe Maps */ public static final Collection sMappings = new ArrayList<>(); + /** + * All recipe maps indexed by their {@link #mUniqueIdentifier}. + */ + public static final 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); 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); @@ -685,6 +689,12 @@ public class GT_Recipe implements Comparable { public final int mUsualInputCount, mUsualOutputCount, mNEISpecialValueMultiplier, mMinimalInputItems, mMinimalInputFluids, mAmperage; public final boolean mNEIAllowed, mShowVoltageAmperageInNEI; + /** + * Unique identifier for this recipe map. Generated from aUnlocalizedName and a few other parameters. + * See constructor for details. + */ + public final String mUniqueIdentifier; + /** * Initialises a new type of Recipe Handler. * @@ -717,6 +727,9 @@ public class GT_Recipe implements Comparable { GregTech_API.sFluidMappings.add(mRecipeFluidMap); GregTech_API.sItemStackMappings.add(mRecipeItemMap); GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName); + mUniqueIdentifier = String.format("%s_%d_%d_%d_%d_%d", aUnlocalizedName, aAmperage, aUsualInputCount, aUsualOutputCount, aMinimalInputFluids, aMinimalInputItems); + if (sIndexedMappings.put(mUniqueIdentifier, this) != null) + throw new IllegalArgumentException("Duplicate recipe map registered: " + mUniqueIdentifier); } public GT_Recipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { -- cgit