From ad5b4e6e71af48c2a39f27865454d6707a6d830d Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Thu, 1 Jul 2021 19:48:29 +0800 Subject: make item filter recipe more reasonable --- .../java/gregtech/common/items/GT_MetaGenerated_Item_01.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java index f0904485d4..9bac6eefe4 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java @@ -849,17 +849,13 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 { GregTech_API.registerCover(ItemList.Cover_NeedsMaintainance.get(1L), TextureFactory.of(MACHINE_CASINGS[2][0], TextureFactory.of(TextureFactory.of(OVERLAY_ACTIVITYDETECTOR), TextureFactory.builder().addIcon(OVERLAY_ACTIVITYDETECTOR_GLOW).glow().build())), new GT_Cover_NeedMaintainance()); GT_Values.RA.addAssemblerRecipe(ItemList.Emitter_MV.get(1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), ItemList.Cover_NeedsMaintainance.get(1L), 600, 24); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plateDouble.get(Materials.StainlessSteel),'S',OrePrefixes.screw.get(Materials.StainlessSteel),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_HV}); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plateDouble.get(Materials.StainlessSteel),'S',OrePrefixes.screw.get(Materials.StainlessSteel),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_HV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{ItemList.ItemFilter_Import.get(1L)}); GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{ItemList.ItemFilter_Export.get(1L)}); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.SolderingAlloy.getMolten(72L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.Tin.getMolten(144L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(1)},Materials.Lead.getMolten(288L),ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.SolderingAlloy.getMolten(72L),ItemList.ItemFilter_Import.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.Tin.getMolten(144L),ItemList.ItemFilter_Import.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plateDouble,Materials.StainlessSteel,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_HV.get(1L),GT_Utility.getIntegratedCircuit(2)},Materials.Lead.getMolten(288L),ItemList.ItemFilter_Import.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(1)},null,ItemList.ItemFilter_Export.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(2)},null,ItemList.ItemFilter_Import.get(1L),100,30); } private static final Map cauldronRemap =new HashMap<>(); -- cgit From 0b1fb32ae1b83cb91e9d83ff4c229172f5aa7700 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Fri, 2 Jul 2021 14:42:23 +0800 Subject: add the space --- .../java/gregtech/common/items/GT_MetaGenerated_Item_01.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java index 9bac6eefe4..839e7db715 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java @@ -849,13 +849,13 @@ public class GT_MetaGenerated_Item_01 extends GT_MetaGenerated_Item_X32 { GregTech_API.registerCover(ItemList.Cover_NeedsMaintainance.get(1L), TextureFactory.of(MACHINE_CASINGS[2][0], TextureFactory.of(TextureFactory.of(OVERLAY_ACTIVITYDETECTOR), TextureFactory.builder().addIcon(OVERLAY_ACTIVITYDETECTOR_GLOW).glow().build())), new GT_Cover_NeedMaintainance()); GT_Values.RA.addAssemblerRecipe(ItemList.Emitter_MV.get(1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), ItemList.Cover_NeedsMaintainance.get(1L), 600, 24); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{"SPS","dIC","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); - GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{"SPS","CId","SPS",'P',OrePrefixes.plate.get(Materials.Tin),'S',OrePrefixes.screw.get(Materials.Iron),'I',ItemList.Component_Filter,'C',ItemList.Conveyor_Module_LV}); - GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L),new Object[]{ItemList.ItemFilter_Import.get(1L)}); - GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L),new Object[]{ItemList.ItemFilter_Export.get(1L)}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Export.get(1L), new Object[]{"SPS", "dIC", "SPS", 'P', OrePrefixes.plate.get(Materials.Tin), 'S', OrePrefixes.screw.get(Materials.Iron), 'I', ItemList.Component_Filter, 'C', ItemList.Conveyor_Module_LV}); + GT_ModHandler.addCraftingRecipe(ItemList.ItemFilter_Import.get(1L), new Object[]{"SPS", "CId", "SPS", 'P', OrePrefixes.plate.get(Materials.Tin), 'S', OrePrefixes.screw.get(Materials.Iron), 'I', ItemList.Component_Filter, 'C', ItemList.Conveyor_Module_LV}); + GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Export.get(1L), new Object[]{ItemList.ItemFilter_Import.get(1L)}); + GT_ModHandler.addShapelessCraftingRecipe(ItemList.ItemFilter_Import.get(1L), new Object[]{ItemList.ItemFilter_Export.get(1L)}); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(1)},null,ItemList.ItemFilter_Export.get(1L),100,30); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L),ItemList.Component_Filter.get(1L),ItemList.Conveyor_Module_LV.get(1L),GT_Utility.getIntegratedCircuit(2)},null,ItemList.ItemFilter_Import.get(1L),100,30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L), ItemList.Component_Filter.get(1L), ItemList.Conveyor_Module_LV.get(1L), GT_Utility.getIntegratedCircuit(1)}, null, ItemList.ItemFilter_Export.get(1L), 100, 30); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.plate,Materials.Tin,2L), ItemList.Component_Filter.get(1L), ItemList.Conveyor_Module_LV.get(1L), GT_Utility.getIntegratedCircuit(2)}, null, ItemList.ItemFilter_Import.get(1L), 100, 30); } private static final Map cauldronRemap =new HashMap<>(); -- cgit From 9b5d86f4cdc16e33a594d48744fd21be8f4530ec Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 3 Jul 2021 14:57:49 +0800 Subject: Remove unnecessary redstone state query for covers Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java | 3 ++- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 3 ++- src/main/java/gregtech/api/util/GT_CoverBehavior.java | 4 ++++ src/main/java/gregtech/common/covers/GT_Cover_Arm.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Crafting.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Drain.java | 4 ++++ src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java | 4 ++++ src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Lens.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Pump.java | 5 +++++ .../java/gregtech/common/covers/GT_Cover_RedstoneConductor.java | 5 +++++ .../gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java | 5 +++++ .../java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java | 5 +++++ .../common/covers/GT_Cover_RedstoneTransmitterInternal.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Screen.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_Shutter.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java | 5 +++++ src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java | 6 ++++++ src/main/java/gregtech/common/covers/GT_Cover_Vent.java | 5 +++++ 28 files changed, 132 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index b51377550b..7f8efed8ce 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -279,7 +279,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + byte tRedstone = tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) ? getInputRedstoneSignal(i) : 0; + mCoverData[i] = tCover.doCoverThings(i, tRedstone, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); if (!hasValidMetaTileEntity()) return; } } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 341e7d5714..6c43799638 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -377,7 +377,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + byte tRedstone = tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) ? getInputRedstoneSignal(i) : 0; + mCoverData[i] = tCover.doCoverThings(i, tRedstone, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); if (!hasValidMetaTileEntity()) { mRunningThroughTick = false; return; diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java index ebd3a98d55..14c8cc1308 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java @@ -18,6 +18,10 @@ public abstract class GT_CoverBehavior { public EntityPlayer lastPlayer = null; + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return true; + } + /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java index c686f99c0b..ed60929719 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Arm.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Arm.java @@ -30,6 +30,11 @@ public class GT_Cover_Arm extends GT_CoverBehavior { this.mTickRate = aTickRate; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((((aTileEntity instanceof IMachineProgress)) && (!((IMachineProgress) aTileEntity).isAllowedToWork()))) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java index b86f950e23..de3dd5c4d7 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Conveyor.java @@ -30,6 +30,11 @@ public class GT_Cover_Conveyor extends GT_CoverBehavior { this.mMaxStacks = maxStacks; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java index 3cf0742d52..0bed5423dd 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Crafting.java @@ -8,6 +8,11 @@ import net.minecraft.inventory.ContainerWorkbench; import net.minecraft.network.play.server.S2DPacketOpenWindow; public class GT_Cover_Crafting extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { if ((aPlayer instanceof EntityPlayerMP)) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java index fbbaa32472..49741d4091 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_DoesWork.java @@ -15,6 +15,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_DoesWork extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aTileEntity instanceof IMachineProgress)) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java index 5fa2244761..8dd2dbddaa 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Drain.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Drain.java @@ -15,6 +15,10 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidHandler; public class GT_Cover_Drain extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 3 > 1) && ((aTileEntity instanceof IMachineProgress))) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java index 3af57ad081..1da5f2a6e2 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EUMeter.java @@ -20,6 +20,11 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; public class GT_Cover_EUMeter extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { long tScale = 0L; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java b/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java index 6326cbbe41..fa60fcb374 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_EnergyOnly.java @@ -8,6 +8,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_EnergyOnly extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + 1) % 3; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java index d68b29e61b..a53545802a 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java @@ -63,6 +63,11 @@ public class GT_Cover_FluidRegulator extends GT_CoverBehavior { return aFlowRate & ~TICK_RATE_BITMASK | (tToStore << SPEED_LENGTH); } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java index 0c0cb27d1f..7aab35ddaa 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java @@ -39,6 +39,10 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehavior { return(String.format("Filtering Fluid: %s Mode: %s", sFluid.getLocalizedName(), getFilterMode(aFilterMode))); } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java index 90c09f8168..99003e18e0 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemFilter.java @@ -28,6 +28,11 @@ public class GT_Cover_ItemFilter extends GT_CoverBehavior { this.mExport = isExport; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { TileEntity tTileEntity = aTileEntity.getTileEntityAtSide(aSide); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java index 5d26f2079e..0bd90745a4 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java @@ -25,6 +25,11 @@ public class GT_Cover_ItemMeter extends GT_CoverBehavior { private static final int CONVERTED_BIT = 0x80000000; private static final int INVERT_BIT = 0x40000000; + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { //Convert from ver. 5.09.33.50 diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Lens.java b/src/main/java/gregtech/common/covers/GT_Cover_Lens.java index 347a6acfcc..37405e6fa8 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Lens.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Lens.java @@ -10,6 +10,11 @@ public class GT_Cover_Lens extends GT_CoverBehavior { this.mColor = aColor; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public byte getLensColor(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return this.mColor; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java index 9fa819cd33..ed75bca967 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_LiquidMeter.java @@ -17,6 +17,11 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; public class GT_Cover_LiquidMeter extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aTileEntity instanceof IFluidHandler)) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java b/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java index 5a5d02b71d..50b7c443d7 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_NeedMaintainance.java @@ -23,6 +23,11 @@ public class GT_Cover_NeedMaintainance extends GT_CoverBehavior { return !(aRotor == null || !(aRotor.getItem() instanceof GT_MetaGenerated_Tool) || aRotor.getItemDamage() < 170 || aRotor.getItemDamage() > 176); } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { boolean needsRepair = false; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java b/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java index 5857c92dab..b57299ed94 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_PlayerDetector.java @@ -19,6 +19,11 @@ public class GT_Cover_PlayerDetector extends GT_CoverBehavior { private String placer = ""; private int range = 8; + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { boolean playerDetected = false; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java index a5b860c0a4..3d937d43fb 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java @@ -23,6 +23,11 @@ public class GT_Cover_Pump extends GT_CoverBehavior{ this.mTransferRate = aTransferRate; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aCoverVariable % 6 > 1) && ((aTileEntity instanceof IMachineProgress))) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java index 41d1861ca1..697d80a243 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneConductor.java @@ -7,6 +7,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_RedstoneConductor extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if (aCoverVariable == 0) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java index 0bf008419b..a4649629d8 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneReceiverExternal.java @@ -4,6 +4,11 @@ import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.ICoverable; public class GT_Cover_RedstoneReceiverExternal extends GT_Cover_RedstoneWirelessBase { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { aTileEntity.setOutputRedstoneSignal(aSide, GregTech_API.sWirelessRedstone.get(Integer.valueOf(aCoverVariable)) == null ? 0 : ((Byte) GregTech_API.sWirelessRedstone.get(Integer.valueOf(aCoverVariable))).byteValue()); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java index cf322e78f1..221f5ea5ce 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneSignalizer.java @@ -8,6 +8,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_RedstoneSignalizer extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { aCoverVariable = (aCoverVariable + 1) % 48; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java index 1c683966f9..94741f6b36 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_RedstoneTransmitterInternal.java @@ -4,6 +4,11 @@ import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.ICoverable; public class GT_Cover_RedstoneTransmitterInternal extends GT_Cover_RedstoneWirelessBase { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { GregTech_API.sWirelessRedstone.put(Integer.valueOf(aCoverVariable), Byte.valueOf(aTileEntity.getOutputRedstoneSignal(aSide))); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Screen.java b/src/main/java/gregtech/common/covers/GT_Cover_Screen.java index afa79b5993..c0de124a7a 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Screen.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Screen.java @@ -6,6 +6,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_Screen extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public float getBlastProofLevel(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return 20.0F; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java b/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java index fbf5ccca33..6fdc69e0fa 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Shutter.java @@ -14,6 +14,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.Fluid; public class GT_Cover_Shutter extends GT_CoverBehavior { + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java index 001dc3c023..ae1b73b8cb 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_SolarPanel.java @@ -16,6 +16,11 @@ public class GT_Cover_SolarPanel extends GT_CoverBehavior { this.mVoltage = aVoltage; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if(aSide != 1)return 0; diff --git a/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java b/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java index 8ac8a0dae9..8d4ac949b7 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_SteamValve.java @@ -1,5 +1,6 @@ package gregtech.common.covers; +import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.util.GT_ModHandler; import net.minecraftforge.fluids.FluidStack; @@ -9,6 +10,11 @@ public class GT_Cover_SteamValve extends GT_Cover_Pump { super(aTransferRate); } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override protected boolean canTransferFluid(FluidStack fluid) { return GT_ModHandler.isAnySteam(fluid); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Vent.java b/src/main/java/gregtech/common/covers/GT_Cover_Vent.java index 869235e011..64347d48e2 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Vent.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Vent.java @@ -12,6 +12,11 @@ public class GT_Cover_Vent extends GT_CoverBehavior { this.mEfficiency = aEfficiency; } + @Override + public boolean isRedstoneSensitive(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + return false; + } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if ((aTileEntity instanceof IMachineProgress)) { -- cgit From 3cd37168292e6a1387ad8e148741c20c7226c03c Mon Sep 17 00:00:00 2001 From: Prometheus0000 Date: Sat, 3 Jul 2021 16:38:42 -0400 Subject: Fix radon recipe amount/time --- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index d886055050..9b8bc68aa5 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -1298,7 +1298,7 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addChemicalRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Blaze, 1L), new ItemStack(Items.slime_ball, 1, 32767), new ItemStack(Items.magma_cream, 1, 0), 50); GT_Values.RA.addChemicalRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 8), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Uranium, 1), Materials.Air.getGas(1000), Materials.Radon.getGas(100), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 8), 12000, 8); - GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 64L), GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 8L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Uranium, 1L), GT_Utility.getIntegratedCircuit(9)}, new FluidStack[]{Materials.Air.getGas(9000L)}, new FluidStack[]{Materials.Radon.getGas(900L)}, new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 64L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 8L)}, 1688, 512); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 64L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Uranium, 1L), GT_Utility.getIntegratedCircuit(8)}, new FluidStack[]{Materials.Air.getGas(8000L)}, new FluidStack[]{Materials.Radon.getGas(800L)}, new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 64L)}, 3000, 512); GT_Values.RA.addChemicalBathRecipe(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.EnderEye, 1), Materials.Radon.getGas(250), ItemList.QuantumEye.get(1L), null, null, null, 480, 384); GT_Values.RA.addChemicalBathRecipe(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.NetherStar, 1), Materials.Radon.getGas(1250), ItemList.QuantumStar.get(1L), null, null, null, 1920, 384); GT_Values.RA.addAutoclaveRecipe(GT_OreDictUnificator.get(ItemList.QuantumStar.get(1L)), Materials.Neutronium.getMolten(288), ItemList.Gravistar.get(1L), 10000, 480, 7680); -- cgit From 52568b0a51a2a512d5ad6eb9559fe342a97781a5 Mon Sep 17 00:00:00 2001 From: Prometheus0000 Date: Sun, 4 Jul 2021 02:27:21 -0400 Subject: 480 --- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 9b8bc68aa5..2e49a3888c 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -1298,7 +1298,7 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addChemicalRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Blaze, 1L), new ItemStack(Items.slime_ball, 1, 32767), new ItemStack(Items.magma_cream, 1, 0), 50); GT_Values.RA.addChemicalRecipe(GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 8), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Uranium, 1), Materials.Air.getGas(1000), Materials.Radon.getGas(100), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 8), 12000, 8); - GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 64L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Uranium, 1L), GT_Utility.getIntegratedCircuit(8)}, new FluidStack[]{Materials.Air.getGas(8000L)}, new FluidStack[]{Materials.Radon.getGas(800L)}, new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 64L)}, 3000, 512); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Plutonium, 64L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Uranium, 1L), GT_Utility.getIntegratedCircuit(8)}, new FluidStack[]{Materials.Air.getGas(8000L)}, new FluidStack[]{Materials.Radon.getGas(800L)}, new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Plutonium, 64L)}, 3000, 480); GT_Values.RA.addChemicalBathRecipe(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.EnderEye, 1), Materials.Radon.getGas(250), ItemList.QuantumEye.get(1L), null, null, null, 480, 384); GT_Values.RA.addChemicalBathRecipe(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.NetherStar, 1), Materials.Radon.getGas(1250), ItemList.QuantumStar.get(1L), null, null, null, 1920, 384); GT_Values.RA.addAutoclaveRecipe(GT_OreDictUnificator.get(ItemList.QuantumStar.get(1L)), Materials.Neutronium.getMolten(288), ItemList.Gravistar.get(1L), 10000, 480, 7680); -- cgit From 65e4a0fa613c53b725a1473682f518ce38eecf6c Mon Sep 17 00:00:00 2001 From: "[Kiwi233]" <[huaxia0611@qq.com]> Date: Mon, 5 Jul 2021 22:10:05 +0800 Subject: update for gregtech-5.09.35.00 --- src/main/resources/assets/gregtech/lang/en_US.lang | 84 ++++++++++++++ src/main/resources/assets/gregtech/lang/zh_CN.lang | 126 +++++++++++++++++++-- 2 files changed, 198 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 51b792f44f..b0d0018312 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -1047,3 +1047,87 @@ gregtech.lifeBlink=Blink gregtech.lifeEon=Eon entity.gregtech.GT_Entity_Arrow.name= a GregTech arrow + +fluid.Xenon=Xenon +fluid.FermentedBacterialSludge=Fermented Bacterial Sludge +fluid.NitricAcid=Nitric Acid +fluid.EnrichedBacterialSludge=Enriched Bacterial Sludge +fluid.Ammonia=Ammonia +fluid.Neon=Neon +fluid.Oganesson=Oganesson +fluid.Aqua Regia=Aqua Regia +fluid.Ammonium Chloride=Ammonium Chloride +fluid.Platinum Concentrate=Platinum Concentrate +fluid.Sodium Formate=Sodium Formate +fluid.Formic Acid=Formic Acid +fluid.Palladium Enriched Ammonia=Palladium Enriched Ammonia +fluid.Ruthenium Tetroxide=Ruthenium Tetroxide +fluid.Hot Ruthenium Tetroxide Solution=Hot Ruthenium Tetroxide Solution +fluid.Ruthenium Tetroxide Solution=Ruthenium Tetroxide Solution +fluid.Rhodium Sulfate=Rhodium Sulfate +fluid.Rhodium Sulfate Solution=Rhodium Sulfate Solution +fluid.Calcium Chloride=Calcium Chloride +fluid.Acidic Osmium Solution=Acidic Osmium Solution +fluid.Osmium Solution=Osmium Solution +fluid.Acidic Iridium Solution=Acidic Iridium Solution +fluid.Rhodium Salt Solution=Rhodium Salt Solution +fluid.Rhodium Filter Cake Solution=Rhodium Filter Cake Solution +fluid.Pollution=Pollution +fluid.SodiumPotassium=Sodium Potassium +fluid.Concrete=Concrete +fluid.mushroomStew=Mushroom Stew + +fluid.Sodium Tungstate=Sodium Tungstate +fluid.Phosgene=Phosgene +fluid.Ethyl Chloroformate=Ethyl Chloroformate +fluid.Ethyl Carbamate=Ethyl Carbamate +fluid.Ethyl N-nitrocarbamate=Ethyl N-nitrocarbamate +fluid.Ammonium N-nitrourethane=Ammonium N-nitrourethane +fluid.Trinitramid=Trinitramid +fluid.Ammonia Boronfluoride Solution=Ammonia Boronfluoride Solution +fluid.Sodium Tetrafluoroborate=Sodium Tetrafluoroborate +fluid.Tetrafluoroborate=Tetrafluoroborate +fluid.Ethyl Acetate=Ethyl Acetate +fluid.Acetylhydrazine=Acetylhydrazine +fluid.Unsymmetrical Dimethylhydrazine=Unsymmetrical Dimethylhydrazine +fluid.Monomethylhydrazine Fuel Mix=Monomethylhydrazine Fuel Mix +fluid.Unsymmetrical Dimethylhydrazine Fuel Mix=Unsymmetrical Dimethylhydrazine Fuel Mix +fluid.Boron Trifluoride=Boron Trifluoride +fluid.Tert-Butylbenzene=Tert-Butylbenzene +fluid.2-tert-butyl-anthraquinone=2-tert-butyl-anthraquinone +fluid.2-tert-butyl-anthrahydroquinone=2-tert-butyl-anthrahydroquinone +fluid.Hydrogen Peroxide=Hydrogen Peroxide +fluid.hydrazine=hydrazine +fluid.Dimethyl Sulfate=Dimethyl Sulfate +fluid.Ethyl Dinitrocarbamate=Ethyl Dinitrocarbamate +fluid.Ammonium Dinitramide=Ammonium Dinitramide +fluid.LMP-103S=LMP-103S +fluid.Nitromethane=Nitromethane +fluid.O-Xylene=O-Xylene +//No cell, most from bart bio +fluid.Monomethylhydrazine=Monomethylhydrazine +fluid.binnibacteriafluid=binnibacteriafluid +fluid.SeaweedBroth=SeaweedBroth +fluid.barnadafisarboriatorisfluid=barnadafisarboriatorisfluid +fluid.Polymerase=Polymerase +fluid.GelatinMixture=GelatinMixture +fluid.FluorecentdDNA=FluorecentdDNA +fluid.Penicillin=Penicillin +fluid.sludge=sludge +fluid.EnzymesSollution=EnzymesSollution +fluid.Formaldehyde=Formaldehyde +fluid.tcetieisfucusserratusfluid=tcetieisfucusserratusfluid +fluid.MeatExtract=MeatExtract +fluid.UnknownNutrientAgar=UnknownNutrientAgar +//No recipe +fluid.CompressedOxygen=CompressedOxygen +fluid.CompressedNitrogen=CompressedNitrogen +fluid.redplasma=redplasma +fluid.tile.fluidBlockSludge=fluidBlockSludge +//No Textrue +fluid.guano=guano +fluid.poo=poo +fluid.sewerage=sewerage +fluid.fuelgc=fuelgc +fluid.dirtywater=dirtywater +fluid.oilgc=oilgc \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/lang/zh_CN.lang b/src/main/resources/assets/gregtech/lang/zh_CN.lang index a77d59f0eb..5d7ebab206 100644 --- a/src/main/resources/assets/gregtech/lang/zh_CN.lang +++ b/src/main/resources/assets/gregtech/lang/zh_CN.lang @@ -189,7 +189,7 @@ achievement.Powellite=找到钼钙矿矿石 achievement.Powellite.desc=高度:20-50,几率:5,下界/暮色森林/月球/火卫一/谷神星/水星/土卫六/海卫八/冥王星/巴德纳E// achievement.Scheelite=找到白钨矿矿石 achievement.Scheelite.desc=高度:20-60,几率:10,火星/火卫二/小行星/木卫三/木卫四/土卫二/天卫四/海卫一/冥王星/鸟神星/妊神星/织女一B// -achievement.Tungstate=找到钨酸盐矿石 +achievement.Tungstate=找到钨酸锂矿石 achievement.Tungstate.desc=高度:20-60,几率:10,火星/火卫二/小行星/木卫三/木卫四/土卫二/天卫四/海卫一/冥王星/鸟神星/妊神星/织女一B// achievement.Lithium=找到锂矿石 achievement.Lithium.desc=高度:20-60,几率:10,火星/火卫二/小行星/木卫三/木卫四/土卫二/天卫四/海卫一/冥王星/鸟神星/妊神星/织女一B// @@ -453,19 +453,19 @@ achievement.flintpick.desc=制造一把燧石镐 achievement.crops=农业 achievement.crops.desc=制造农作物 achievement.havestlead=收获铅 -achievement.havestlead.desc=得到铅叶花 +achievement.havestlead.desc=得到铅叶子 achievement.havestcopper=收获铜 achievement.havestcopper.desc=得到铜纤维 achievement.havesttin=收获锡 -achievement.havesttin.desc=得到锡叶花 +achievement.havesttin.desc=得到锡叶子 achievement.havestoil=收获石油 achievement.havestoil.desc=得到石油浆果 achievement.havestiron=收获铁 -achievement.havestiron.desc=得到铁叶花 +achievement.havestiron.desc=得到铁叶子 achievement.havestgold=收获金 -achievement.havestgold.desc=得到金叶花 +achievement.havestgold.desc=得到金叶子 achievement.havestsilver=收获银 -achievement.havestsilver.desc=得到银叶花 +achievement.havestsilver.desc=得到银叶子 achievement.havestemeralds=收获绿宝石 achievement.havestemeralds.desc=得到易如反掌浆果 achievement.tools=更多的工具 @@ -543,7 +543,7 @@ achievement.thatspower.desc=得到一个兰波顿能量球簇 achievement.datasaving=数据存储 achievement.datasaving.desc=得到一个数据球 achievement.superbuffer=超级缓冲 -achievement.superbuffer.desc=制造一个LV级大型缓冲器 +achievement.superbuffer.desc=制造一个LV超级缓冲器 achievement.newstorage=新型存储 achievement.newstorage.desc=制造一个量子箱 achievement.whereistheocean=大海在哪里? @@ -568,7 +568,7 @@ achievement.pumpcover=泵 achievement.pumpcover.desc=制造一个电动泵(LV) achievement.closeit=把它关了! achievement.closeit.desc=得到一块扇板 -achievement.slurp=Slurp +achievement.slurp=嘶溜嘶溜 achievement.slurp.desc=制造一台进阶泵 II achievement.transport=运输 achievement.transport.desc=制造一个输送机模块(LV) @@ -587,7 +587,7 @@ achievement.steampower.desc=制造一台基础蒸汽轮机 achievement.batterys=蓄电池 achievement.batterys.desc=制造一个电池箱 achievement.badweather=坏天气 -achievement.badweather.desc=忘记给机器上方建屋顶 +achievement.badweather.desc=忘记在机器上方建屋顶 achievement.electricproblems=电力问题 achievement.electricproblems.desc=因为超过电压损失一台机器 achievement.ebf=电力高炉 @@ -627,7 +627,7 @@ achievement.tungsten.desc=冷却一块热钨锭 achievement.osmium=锇 achievement.osmium.desc=冷却一块热锇锭 achievement.hightech=高科技 -achievement.hightech.desc=制造一台力场产生器(LV) +achievement.hightech.desc=制造一个力场发生器(LV) achievement.amplifier=增幅器 achievement.amplifier.desc=制造一台UU增幅液产生器 achievement.scanning=扫描 @@ -635,9 +635,9 @@ achievement.scanning.desc=完成一次成分扫描 achievement.alienpower=外星能量 achievement.alienpower.desc=制造一台硅岩反应堆Mk.I achievement.universal=通用的 -achievement.universal.desc=制造一台质量加工器 +achievement.universal.desc=制造一台质量发生器 achievement.replication=复制 -achievement.replication.desc=制造一台复制器 +achievement.replication.desc=制造一台复制机 achievement.tungstensteel=钨钢 achievement.tungstensteel.desc=冷却一块热钨钢锭 achievement.upgrade3=升级你的线圈(Lv.3) @@ -775,6 +775,12 @@ achievement.gt.blockmachines.hatch.energy.tier.08=能源仓(UV) achievement.gt.blockmachines.hatch.energy.tier.08.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockmachines.hatch.energy.tier.09=能源仓(UHV) achievement.gt.blockmachines.hatch.energy.tier.09.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.energy.tier.10=能源仓(UEV) +achievement.gt.blockmachines.hatch.energy.tier.10.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.energy.tier.11=能源仓(UIV) +achievement.gt.blockmachines.hatch.energy.tier.11.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.energy.tier.12=能源仓(UMV) +achievement.gt.blockmachines.hatch.energy.tier.12.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockmachines.hatch.dynamo.tier.06=动力仓(LuV) achievement.gt.blockmachines.hatch.dynamo.tier.06.desc=捡起这个物品以在NEI内查看配方 @@ -784,6 +790,12 @@ achievement.gt.blockmachines.hatch.dynamo.tier.08=动力仓(UV) achievement.gt.blockmachines.hatch.dynamo.tier.08.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockmachines.hatch.dynamo.tier.09=动力仓(UHV) achievement.gt.blockmachines.hatch.dynamo.tier.09.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.dynamo.tier.10=动力仓(UEV) +achievement.gt.blockmachines.hatch.dynamo.tier.10.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.dynamo.tier.11=动力仓(UIV) +achievement.gt.blockmachines.hatch.dynamo.tier.11.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.hatch.dynamo.tier.12=动力仓(UMV) +achievement.gt.blockmachines.hatch.dynamo.tier.12.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockmachines.fusioncomputer.tier.06=核聚变反应堆控制电脑Mk I achievement.gt.blockmachines.fusioncomputer.tier.06.desc=捡起这个物品以在NEI内查看配方 @@ -809,6 +821,8 @@ achievement.item.PikoCircuit=Piko电路 achievement.item.PikoCircuit.desc=捡起这个物品以在NEI内查看配方 achievement.item.QuantumCircuit=量子电路 achievement.item.QuantumCircuit.desc=捡起这个物品以在NEI内查看配方 +achievement.item.relocator=定位器 +achievement.item.relocator.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockmachines.multimachine.em.computer=量子计算机 achievement.gt.blockmachines.multimachine.em.computer.desc=捡起这个物品以在NEI内查看配方 @@ -870,6 +884,9 @@ achievement.item.graviChestPlate.desc=捡起这个物品以在NEI内查看配方 achievement.gt.blockreinforced.12=漆黑之门粗胚 achievement.gt.blockreinforced.12.desc=捡起这个物品以在NEI内查看配方 +achievement.gt.blockmachines.debug.tt.maintenance=Debug维护仓 +achievement.gt.blockmachines.debug.tt.maintenance.desc=捡起这个物品以在NEI内查看配方 + for.bees.species.clay=粘土 for.bees.species.slimeball=粘液球 for.bees.species.peat=泥炭 @@ -1029,3 +1046,88 @@ gregtech.speedAccelerated=加速 gregtech.lifeBlink=瞬灭 gregtech.lifeEon=永生 +entity.gregtech.GT_Entity_Arrow.name=GT箭头 + +fluid.Xenon=氙气 +fluid.FermentedBacterialSludge=发酵的细菌污泥 +fluid.NitricAcid=硝酸 +fluid.EnrichedBacterialSludge=放射性细菌污泥 +fluid.Ammonia=氨气 +fluid.Neon=氖气 +fluid.Oganesson=<气奥> +fluid.Aqua Regia=王水 +fluid.Ammonium Chloride=氯化铵 +fluid.Platinum Concentrate=浓缩铂 +fluid.Sodium Formate=甲酸钠 +fluid.Formic Acid=甲酸 +fluid.Palladium Enriched Ammonia=富钯氨 +fluid.Ruthenium Tetroxide=四氧化钌 +fluid.Hot Ruthenium Tetroxide Solution=热四氧化钌溶液 +fluid.Ruthenium Tetroxide Solution=四氧化钌溶液 +fluid.Rhodium Sulfate=硫酸铑 +fluid.Rhodium Sulfate Solution=硫酸铑溶液 +fluid.Calcium Chloride=氯化钙 +fluid.Acidic Osmium Solution=酸性锇溶液 +fluid.Osmium Solution=锇溶液 +fluid.Acidic Iridium Solution=酸性铱溶液 +fluid.Rhodium Salt Solution=铑盐溶液 +fluid.Rhodium Filter Cake Solution=铑滤饼溶液 +fluid.Pollution=污染物 +fluid.SodiumPotassium=钠钾共晶合金(NaK) +fluid.Concrete=混凝土 +fluid.mushroomStew=蘑菇煲 + +fluid.Sodium Tungstate=钨酸钠 +fluid.Phosgene=碳酰氯 +fluid.Ethyl Chloroformate=氯基甲酸乙酯 +fluid.Ethyl Carbamate=氨基甲酸乙酯 +fluid.Ethyl N-nitrocarbamate=N-硝氨基甲酸乙酯 +fluid.Ammonium N-nitrourethane=N-硝氨基甲酸乙酯-铵 +fluid.Trinitramid=三硝基胺 +fluid.Ammonia Boronfluoride Solution=氟化硼氨溶液 +fluid.Sodium Tetrafluoroborate=氟硼酸钠 +fluid.Tetrafluoroborate=氟硼酸 +fluid.Ethyl Acetate=乙酸乙酯 +fluid.Acetylhydrazine=乙酰肼 +fluid.Unsymmetrical Dimethylhydrazine=偏二甲肼 +fluid.Monomethylhydrazine Fuel Mix=一甲基肼混合燃料 +fluid.Unsymmetrical Dimethylhydrazine Fuel Mix=偏二甲肼混合燃料 +fluid.Boron Trifluoride=三氟化硼 +fluid.Tert-Butylbenzene=叔丁基苯 +fluid.2-tert-butyl-anthraquinone=2-叔丁基蒽醌 +fluid.2-tert-butyl-anthrahydroquinone=2-叔丁基蒽氢醌 +fluid.Hydrogen Peroxide=过氧化氢 +fluid.hydrazine=肼 +fluid.Dimethyl Sulfate=硫酸二甲酯 +fluid.Ethyl Dinitrocarbamate=二硝氨基甲酸乙酯 +fluid.Ammonium Dinitramide=二硝酰胺铵 +fluid.LMP-103S=LMP-103S +fluid.Nitromethane=硝基甲烷 +fluid.O-Xylene=邻二甲苯 +//以下流体没有单元形式,大部分是bart的生物科技 +fluid.Monomethylhydrazine=一甲基肼 +fluid.binnibacteriafluid=双杆菌液体 +fluid.SeaweedBroth=海藻基质 +fluid.barnadafisarboriatorisfluid=巴纳德乔木培养液 +fluid.Polymerase=聚合酶 +fluid.GelatinMixture=明胶混合物 +fluid.FluorecentdDNA=荧光DNA +fluid.Penicillin=青霉素 +fluid.sludge=菌泥 +fluid.EnzymesSollution=酶溶液 +fluid.Formaldehyde=甲醛 +fluid.tcetieisfucusserratusfluid=鲸鱼座T星藻类培养液 +fluid.MeatExtract=肉汁 +fluid.UnknownNutrientAgar=未知营养琼脂 +//以下流体有贴图没有配方 +fluid.CompressedOxygen=压缩氧气 +fluid.CompressedNitrogen=压缩氮气 +fluid.redplasma=红等离子体 +fluid.tile.fluidBlockSludge=污泥 +//以下流体没有贴图 +fluid.guano=鸟粪 +fluid.poo=便便 +fluid.sewerage=下水 +fluid.fuelgc=GC燃油 +fluid.dirtywater=污水 +fluid.oilgc=GC石油 \ No newline at end of file -- cgit From c31ba09f8fb68b02879dc2934f3e23d38c3f1ff6 Mon Sep 17 00:00:00 2001 From: korneel vandamme Date: Mon, 5 Jul 2021 17:37:13 +0200 Subject: fix overvolatage null crach --- src/main/java/gregtech/api/graphs/paths/PowerNodePath.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java index 1120fe84e4..1b80c5922d 100644 --- a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java +++ b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java @@ -40,7 +40,9 @@ public class PowerNodePath extends NodePath { for (MetaPipeEntity tCable : mPipes) { if (((GT_MetaPipeEntity_Cable)tCable).mVoltage < this.mVoltage) { BaseMetaPipeEntity tBaseCable = (BaseMetaPipeEntity) tCable.getBaseMetaTileEntity(); - tBaseCable.setToFire(); + if (tBaseCable != null) { + tBaseCable.setToFire(); + } } } } -- cgit From c6680439c28bbd72f178d06172971c0331a08909 Mon Sep 17 00:00:00 2001 From: Ethryan Date: Mon, 5 Jul 2021 19:40:55 +0200 Subject: Lowered rich uranium vein to 55. --- src/main/java/gregtech/loaders/postload/GT_Worldgenloader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_Worldgenloader.java b/src/main/java/gregtech/loaders/postload/GT_Worldgenloader.java index 95e9db8310..55a0736490 100644 --- a/src/main/java/gregtech/loaders/postload/GT_Worldgenloader.java +++ b/src/main/java/gregtech/loaders/postload/GT_Worldgenloader.java @@ -197,7 +197,7 @@ public class GT_Worldgenloader implements Runnable { new GT_Worldgen_GT_Ore_Layer("ore.mix.netherstar", true, 20, 60, 60, 2, 24, false, false, false, Materials.GarnetSand, Materials.NetherStar, Materials.GarnetRed, Materials.GarnetYellow); new GT_Worldgen_GT_Ore_Layer("ore.mix.garnet", true, 10, 30, 40, 2, 16, false, false, false, Materials.GarnetRed, Materials.GarnetYellow, Materials.Chrysotile, Materials.Realgar); new GT_Worldgen_GT_Ore_Layer("ore.mix.rareearth", true, 30, 60, 40, 2, 24, false, false, false, Materials.Cadmium, Materials.Caesium, Materials.Lanthanum, Materials.Cerium); - new GT_Worldgen_GT_Ore_Layer("ore.mix.richnuclear", true, 65, 120, 5, 2, 8, false, false, false, Materials.Uranium, Materials.Plutonium, Materials.Thorium, Materials.Thorium); + new GT_Worldgen_GT_Ore_Layer("ore.mix.richnuclear", true, 55, 120, 5, 2, 8, false, false, false, Materials.Uranium, Materials.Plutonium, Materials.Thorium, Materials.Thorium); new GT_Worldgen_GT_Ore_Layer("ore.mix.heavypentele", true, 40, 60, 60, 5, 32, false, false, false, Materials.Arsenic, Materials.Bismuth, Materials.Antimony, Materials.Antimony); new GT_Worldgen_GT_Ore_Layer("ore.mix.europa", true, 55, 65, 110, 4, 24, false, false, false, Materials.Magnesite, Materials.BandedIron, Materials.Sulfur, Materials.Opal); new GT_Worldgen_GT_Ore_Layer("ore.mix.europacore", true, 5, 15, 5, 2, 16, false, false, false, Materials.Chrome, Materials.Tungstate, Materials.Molybdenum, Materials.Manganese); -- cgit From 6f8016367d6f278f7a39206ff7f9dc73c719c807 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 10 Jul 2021 11:21:34 +0800 Subject: Extended GUI fluid manipulation support to GT_MetaTileEntity_BasicTank --- .../api/gui/GT_Container_BasicMachine.java | 150 +------------- .../gregtech/api/gui/GT_Container_BasicTank.java | 226 +++++++++++++++++++++ .../GT_MetaTileEntity_BasicMachine.java | 2 +- .../GT_MetaTileEntity_BasicTank.java | 2 +- src/main/java/gregtech/api/util/GT_Utility.java | 6 +- .../render/GT_FluidDisplayStackRenderer.java | 2 +- 6 files changed, 243 insertions(+), 145 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 28fd2983f4..5d2a9321c4 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -11,7 +12,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; @@ -195,154 +195,22 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { if (mTileEntity.getMetaTileEntity() == null) return null; machine.mItemTransfer = !machine.mItemTransfer; return null; - case 2: - if (aMouseclick > 1) - return null; - tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer, aMouseclick == 0); - if (machine.getDrainableStack() != null && machine.getDrainableStack().amount == 0) - machine.setDrainableStack(null); - return tResultStack; default: - if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length) { - if (aMouseclick > 1) - return null; - // input fluid slot - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; - FluidStack tInputFluid = machine.getFillableStack(); - FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); - if (tFluidHeld != null && tFluidHeld.amount <= 0) - tFluidHeld = null; - if (tInputFluid == null) { - if (tFluidHeld == null) - // both null -> no op - return null; - return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); - } else { - if (tFluidHeld != null && tInputFluid.amount < machine.getCapacity()) { - // both nonnull and have space left for filling. - // actually both pickup and fill is reasonable, but I'll go with fill here - return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); - } else { - tResultStack = pickupFluid(tInputFluid, aPlayer, aMouseclick == 0); - if (tInputFluid.amount == 0) - machine.setFillableStack(null); - return tResultStack; - } + if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length && aMouseclick < 2) { + if (mTileEntity.isClientSide()) { + // see parent class slotClick for an explanation on why doing this + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + tTank.setFillableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); } + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + IFluidAccess tFillableAccess = IFluidAccess.from(tTank, true); + return handleFluidSlotClick(tFillableAccess, aPlayer, aMouseclick == 0, true, true); } else { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } } } - private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer, boolean aProcessFullStack) { - if (aTankStack == null) return null; - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; - int tOriginalFluidAmount = aTankStack.amount; - ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); - if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { - IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); - int tFilledAmount = tContainerItem.fill(tStackSizedOne, aTankStack, true); - if (tFilledAmount > 0) { - tFilled = tStackSizedOne; - aTankStack.amount -= tFilledAmount; - } - } - if (tFilled != null) { - if (aProcessFullStack) { - int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; - /* - work out how many more items we can fill - one cell is already used, so account for that - the round down behavior will left over a fraction of a cell worth of fluid - the user then get to decide what to do with it - it will not be too fancy if it spills out partially filled cells - */ - int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, aTankStack.amount / tFilledAmount); - aTankStack.amount -= tFilledAmount * tAdditionalParallel; - tFilled.stackSize += tAdditionalParallel; - } - replaceCursorItemStack(aPlayer, tFilled); - } - return tFilled; - } - - private ItemStack fillFluid(GT_MetaTileEntity_BasicMachine aMachine, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { - // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves - if (aMachine.getFillableStack() != null && !aMachine.getFillableStack().isFluidEqual(aFluidHeld)) - return null; - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) - return null; - - int tFreeSpace = aMachine.getCapacity() - (aMachine.getFillableStack() != null ? aMachine.getFillableStack().amount : 0); - if (tFreeSpace <= 0) - // no space left - return null; - - // find out how much fluid can be taken - // some cells cannot be partially filled - ItemStack tStackEmptied = null; - int tAmountTaken = 0; - if (tFreeSpace >= aFluidHeld.amount) { - // fully accepted - try take it from item now - // IFluidContainerItem is intentionally not checked here. it will be checked later - tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); - tAmountTaken = aFluidHeld.amount; - } - if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { - // either partially accepted, or is IFluidContainerItem - IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); - FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); - if (tDrained != null && tDrained.amount > 0) { - // something is actually drained - change the cell and drop it to player - tStackEmptied = tStackSizedOne; - tAmountTaken = tDrained.amount; - } - } - if (tStackEmptied == null) - // somehow the cell refuse to give out that amount of fluid, no op then - return null; - - // find out how many fill can we do - // same round down behavior as above - // however here the fluid stack is not changed at all, so the exact code will slightly differ - int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; - if (aMachine.getFillableStack() == null) { - FluidStack tNewFillableStack = aFluidHeld.copy(); - tNewFillableStack.amount = tAmountTaken * tParallel; - aMachine.setFillableStack(tNewFillableStack); - } else { - aMachine.getFillableStack().amount += tAmountTaken * tParallel; - } - tStackEmptied.stackSize = tParallel; - replaceCursorItemStack(aPlayer, tStackEmptied); - return tStackEmptied; - } - - private void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { - int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); - while (tStackResult.stackSize > tStackResultMaxStackSize) { - aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; - GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); - } - if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { - // every cell is mutated. it could just stay on the cursor. - aPlayer.inventory.setItemStack(tStackResult); - } else { - // some cells not mutated. The mutated cells must go into the inventory - // or drop into the world if there isn't enough space. - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - tStackHeld.stackSize -= tStackResult.stackSize; - GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); - } - } - @Override public void detectAndSendChanges() { super.detectAndSendChanges(); 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 c80874eef4..0ce9ab9232 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -4,9 +4,15 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +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.minecraft.util.ChatComponentText; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -28,6 +34,189 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); } + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex == 2 && aMouseclick < 2) { + if (mTileEntity.isClientSide()) { + /* + * While a logical client don't really need to process fluid cells upon click (it could have just wait + * for server side to send the result), doing so would result in every fluid interaction having a + * noticeable delay between clicking and changes happening even on single player. + * I'd imagine this delay to get only more severe when playing MP over ethernet, which would have much more latency + * than a memory connection + */ + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); + } + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + IFluidAccess tDrainableAccess = IFluidAccess.from(tTank, false); + return handleFluidSlotClick(tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); + } + if (mTileEntity.isServerSide()) { + aPlayer.addChatComponentMessage(new ChatComponentText(String.format("Slot Index: %d, aMouseClick: %d, Shift Hold: %d", aShifthold, aMouseclick, aShifthold))); + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + /** + * Expected to be called on client side only. Load fluid stacks from fluid display items as they were not sent + * over the network. + * Override this if you have more than one fluid display stack. This implementation will set drainable stack according to items + * in slot indexed 2. + * + */ + protected void syncFluidFromFluidDisplayItems() { + GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); + tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); + } + + protected static ItemStack handleFluidSlotClick(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack, boolean aCanDrain, boolean aCanFill) { + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; + FluidStack tInputFluid = aFluidAccess.get(); + FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); + if (tFluidHeld != null && tFluidHeld.amount <= 0) + tFluidHeld = null; + if (tInputFluid == null) { + // tank empty, consider fill only from now on + if (!aCanFill) + // cannot fill and nothing to take, bail out + return null; + if (tFluidHeld == null) + // no fluid to fill + return null; + return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); + } + // tank not empty, both action possible + if (tFluidHeld != null && tInputFluid.amount < aFluidAccess.getCapacity()) { + // both nonnull and have space left for filling. + if (aCanFill) + // actually both pickup and fill is reasonable, but I'll go with fill here + return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); + if (!aCanDrain) + // cannot take AND cannot fill, why make this call then? + return null; + // the slot does not allow filling, so try take some + return drainFluid(aFluidAccess.get(), aPlayer, aProcessFullStack); + } else { + // cannot fill and there is something to take + if (!aCanDrain) + // but the slot does not allow taking, so bail out + return null; + ItemStack tResultStack = drainFluid(tInputFluid, aPlayer, aProcessFullStack); + if (tInputFluid.amount == 0) + aFluidAccess.set(null); + return tResultStack; + } + } + + protected static ItemStack drainFluid(FluidStack aTankStack, EntityPlayer aPlayer, boolean aProcessFullStack) { + if (aTankStack == null) return null; + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; + int tOriginalFluidAmount = aTankStack.amount; + ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); + if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); + int tFilledAmount = tContainerItem.fill(tStackSizedOne, aTankStack, true); + if (tFilledAmount > 0) { + tFilled = tStackSizedOne; + aTankStack.amount -= tFilledAmount; + } + } + if (tFilled != null) { + if (aProcessFullStack) { + int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; + /* + work out how many more items we can fill + one cell is already used, so account for that + the round down behavior will left over a fraction of a cell worth of fluid + the user then get to decide what to do with it + it will not be too fancy if it spills out partially filled cells + */ + int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, aTankStack.amount / tFilledAmount); + aTankStack.amount -= tFilledAmount * tAdditionalParallel; + tFilled.stackSize += tAdditionalParallel; + } + replaceCursorItemStack(aPlayer, tFilled); + } + return tFilled; + } + + protected static ItemStack fillFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { + // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves + if (aFluidAccess.get() != null && !aFluidAccess.get().isFluidEqual(aFluidHeld)) + return null; + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); + if (tStackSizedOne == null) + return null; + + int tFreeSpace = aFluidAccess.getCapacity() - (aFluidAccess.get() != null ? aFluidAccess.get().amount : 0); + if (tFreeSpace <= 0) + // no space left + return null; + + // find out how much fluid can be taken + // some cells cannot be partially filled + ItemStack tStackEmptied = null; + int tAmountTaken = 0; + if (tFreeSpace >= aFluidHeld.amount) { + // fully accepted - try take it from item now + // IFluidContainerItem is intentionally not checked here. it will be checked later + tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); + tAmountTaken = aFluidHeld.amount; + } + if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + // either partially accepted, or is IFluidContainerItem + IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); + FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); + if (tDrained != null && tDrained.amount > 0) { + // something is actually drained - change the cell and drop it to player + tStackEmptied = tStackSizedOne; + tAmountTaken = tDrained.amount; + } + } + if (tStackEmptied == null) + // somehow the cell refuse to give out that amount of fluid, no op then + return null; + + // find out how many fill can we do + // same round down behavior as above + // however here the fluid stack is not changed at all, so the exact code will slightly differ + int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; + if (aFluidAccess.get() == null) { + FluidStack tNewFillableStack = aFluidHeld.copy(); + tNewFillableStack.amount = tAmountTaken * tParallel; + aFluidAccess.set(tNewFillableStack); + } else { + aFluidAccess.get().amount += tAmountTaken * tParallel; + } + tStackEmptied.stackSize = tParallel; + replaceCursorItemStack(aPlayer, tStackEmptied); + return tStackEmptied; + } + + private static void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { + int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); + while (tStackResult.stackSize > tStackResultMaxStackSize) { + aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); + } + if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { + // every cell is mutated. it could just stay on the cursor. + aPlayer.inventory.setItemStack(tStackResult); + } else { + // some cells not mutated. The mutated cells must go into the inventory + // or drop into the world if there isn't enough space. + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + tStackHeld.stackSize -= tStackResult.stackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); + } + } + @Override public void detectAndSendChanges() { super.detectAndSendChanges(); @@ -66,4 +255,41 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { public int getShiftClickSlotCount() { return 1; } + + protected interface IFluidAccess { + void set(FluidStack stack); + FluidStack get(); + int getCapacity(); + static IFluidAccess from(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { + return new BasicTankFluidAccess(aTank, aIsFillableStack); + } + } + + static class BasicTankFluidAccess implements IFluidAccess { + private final GT_MetaTileEntity_BasicTank mTank; + private final boolean mIsFillableStack; + + public BasicTankFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { + this.mTank = aTank; + this.mIsFillableStack = aIsFillableStack; + } + + @Override + public void set(FluidStack stack) { + if (mIsFillableStack) + mTank.setFillableStack(stack); + else + mTank.setDrainableStack(stack); + } + + @Override + public FluidStack get() { + return mIsFillableStack ? mTank.getFillableStack() : mTank.getDrainableStack(); + } + + @Override + public int getCapacity() { + return mTank.getCapacity(); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 834344d2d2..29fe6ec387 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -594,7 +594,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) mInventory[tDisplayStackSlot] = null; } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), true, !displaysStackSize()); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 6a65eaf5d8..7b99d78009 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -198,7 +198,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null; } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), true, !displaysStackSize()); } } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8cbb44fe07..a404d8c561 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -108,7 +108,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -999,6 +998,10 @@ public class GT_Utility { } public static ItemStack getFluidDisplayStack(FluidStack aFluid, boolean aUseStackSize) { + return getFluidDisplayStack(aFluid, aUseStackSize, false); + } + + public static ItemStack getFluidDisplayStack(FluidStack aFluid, boolean aUseStackSize, boolean aHideStackSize) { if (aFluid == null || aFluid.getFluid() == null) return null; int tmp = 0; try { @@ -1011,6 +1014,7 @@ public class GT_Utility { tNBT.setLong("mFluidDisplayAmount", aUseStackSize ? aFluid.amount : 0); tNBT.setLong("mFluidDisplayHeat", aFluid.getFluid().getTemperature(aFluid)); tNBT.setBoolean("mFluidState", aFluid.getFluid().isGaseous(aFluid)); + tNBT.setBoolean("mHideStackSize", aHideStackSize); rStack.setTagCompound(tNBT); return rStack; } diff --git a/src/main/java/gregtech/common/render/GT_FluidDisplayStackRenderer.java b/src/main/java/gregtech/common/render/GT_FluidDisplayStackRenderer.java index ef5d8287ba..c4e23eab6e 100644 --- a/src/main/java/gregtech/common/render/GT_FluidDisplayStackRenderer.java +++ b/src/main/java/gregtech/common/render/GT_FluidDisplayStackRenderer.java @@ -67,7 +67,7 @@ public class GT_FluidDisplayStackRenderer implements IItemRenderer { // Render Fluid amount text long fluidAmount = item.getTagCompound().getLong("mFluidDisplayAmount"); - if (fluidAmount > 0L) { + if (fluidAmount > 0L && !item.getTagCompound().getBoolean("mHideStackSize")) { String amountString; if (fluidAmount < 10000) { -- cgit From 8000dcecab1d731893b0be4637fc3316ca2d1550 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Sat, 10 Jul 2021 13:25:03 +0800 Subject: fix recipe check --- src/main/java/gregtech/api/util/GT_Recipe.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index aa54b55277..315d70a522 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -388,13 +388,18 @@ public class GT_Recipe implements Comparable { if (mInputs.length > 0 && aInputs == null) return false; + HashSet isUsed = new HashSet<>(); + for (ItemStack tStack : mInputs) { ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); if (unified_tStack != null) { amt = tStack.stackSize; boolean temp = true; + int it = 0; for (ItemStack aStack : aInputs) { - if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack)) { + it ++; + if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isUsed.contains(it)) { + isUsed.add(it); if (GTppRecipeHelper) {//remove once the fix is out if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) { if (!GT_Utility.areStacksEqual(aStack, tStack, false)) -- cgit From df839fb5acebbfe28b20720813b9412f37e0b8bc Mon Sep 17 00:00:00 2001 From: Elisis Date: Tue, 13 Jul 2021 14:23:36 +1000 Subject: Update GT_MachineRecipeLoader.java Fix https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/8199 --- .../gregtech/loaders/postload/GT_MachineRecipeLoader.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 2e49a3888c..641aa6146e 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -1707,24 +1707,24 @@ public class GT_MachineRecipeLoader implements Runnable { } /* Recycling Recipes for EBF Coils Adding hatches/buses at a later date*/ GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Cupronickel.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Cupronickel,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Tin,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,2)},null,300,360); - GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Kanthal.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Kanthal,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Copper,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,3)},null,300,360); - GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Nichrome.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Nichrome,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Aluminium,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,4)},null,300,360); + GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Kanthal.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Kanthal,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Cupronickel,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,3)},null,300,360); + GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Nichrome.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Nichrome,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Kanthal,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,4)},null,300,360); GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_TungstenSteel.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.TungstenSteel,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Nichrome,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,5)},null,300,360); GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_HSSG.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.HSSG,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.TungstenSteel,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,6)},null,300,360); GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_Naquadah.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Naquadah,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.HSSG,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,7)},null,300,360); GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_NaquadahAlloy.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.NaquadahAlloy,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Naquadah,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,8)},null,300,360); GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_ElectrumFlux.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.ElectrumFlux,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.NaquadahAlloy,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,9)},null,300,360); - GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_AwakenedDraconium.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.DraconiumAwakened,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.Neutronium,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,10)},null,360,128); + GT_Values.RA.addArcFurnaceRecipe(ItemList.Casing_Coil_AwakenedDraconium.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.DraconiumAwakened,8),GT_OreDictUnificator.get(OrePrefixes.ingot,Materials.ElectrumFlux,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Ash,10)},null,360,128); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Cupronickel.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Cupronickel,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Tin,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,2)},null,1500,80); - GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Kanthal.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Kanthal,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Copper,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,3)},null,1500,80); - GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Nichrome.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Nichrome,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Aluminium,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,4)},null,1500,80); + GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Kanthal.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Kanthal,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Cupronickel,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,3)},null,1500,80); + GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Nichrome.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Nichrome,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Kanthal,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,4)},null,1500,80); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_TungstenSteel.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.TungstenSteel,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Nichrome,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,5)},null,1500,80); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_HSSG.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.HSSG,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.TungstenSteel,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,6)},null,1500,80); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_Naquadah.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Naquadah,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.HSSG,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,7)},null,1500,80); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_NaquadahAlloy.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.NaquadahAlloy,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Naquadah,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,8)},null,1500,80); GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_ElectrumFlux.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.ElectrumFlux,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.NaquadahAlloy,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,9)},null,1500,80); - GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_AwakenedDraconium.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.DraconiumAwakened,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Neutronium,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,10)},null,1500,80); + GT_Values.RA.addPulveriserRecipe(ItemList.Casing_Coil_AwakenedDraconium.get(1L),new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.dust,Materials.DraconiumAwakened,8),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.ElectrumFlux,1),GT_OreDictUnificator.get(OrePrefixes.dust,Materials.QuartzSand,10)},null,1500,80); -- cgit From 6ecf806dab6ffdb99d69c6add11492e6a7d866a4 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 14 Jul 2021 11:19:21 +0800 Subject: Add option to not change GUI color based on paint --- src/main/java/gregtech/GT_Mod.java | 1 + src/main/java/gregtech/api/GregTech_API.java | 1 + .../java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 525da2dd08..c601130ab9 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -308,6 +308,7 @@ public class GT_Mod implements IGT_Mod { GregTech_API.sMachineThunderExplosions = tMainConfig.get("machines", "lightning_causes_explosions", true).getBoolean(false); GregTech_API.sConstantEnergy = tMainConfig.get("machines", "constant_need_of_energy", true).getBoolean(false); GregTech_API.sColoredGUI = tMainConfig.get("machines", "colored_guis_when_painted", true).getBoolean(false); + GregTech_API.sMachineMetalGUI = tMainConfig.get("machines", "guis_in_consistent_machine_metal_color", false).getBoolean(false); // Implementation for this is actually handled in NewHorizonsCoreMod in MainRegistry.java! GregTech_API.sUseMachineMetal = tMainConfig.get("machines", "use_machine_metal_tint", true).getBoolean(true); diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index ba7e3ab43e..ac9b1bfb5a 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -277,6 +277,7 @@ public class GregTech_API { sMultiThreadedSounds = false, sDoShowAllItemsInCreative = false, sColoredGUI = true, + sMachineMetalGUI = false, sConstantEnergy = true, sMachineExplosions = true, sMachineFlammable = true, 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 a54aa2e526..7fd4f9f0b2 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -27,7 +27,9 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer { @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - if (GregTech_API.sColoredGUI && mContainer != null && mContainer.mTileEntity != null) { + if (GregTech_API.sMachineMetalGUI) { + GL11.glColor3ub((byte) Dyes.MACHINE_METAL.mRGBa[0], (byte) Dyes.MACHINE_METAL.mRGBa[1], (byte) Dyes.MACHINE_METAL.mRGBa[2]); + } else if (GregTech_API.sColoredGUI && mContainer != null && mContainer.mTileEntity != null) { byte colorByte = mContainer.mTileEntity.getColorization(); Dyes color; if (colorByte != -1) @@ -35,7 +37,8 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer { else color = Dyes.MACHINE_METAL; GL11.glColor3ub((byte) color.mRGBa[0], (byte) color.mRGBa[1], (byte) color.mRGBa[2]); - } else + } else { GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255); + } } } -- cgit From 9f7fd2675139d4a575b6a1dc2fa1b472800a0757 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 15 Jul 2021 02:23:32 +0300 Subject: Optimized Replacing Vanilla Materials code, removed uselessly-repeated operations --- .../gregtech/api/util/GT_RecipeRegistrator.java | 150 +++++++++++---------- src/main/java/gregtech/api/util/GT_Utility.java | 7 + 2 files changed, 84 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 0868ff41c8..34cf7ca80e 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -1,5 +1,6 @@ package gregtech.api.util; +import com.google.common.base.Stopwatch; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; @@ -28,52 +29,52 @@ public class GT_RecipeRegistrator { public static final List sRodMaterialList = new ArrayList(); private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; - private static final ItemStack[][] - sShapes1 = new ItemStack[][]{ - {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, - {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, - {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, - {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, sMt1, null, null, sMt1, null, null, sMt2, null}, - {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, null, sMt2, null, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, - {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, - {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, - {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, - {null, sMt2, null, null, sMt1, null, null, sMt1, null}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, null, sMt1, null}, - {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, - {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, - {sMt1, null, null, null, sMt2, null, null, null, sMt2}, - {null, null, sMt1, null, sMt2, null, sMt2, null, null}, - {sMt1, null, null, null, sMt2, null, null, null, null}, - {null, null, sMt1, null, sMt2, null, null, null, null}, - {sMt1, sMt2, null, null, null, null, null, null, null}, - {sMt2, sMt1, null, null, null, null, null, null, null}, - {sMt1, null, null, sMt2, null, null, null, null, null}, - {sMt2, null, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, - {sMt1, null, null, null, sMt1, null, null, null, null}, - {null, sMt1, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, - {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} + private static final RecipeShape[] + sShapes = new RecipeShape[]{ + new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null), + new RecipeShape(sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null), + new RecipeShape(sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1), + new RecipeShape(null, null, null, sMt1, null, sMt1, sMt1, null, sMt1), + new RecipeShape(null, sMt1, null, null, sMt1, null, null, sMt2, null), + new RecipeShape(sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, null, null, sMt2, null, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, sMt1, null, sMt2, null, null, sMt2, null), + new RecipeShape(null, sMt1, null, sMt1, null, null, null, sMt1, sMt2), + new RecipeShape(null, sMt1, null, null, null, sMt1, sMt2, sMt1, null), + new RecipeShape(null, sMt1, null, sMt1, null, sMt1, null, null, sMt2), + new RecipeShape(null, sMt1, null, sMt1, null, sMt1, sMt2, null, null), + new RecipeShape(null, sMt2, null, null, sMt1, null, null, sMt1, null), + new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1), + new RecipeShape(null, sMt2, null, null, sMt2, null, null, sMt1, null), + new RecipeShape(null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null), + new RecipeShape(null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, null, sMt2, null, sMt1, sMt1, null), + new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, sMt2), + new RecipeShape(null, null, sMt1, null, sMt2, null, sMt2, null, null), + new RecipeShape(sMt1, null, null, null, sMt2, null, null, null, null), + new RecipeShape(null, null, sMt1, null, sMt2, null, null, null, null), + new RecipeShape(sMt1, sMt2, null, null, null, null, null, null, null), + new RecipeShape(sMt2, sMt1, null, null, null, null, null, null, null), + new RecipeShape(sMt1, null, null, sMt2, null, null, null, null, null), + new RecipeShape(sMt2, null, null, sMt1, null, null, null, null, null), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null), + new RecipeShape(null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null), + new RecipeShape(sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null), + new RecipeShape(null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1), + new RecipeShape(null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1), + new RecipeShape(sMt1, null, null, null, sMt1, null, null, null, null), + new RecipeShape(null, sMt1, null, sMt1, null, null, null, null, null), + new RecipeShape(sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null), + new RecipeShape(null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2) }; private static final String[][] sShapesA = new String[][]{ null, @@ -307,10 +308,7 @@ public class GT_RecipeRegistrator { */ public static synchronized void registerUsagesForMaterials(String aPlate, boolean aRecipeReplacing, ItemStack... aMats) { for (ItemStack aMat : aMats) { - if (aMat == null) - continue; - - aMat = GT_Utility.copy(aMat); + aMat = GT_Utility.copyOrNull(aMat); if (aMat == null) continue; @@ -327,20 +325,17 @@ public class GT_RecipeRegistrator { sMt2.stackSize = 1; Items.feather.setDamage(sMt2, 0); - for (ItemStack[] tRecipe : sShapes1) { - int tAmount1 = 0; - for (ItemStack tMat : tRecipe) { - if (tMat == sMt1) tAmount1++; - } - if (aItemData != null && aItemData.hasValidPrefixMaterialData()) - for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputsBuffered(tRecipe)) { - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1)); -// GT_Log.out.println("###################################################################################"); -// GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aPlate); -// GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getUnlocalizedName()); -// GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getDisplayName()); -// GT_Log.out.println("###################################################################################"); + if(aItemData != null && aItemData.hasValidPrefixMaterialData()) { + for (RecipeShape tRecipe : sShapes) { + for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputsBuffered(tRecipe.shape)) { + GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tRecipe.amount1)); + // GT_Log.out.println("###################################################################################"); + // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aPlate); + // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getUnlocalizedName()); + // GT_Log.out.println("registerUsagesForMaterials used aPlate: "+aMat.getDisplayName()); + // GT_Log.out.println("###################################################################################"); } + } } registerStickStuff(aPlate, aItemData, aRecipeReplacing); } @@ -355,22 +350,17 @@ public class GT_RecipeRegistrator { sMt2.stackSize = 1; Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2)); - for (int i = 0; i < sShapes1.length; i++) { - ItemStack[] tRecipe = sShapes1[i]; + for (int i = 0; i < sShapes.length; i++) { + RecipeShape tRecipe = sShapes[i]; - int tAmount1 = 0, tAmount2 = 0; - for (ItemStack tMat : tRecipe) { - if (tMat == sMt1) tAmount1++; - if (tMat == sMt2) tAmount2++; - } - for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) { + for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe.shape)) { if (aItemData != null && aItemData.hasValidPrefixMaterialData()) - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); + GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tRecipe.amount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tRecipe.amount2))); if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) { assert aItemData != null; if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) { - if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { + if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe.shape))) { // GT_Log.out.println("###################################################################################"); // GT_Log.out.println("registerStickStuff used aPlate: "+aPlate); // GT_Log.out.println("###################################################################################"); @@ -398,4 +388,18 @@ public class GT_RecipeRegistrator { return Arrays.stream(VANILLA_MATS).anyMatch(mat -> mat == materials); } + private static class RecipeShape { + private final ItemStack[] shape; + private int amount1; + private int amount2; + + public RecipeShape(ItemStack... shape) { + this.shape = shape; + + for (ItemStack stack : shape) { + if(stack == sMt1) this.amount1++; + if(stack == sMt2) this.amount2++; + } + } + } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8cbb44fe07..8e283956cb 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -90,6 +90,7 @@ import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import javax.annotation.Nullable; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -1651,6 +1652,12 @@ public class GT_Utility { return null; } + @Nullable + public static ItemStack copyOrNull(@Nullable ItemStack stack) { + if (isStackValid(stack)) return stack.copy(); + return null; + } + public static ItemStack copyAmount(long aAmount, Object... aStacks) { ItemStack rStack = copy(aStacks); if (isStackInvalid(rStack)) return null; -- cgit From 77f22e029303ba48f9aabad32367e500bdcefee3 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 15 Jul 2021 02:53:54 +0300 Subject: Removed useless array creation in most #copy methods by changing them to #copyOrNull variant with single parameter. --- src/main/java/gregtech/api/gui/GT_Container.java | 8 +-- .../api/metatileentity/MetaPipeEntity.java | 2 +- .../api/metatileentity/MetaTileEntity.java | 2 +- .../GT_MetaTileEntity_BasicGenerator.java | 2 +- .../GT_MetaTileEntity_BasicMachine.java | 2 +- .../GT_MetaTileEntity_MultiBlockBase.java | 2 +- src/main/java/gregtech/api/util/GT_BaseCrop.java | 10 ++-- src/main/java/gregtech/api/util/GT_FoodStat.java | 4 +- src/main/java/gregtech/api/util/GT_ModHandler.java | 57 +++++++++++----------- .../gregtech/api/util/GT_OreDictUnificator.java | 8 +-- src/main/java/gregtech/api/util/GT_Recipe.java | 18 +++---- src/main/java/gregtech/api/util/GT_Utility.java | 14 +++--- .../java/gregtech/common/GT_ThaumcraftCompat.java | 4 +- .../gregtech/common/entities/GT_Entity_Arrow.java | 2 +- .../common/gui/GT_Container_Regulator.java | 2 +- .../common/items/behaviors/Behaviour_DataOrb.java | 2 +- .../items/behaviors/Behaviour_Sonictron.java | 2 +- .../machines/basic/GT_MetaTileEntity_Scanner.java | 4 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../GT_MetaTileEntity_PrimitiveBlastFurnace.java | 2 +- .../loaders/oreprocessing/ProcessingLog.java | 8 +-- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 6 +-- .../java/gregtech/nei/GT_NEI_DefaultHandler.java | 6 +-- 23 files changed, 86 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index 608c6015d5..e00759bf24 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -142,7 +142,7 @@ public class GT_Container extends Container { if (aSlot != null && aSlot.canTakeStack(aPlayer)) { tTempStack = this.transferStackInSlot(aPlayer, aSlotIndex); if (tTempStack != null) { - rStack = GT_Utility.copy(tTempStack); + rStack = GT_Utility.copyOrNull(tTempStack); if (aSlot.getStack() != null && aSlot.getStack().getItem() == tTempStack.getItem()) { slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @@ -157,7 +157,7 @@ public class GT_Container extends Container { tTempStack = aSlot.getStack(); ItemStack var13 = aPlayerInventory.getItemStack(); if (tTempStack != null) { - rStack = GT_Utility.copy(tTempStack); + rStack = GT_Utility.copyOrNull(tTempStack); } if (tTempStack == null) { if (var13 != null && aSlot.isItemValid(var13)) { @@ -253,7 +253,7 @@ public class GT_Container extends Container { } else if (aShifthold == 3 && aPlayer.capabilities.isCreativeMode && aPlayerInventory.getItemStack() == null && aSlotIndex >= 0) { aSlot = (Slot) this.inventorySlots.get(aSlotIndex); if (aSlot != null && aSlot.getHasStack()) { - tTempStack = GT_Utility.copy(aSlot.getStack()); + tTempStack = GT_Utility.copyOrNull(aSlot.getStack()); tTempStack.stackSize = tTempStack.getMaxStackSize(); aPlayerInventory.setItemStack(tTempStack); } @@ -271,7 +271,7 @@ public class GT_Container extends Container { //null checks and checks if the item can be stacked (maxStackSize > 1) if (getSlotCount() > 0 && slotObject != null && slotObject.getHasStack() && !(slotObject instanceof GT_Slot_Holo)) { ItemStack stackInSlot = slotObject.getStack(); - stack = GT_Utility.copy(stackInSlot); + stack = GT_Utility.copyOrNull(stackInSlot); //TileEntity -> Player if (aSlotIndex < getAllSlotCount()) { diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 601b6fb4f9..1070c97364 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -503,7 +503,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); + ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copyOrNull(tStack); if (tStack != null) { if (tStack.stackSize <= aAmount) { if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 87eee3e6ac..d9f90b06b7 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -696,7 +696,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { @Override public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); + ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copyOrNull(tStack); if (tStack != null) { if (tStack.stackSize <= aAmount) { if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; 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 ccc0fc0af4..9bbfbf0a3a 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 @@ -303,7 +303,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity 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); - if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + if (tFuel != null) return GT_Utility.copyOrNull(tFuel.getOutput(0)); return GT_Utility.getContainerItem(aStack, true); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 834344d2d2..5698eabc76 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -549,7 +549,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; for (int i = 0; i < mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + mOutputItems[i] = GT_Utility.copyOrNull(mOutputItems[i]); if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) mOutputItems[i].stackSize = 64; mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 193b9d482c..0de4dfecbb 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -741,7 +741,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean addOutput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; - aStack = GT_Utility.copy(aStack); + aStack = GT_Utility.copyOrNull(aStack); for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { if (isValidMetaTileEntity(tHatch) && tHatch.storeAll(aStack)) { return true; diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index c06bf82b89..97f8db0547 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -68,7 +68,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { aID = GT_Config.addIDConfig(ConfigCategories.IDs.crops, mName.replaceAll(" ", "_"), aID); if (aDiscoveredBy != null && !aDiscoveredBy.equals(E)) mDiscoveredBy = aDiscoveredBy; if (aDrop != null && aID > 0 && aID < 256) { - mDrop = GT_Utility.copy(aDrop); + mDrop = GT_Utility.copyOrNull(aDrop); mSpecialDrops = aSpecialDrops; mTier = Math.max(1, aTier); mMaxSize = Math.max(3, aMaxSize); @@ -177,9 +177,9 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { public ItemStack getGain(ICropTile aCrop) { int tDrop = 0; if (mSpecialDrops != null && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { - return GT_Utility.copy(mSpecialDrops[tDrop]); + return GT_Utility.copyOrNull(mSpecialDrops[tDrop]); } - return GT_Utility.copy(mDrop); + return GT_Utility.copyOrNull(mDrop); } @Override @@ -247,9 +247,9 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public ItemStack getDisplayItem() { if (mSpecialDrops != null && mSpecialDrops[mSpecialDrops.length - 1] != null) { - return GT_Utility.copy(mSpecialDrops[mSpecialDrops.length - 1]); + return GT_Utility.copyOrNull(mSpecialDrops[mSpecialDrops.length - 1]); } - return GT_Utility.copy(mDrop); + return GT_Utility.copyOrNull(mDrop); } } diff --git a/src/main/java/gregtech/api/util/GT_FoodStat.java b/src/main/java/gregtech/api/util/GT_FoodStat.java index ce89881a5b..193977476a 100644 --- a/src/main/java/gregtech/api/util/GT_FoodStat.java +++ b/src/main/java/gregtech/api/util/GT_FoodStat.java @@ -36,7 +36,7 @@ public class GT_FoodStat implements IFoodStat { mSaturation = aSaturation; mAction = aAction == null ? EnumAction.eat : aAction; mPotionEffects = aPotionEffects; - mEmptyContainer = GT_Utility.copy(aEmptyContainer); + mEmptyContainer = GT_Utility.copyOrNull(aEmptyContainer); mInvisibleParticles = aInvisibleParticles; mAlwaysEdible = aAlwaysEdible; mIsRotten = aIsRotten; @@ -65,7 +65,7 @@ public class GT_FoodStat implements IFoodStat { @Override public void onEaten(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer) { aStack.stackSize--; - ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer)); + ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copyOrNull(mEmptyContainer)); if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack)) aPlayer.dropPlayerItemWithRandomChoice(tStack, true); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index f82b0ecb7e..7e66e6cc2a 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -460,8 +460,8 @@ public class GT_ModHandler { aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance); if (aChance <= 0) return false; try { - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copy(aOutput), aChance); - GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copy(aOutput), aChance); + GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copyOrNull(aOutput), aChance); + GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copyOrNull(aOutput), aChance); } catch (Throwable e) {/*Do nothing*/} return true; } @@ -484,7 +484,7 @@ public class GT_ModHandler { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null || GT_Utility.getContainerItem(aInput, false) != null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.smelting, aInput, true)) return false; - FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F); + FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copyOrNull(aOutput), 0.0F); return true; } @@ -562,8 +562,8 @@ public class GT_ModHandler { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null || aTime <= 0) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rcblastfurnace, aInput, true)) return false; - aInput = GT_Utility.copy(aInput); - aOutput = GT_Utility.copy(aOutput); + aInput = GT_Utility.copyOrNull(aInput); + aOutput = GT_Utility.copyOrNull(aOutput); try { mods.railcraft.api.crafting.RailcraftCraftingManager.blastFurnace.addRecipe(aInput, true, false, aTime, aOutput); } catch (Throwable e) { @@ -614,28 +614,28 @@ public class GT_ModHandler { if (Materials.Wood.contains(aOutput1)) { if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) - ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); + ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1)); else - ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2); + ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1), GT_Utility.copyOrNull(aOutput2), aChance2 <= 0 ? 10 : aChance2); } } else { if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rockcrushing, aInput, true)) { try { if (GT_Utility.getBlockFromStack(aInput) != Blocks.obsidian && GT_Utility.getBlockFromStack(aInput) != Blocks.gravel) { mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != W, false); - tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput1), 1.0F / aInput.stackSize); if (aOutput2 != null) - tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize); if (aOutput3 != null) - tRecipe.addOutput(GT_Utility.copy(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize); + tRecipe.addOutput(GT_Utility.copyOrNull(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize); } } catch (Throwable e) {/*Do nothing*/} } if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) - ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); + ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1)); else - ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2); + ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copyOrNull(aInput), GT_Utility.copyOrNull(aOutput1), GT_Utility.copyOrNull(aOutput2), aChance2 <= 0 ? 10 : aChance2); } } } @@ -702,7 +702,7 @@ public class GT_ModHandler { if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true)) return false; try { - ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copy(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance); + ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copyOrNull(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance); } catch (Throwable e) {/*Do nothing*/} return true; } @@ -713,7 +713,7 @@ public class GT_ModHandler { public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null) return false; - FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F); + FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copyOrNull(aOutput), 0.0F); return true; } @@ -847,9 +847,9 @@ public class GT_ModHandler { aResult = GT_OreDictUnificator.get(true, aResult); if (aResult == null || aRecipe == null || aResult.stackSize <= 0) return false; try { - mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copy(aResult), aRecipe)); + mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copyOrNull(aResult), aRecipe)); } catch (Throwable e) { - return addCraftingRecipe(GT_Utility.copy(aResult), aRecipe); + return addCraftingRecipe(GT_Utility.copyOrNull(aResult), aRecipe); } return true; } @@ -1084,8 +1084,9 @@ public class GT_ModHandler { Character chr = (Character) aRecipe[idx]; Object in = aRecipe[idx + 1]; if (in instanceof ItemStack) { - tItemStackMap.put(chr, GT_Utility.copy(in)); - tItemDataMap.put(chr, GT_OreDictUnificator.getItemData((ItemStack) in)); + ItemStack is = (ItemStack) in; + tItemStackMap.put(chr, GT_Utility.copyOrNull(is)); + tItemDataMap.put(chr, GT_OreDictUnificator.getItemData(is)); } else if (in instanceof ItemData) { String tString = in.toString(); switch (tString) { @@ -1184,9 +1185,9 @@ public class GT_ModHandler { if (tThereWasARecipe || !aOnlyAddIfThereIsAnyRecipeOutputtingThis) { if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + sBufferRecipeList.add(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); else - GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); + GameRegistry.addRecipe(new GT_Shaped_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored)); } return true; } @@ -1260,9 +1261,9 @@ public class GT_ModHandler { GT_Utility.updateItemStack(aResult); if (sBufferCraftingRecipes && aBuffered) - sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + sBufferRecipeList.add(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); else - GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); + GameRegistry.addRecipe(new GT_Shapeless_Recipe(GT_Utility.copyOrNull(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe)); return true; } @@ -1531,7 +1532,7 @@ public class GT_ModHandler { throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); } else { if (aUncopiedStack) return tOutput; - return GT_Utility.copy(tOutput); + return GT_Utility.copyOrNull(tOutput); } } } @@ -1679,7 +1680,7 @@ public class GT_ModHandler { if (tRecipe instanceof ShapelessRecipes) continue; if (tRecipe instanceof ShapelessOreRecipe) continue; if (tRecipe instanceof IGT_CraftingRecipe) continue; - rList.add(GT_Utility.copy(tOutput)); + rList.add(GT_Utility.copyOrNull(tOutput)); aList.remove(i--); } } @@ -1691,7 +1692,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getMaceratorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1699,7 +1700,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getExtractorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1707,7 +1708,7 @@ public class GT_ModHandler { */ @Deprecated public static ItemStack getCompressorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - return GT_Utility.copy(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); + return GT_Utility.copyOrNull(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } /** @@ -1748,7 +1749,7 @@ public class GT_ModHandler { for (byte i = 0; i < aOutputSlots.length && i < tList.length; i++) { if (tList[i] != null) { if (aOutputSlots[i] == null || (GT_Utility.areStacksEqual(tList[i], aOutputSlots[i]) && tList[i].stackSize + aOutputSlots[i].stackSize <= aOutputSlots[i].getMaxStackSize())) { - rList[i] = GT_Utility.copy(tList[i]); + rList[i] = GT_Utility.copyOrNull(tList[i]); } else { return new ItemStack[aOutputSlots.length]; } diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 98809bbf45..54ef5b2866 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -123,7 +123,7 @@ public class GT_OreDictUnificator { } public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) { - for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); + for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copyOrNull(aStacks[i])); return aStacks; } @@ -155,15 +155,15 @@ public class GT_OreDictUnificator { ItemData tPrefixMaterial = getAssociation(aStack); ItemStack rStack = null; if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return GT_Utility.copy(aStack); + return GT_Utility.copyOrNull(aStack); if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { tPrefixMaterial.mBlackListed = true; - return GT_Utility.copy(aStack); + return GT_Utility.copyOrNull(aStack); } if (tPrefixMaterial.mUnificationTarget == null) tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); rStack = tPrefixMaterial.mUnificationTarget; - if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack); + if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copyOrNull(aStack); assert rStack != null; rStack.setTagCompound(aStack.getTagCompound()); return GT_Utility.copyAmount(aStack.stackSize, rStack); diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index aa54b55277..0214eab54b 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -312,12 +312,12 @@ public class GT_Recipe implements Comparable { public ItemStack getRepresentativeInput(int aIndex) { if (aIndex < 0 || aIndex >= mInputs.length) return null; - return GT_Utility.copy(mInputs[aIndex]); + return GT_Utility.copyOrNull(mInputs[aIndex]); } public ItemStack getOutput(int aIndex) { if (aIndex < 0 || aIndex >= mOutputs.length) return null; - return GT_Utility.copy(mOutputs[aIndex]); + return GT_Utility.copyOrNull(mOutputs[aIndex]); } public int getOutputChance(int aIndex) { @@ -1215,7 +1215,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.compressor.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1238,7 +1238,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.extractor.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1261,7 +1261,7 @@ public class GT_Recipe implements Comparable { public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.centrifuge.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 48, 0) : null; } @@ -1285,7 +1285,7 @@ public class GT_Recipe implements Comparable { if (aInputs == null || aInputs.length <= 0 || aInputs[0] == null || aFluids == null || aFluids.length < 1 || !GT_ModHandler.isWater(aFluids[0])) return null; if (aRecipe != null && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) return aRecipe; - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); NBTTagCompound aRecipeMetaData = new NBTTagCompound(); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.oreWashing.getRecipes(), true, aRecipeMetaData, null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, new FluidStack[]{new FluidStack(aFluids[0].getFluid(), ((NBTTagCompound) aRecipeMetaData.getTag("return")).getInteger("amount"))}, null, 400, 16, 0) : null; @@ -1334,7 +1334,7 @@ public class GT_Recipe implements Comparable { if (D1) GT_Log.err.println("Railcraft Not loaded"); } catch (NullPointerException e) {/**/} - ItemStack tComparedInput = GT_Utility.copy(aInputs[0]); + ItemStack tComparedInput = GT_Utility.copyOrNull(aInputs[0]); ItemStack[] tOutputItems = GT_ModHandler.getMachineOutput(tComparedInput, ic2.api.recipe.Recipes.macerator.getRecipes(), true, new NBTTagCompound(), null, null, null); return GT_Utility.arrayContainsNonNull(tOutputItems) ? new GT_Recipe(false, new ItemStack[]{GT_Utility.copyAmount(aInputs[0].stackSize - tComparedInput.stackSize, aInputs[0])}, tOutputItems, null, null, null, null, 400, 2, 0) : null; } @@ -1823,13 +1823,13 @@ public class GT_Recipe implements Comparable { if (mOreDictAlt[aIndex] != null && mOreDictAlt[aIndex].length > 0) { ItemStack[] rStacks = new ItemStack[mOreDictAlt[aIndex].length]; for (int i = 0; i < mOreDictAlt[aIndex].length; i++) { - rStacks[i] = GT_Utility.copy(mOreDictAlt[aIndex][i]); + rStacks[i] = GT_Utility.copyOrNull(mOreDictAlt[aIndex][i]); } return rStacks; } } if (aIndex >= mInputs.length) return null; - return GT_Utility.copy(mInputs[aIndex]); + return GT_Utility.copyOrNull(mInputs[aIndex]); } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8e283956cb..8e839c8ba0 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -89,6 +89,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.lang.reflect.Constructor; @@ -439,7 +441,7 @@ public class GT_Utility { if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copy(tStack)); + ItemStack rStack = ((IItemDuct) aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyOrNull(tStack)); byte tMovedItemCount = (byte) (tStack.stackSize - (rStack == null ? 0 : rStack.stackSize)); if (tMovedItemCount >= 1/*Math.max(aMinMoveAtOnce, aMinTargetStackSize)*/) { //((cofh.api.transport.IItemConduit)aTileEntity2).insertItem(ForgeDirection.getOrientation(aPutTo), copyAmount(tMovedItemCount, tStack), F); @@ -459,7 +461,7 @@ public class GT_Utility { if (isAllowedToTakeFromSlot(aTileEntity1, aGrabSlot, (byte) aGrabFrom, aTileEntity1.getStackInSlot(aGrabSlot))) { if (Math.max(aMinMoveAtOnce, aMinTargetStackSize) <= aTileEntity1.getStackInSlot(aGrabSlot).stackSize) { ItemStack tStack = copyAmount(Math.min(aTileEntity1.getStackInSlot(aGrabSlot).stackSize, Math.min(aMaxMoveAtOnce, aMaxTargetStackSize)), aTileEntity1.getStackInSlot(aGrabSlot)); - byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copy(tStack), false, ForgeDirection.getOrientation(aPutTo)); + byte tMovedItemCount = (byte) ((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyOrNull(tStack), false, ForgeDirection.getOrientation(aPutTo)); if (tMovedItemCount >= Math.max(aMinMoveAtOnce, aMinTargetStackSize)) { tMovedItemCount = (byte) (((buildcraft.api.transport.IPipeTile) aTileEntity2).injectItem(copyAmount(tMovedItemCount, tStack), true, ForgeDirection.getOrientation(aPutTo))); aTileEntity1.decrStackSize(aGrabSlot, tMovedItemCount); @@ -510,7 +512,7 @@ public class GT_Utility { ItemStack tStack1 = aTileEntity1.getStackInSlot(aGrabFrom), tStack2 = aTileEntity2.getStackInSlot(aPutTo), tStack3 = null; if (tStack1 != null) { if (tStack2 != null && !areStacksEqual(tStack1, tStack2)) return 0; - tStack3 = copy(tStack1); + tStack3 = copyOrNull(tStack1); aMaxTargetStackSize = (byte) Math.min(aMaxTargetStackSize, Math.min(tStack3.getMaxStackSize(), Math.min(tStack2 == null ? Integer.MAX_VALUE : tStack2.getMaxStackSize(), aTileEntity2.getInventoryStackLimit()))); tStack3.stackSize = Math.min(tStack3.stackSize, aMaxTargetStackSize - (tStack2 == null ? 0 : tStack2.stackSize)); if (tStack3.stackSize > aMaxMoveAtOnce) tStack3.stackSize = aMaxMoveAtOnce; @@ -519,7 +521,7 @@ public class GT_Utility { aTileEntity1.markDirty(); if (tStack3 != null) { if (tStack2 == null) { - aTileEntity2.setInventorySlotContents(aPutTo, copy(tStack3)); + aTileEntity2.setInventorySlotContents(aPutTo, copyOrNull(tStack3)); } else { tStack2.stackSize += tStack3.stackSize; } @@ -1147,7 +1149,7 @@ public class GT_Utility { if(tOreName.toString().equals("dustAsh")&&tStack[0].getUnlocalizedName().equals("tile.volcanicAsh"))return false; aRecipeList.put(new RecipeInputOreDict(tOreName.toString(), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } else { - aRecipeList.put(new RecipeInputItemStack(copy(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); + aRecipeList.put(new RecipeInputItemStack(copyOrNull(aInput), aInput.stackSize), new RecipeOutput(aNBT, tStack)); } return true; } @@ -1191,7 +1193,7 @@ public class GT_Utility { rStack.setTagCompound(tNBT); GT_Log.out.println("GT_Mod: Added Book to Book List - Mapping: '" + aMapping + "' - Name: '" + aTitle + "' - Author: '" + aAuthor + "'"); GregTech_API.sBookList.put(aMapping, rStack); - return copy(rStack); + return copyOrNull(rStack); } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength) { diff --git a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java index bc6372e41c..e4472824e7 100644 --- a/src/main/java/gregtech/common/GT_ThaumcraftCompat.java +++ b/src/main/java/gregtech/common/GT_ThaumcraftCompat.java @@ -182,7 +182,7 @@ public class GT_ThaumcraftCompat implements IThaumcraftCompat { if ((GT_Utility.isStringInvalid(aResearch)) || (aInput == null) || (aOutput == null) || (aAspects == null) || (aAspects.isEmpty())) { return null; } - return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), ((aInput instanceof ItemStack)) || ((aInput instanceof ArrayList)) ? aInput : aInput.toString(), getAspectList(aAspects)); + return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copyOrNull(aOutput), ((aInput instanceof ItemStack)) || ((aInput instanceof ArrayList)) ? aInput : aInput.toString(), getAspectList(aAspects)); } @Override @@ -190,7 +190,7 @@ public class GT_ThaumcraftCompat implements IThaumcraftCompat { if ((GT_Utility.isStringInvalid(aResearch)) || (aMainInput == null) || (aSideInputs == null) || (aOutput == null) || (aAspects == null) || (aAspects.isEmpty())) { return null; } - return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), aInstability, getAspectList(aAspects), aMainInput, aSideInputs); + return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, GT_Utility.copyOrNull(aOutput), aInstability, getAspectList(aAspects), aMainInput, aSideInputs); } @Override diff --git a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java index b7c87b4860..7a44ade127 100644 --- a/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java +++ b/src/main/java/gregtech/common/entities/GT_Entity_Arrow.java @@ -345,7 +345,7 @@ public class GT_Entity_Arrow extends EntityArrow { } public ItemStack getArrowItem() { - return GT_Utility.copy(this.mArrow); + return GT_Utility.copyOrNull(this.mArrow); } public void setArrowItem(ItemStack aStack) { diff --git a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java index f432c9b5d5..f50ac2dae3 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Regulator.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Regulator.java @@ -81,7 +81,7 @@ public class GT_Container_Regulator extends GT_ContainerMetaTile_Machine { if ((aSlotIndex < 19)) { ItemStack tStack = aPlayer.inventory.getItemStack(); if (tStack != null) { - tSlot.putStack(GT_Utility.copy(new Object[]{tStack})); + tSlot.putStack(GT_Utility.copyOrNull(tStack)); } else if (tSlot.getStack() != null) { if (aMouseclick == 0) { tSlot.getStack().stackSize -= (aShifthold == 1 ? 8 : 1); diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java index b909593694..a5393cdec5 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java @@ -14,7 +14,7 @@ public class Behaviour_DataOrb extends Behaviour_None { if (aNewContent[i] == null) { aInventory[i] = null; } else { - aInventory[i] = GT_Utility.copy(new Object[]{aNewContent[i]}); + aInventory[i] = GT_Utility.copyOrNull(aNewContent[i]); } } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java index a0dea777f7..bcaa8242f3 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Sonictron.java @@ -90,7 +90,7 @@ public class Behaviour_Sonictron extends Behaviour_None { if (aNewContent[i] == null) { aInventory[i] = null; } else { - aInventory[i] = GT_Utility.copy(aNewContent[i]); + aInventory[i] = GT_Utility.copyOrNull(aNewContent[i]); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index 11430c6862..eba61ad1b1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -86,7 +86,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { if (tIndividual != null) { if (tIndividual.analyze()) { getFillableStack().amount -= 100; - this.mOutputItems[0] = GT_Utility.copy(aStack); + this.mOutputItems[0] = GT_Utility.copyOrNull(aStack); aStack.stackSize = 0; NBTTagCompound tNBT = new NBTTagCompound(); tIndividual.writeToNBT(tNBT); @@ -97,7 +97,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } - this.mOutputItems[0] = GT_Utility.copy(aStack); + this.mOutputItems[0] = GT_Utility.copyOrNull(aStack); aStack.stackSize = 0; this.mMaxProgresstime = 1; this.mEUt = 1; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index d7b7e2aa4d..a57a237060 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -207,7 +207,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu if (!storedItem.isItemEqual(miningPipe)) continue; if (pipes == null) { - setInventorySlotContents(1, GT_Utility.copy(miningPipe)); + setInventorySlotContents(1, GT_Utility.copyOrNull(miningPipe)); pipes = getStackInSlot(1); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java index f1b304a1b1..eab4e9c896 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -282,7 +282,7 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn for (int i = 0; i < limit; i++) { int absi = INPUT_SLOTS + i; if (this.mInventory[absi] == null) { - this.mInventory[absi] = GT_Utility.copy(this.mOutputItems[i]); + this.mInventory[absi] = GT_Utility.copyOrNull(this.mOutputItems[i]); } else if (GT_Utility.areStacksEqual(this.mInventory[absi], this.mOutputItems[i])) { this.mInventory[absi].stackSize = Math.min(this.mInventory[absi].getMaxStackSize(), this.mInventory[absi].stackSize + this.mOutputItems[i].stackSize); diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java index dfccc35684..fc60328e44 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingLog.java @@ -56,9 +56,9 @@ public class ProcessingLog implements gregtech.api.interfaces.IOreRecipeRegistra } else { - ItemStack tPlanks = GT_Utility.copy(tStack); + ItemStack tPlanks = GT_Utility.copyOrNull(tStack); tPlanks.stackSize = (tPlanks.stackSize * 3 / 2); - GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), Materials.Lubricant.getFluid(1L), GT_Utility.copy(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); + GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), Materials.Lubricant.getFluid(1L), GT_Utility.copyOrNull(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); GT_Values.RA.addCutterRecipe(new ItemStack(aStack.getItem(), 1, i), GT_Utility.copyAmount(GT_Mod.gregtechproxy.mNerfedWoodPlank ? tStack.stackSize : tStack.stackSize * 5 / 4, tStack), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 2L), 200, 8); GT_ModHandler.addSawmillRecipe(new ItemStack(aStack.getItem(), 1, i), tPlanks, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L)); GT_ModHandler.removeRecipeDelayed(new ItemStack(aStack.getItem(), 1, i)); @@ -75,9 +75,9 @@ public class ProcessingLog implements gregtech.api.interfaces.IOreRecipeRegistra } ItemStack tStack = GT_ModHandler.getRecipeOutput(GT_Utility.copyAmount(1L, aStack)); if (tStack != null) { - ItemStack tPlanks = GT_Utility.copy(tStack); + ItemStack tPlanks = GT_Utility.copyOrNull(tStack); tPlanks.stackSize = (tPlanks.stackSize * 3 / 2); - GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), Materials.Lubricant.getFluid(1L), GT_Utility.copy(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); + GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), Materials.Lubricant.getFluid(1L), GT_Utility.copyOrNull(tPlanks), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L), 200, 8); GT_Values.RA.addCutterRecipe(GT_Utility.copyAmount(1L, aStack), GT_Utility.copyAmount(GT_Mod.gregtechproxy.mNerfedWoodPlank ? tStack.stackSize : tStack.stackSize * 5 / 4, tStack), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 2L), 200, 8); GT_ModHandler.addSawmillRecipe(GT_Utility.copyAmount(1L, aStack), tPlanks, GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 1L)); GT_ModHandler.removeRecipeDelayed(GT_Utility.copyAmount(1L, aStack)); diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index 6c315edb42..c692a2dce1 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -105,7 +105,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); + tResults.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -147,7 +147,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); + tInputs.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -370,7 +370,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { tDisplayStacks.add(base); } } else { - tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + tDisplayStacks.add(GT_Utility.copyOrNull(tStack)); } } } diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index f37eea25e9..a4fc75a24e 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -102,7 +102,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); + tResults.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -136,7 +136,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); + tInputs.add(GT_Utility.copyOrNull(tData.filledContainer)); } } } @@ -385,7 +385,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { tDisplayStacks.add(base); } } else { - tDisplayStacks.add(GT_Utility.copy(tStack)); + tDisplayStacks.add(GT_Utility.copyOrNull(tStack)); } } } -- cgit From 86c442947a6778e66b761cb2cee7a88782eb363a Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 15 Jul 2021 18:29:26 +0300 Subject: Removed useless method callings --- src/main/java/gregtech/api/GregTech_API.java | 12 +++++++----- src/main/java/gregtech/api/util/GT_Utility.java | 5 ++++- .../tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 8 ++++---- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index ba7e3ab43e..3133536de2 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -426,7 +426,7 @@ public class GregTech_API { * @param aMeta the Metadata of the Blocks as Bitmask! -1 or ~0 for all Metavalues */ public static boolean registerMachineBlock(Block aBlock, int aMeta) { - if (GT_Utility.isBlockInvalid(aBlock)) + if (aBlock == null) return false; if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerPortholeBlacklistedBlock(aBlock); @@ -438,7 +438,7 @@ public class GregTech_API { * Like above but with boolean Parameters instead of a BitMask */ public static boolean registerMachineBlock(Block aBlock, boolean... aMeta) { - if (GT_Utility.isBlockInvalid(aBlock) || aMeta == null || aMeta.length == 0) + if (aBlock == null || aMeta == null || aMeta.length == 0) return false; if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerPortholeBlacklistedBlock(aBlock); @@ -452,9 +452,11 @@ public class GregTech_API { * if this Block is a Machine Update Conducting Block */ public static boolean isMachineBlock(Block aBlock, int aMeta) { - if (GT_Utility.isBlockInvalid(aBlock)) - return false; - return (sMachineIDs.containsKey(aBlock) && (sMachineIDs.get(aBlock) & B[aMeta]) != 0); + if (aBlock != null) { + Integer id = sMachineIDs.get(aBlock); + return id != null && (id & B[aMeta]) != 0; + } + return false; } /** diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8e839c8ba0..165ff71927 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1286,6 +1286,7 @@ public class GT_Utility { return rList; } + @Deprecated // why do you use Objects? public static Block getBlock(Object aBlock) { return (Block) aBlock; } @@ -1299,12 +1300,14 @@ public class GT_Utility { return Block.getBlockFromItem(item); } + @Deprecated // why do you use Objects? And if you want to check your block to be not null, check it directly! public static boolean isBlockValid(Object aBlock) { return (aBlock instanceof Block); } + @Deprecated // why do you use Objects? And if you want to check your block to be null, check it directly! public static boolean isBlockInvalid(Object aBlock) { - return aBlock == null || !(aBlock instanceof Block); + return !(aBlock instanceof Block); } public static boolean isStringValid(Object aString) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index e1dfc32aba..431241eb84 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -366,7 +366,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { } private boolean hasValidFluid() { - return (!GT_Utility.isBlockInvalid(this.mPrimaryPumpedBlock) && !GT_Utility.isBlockInvalid(this.mSecondaryPumpedBlock)); + return mPrimaryPumpedBlock != null && mSecondaryPumpedBlock != null; } private boolean moveOneDown() { @@ -522,7 +522,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { return; Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - if (GT_Utility.isBlockValid(aBlock)) { + if (aBlock != null) { if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { this.mPrimaryPumpedBlock = Blocks.water; this.mSecondaryPumpedBlock = Blocks.flowing_water; @@ -549,7 +549,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - return GT_Utility.isBlockValid(aBlock) && + return aBlock != null && (aBlock == Blocks.water || aBlock == Blocks.flowing_water || aBlock == Blocks.lava || @@ -565,7 +565,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { + if (aBlock != null && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water || this.mPrimaryPumpedBlock == Blocks.lava)); if (isWaterOrLava && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) != 0) { -- cgit From 4d8ab247f924f4948724e85275362a66afa78564 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Sun, 18 Jul 2021 11:52:19 +0300 Subject: ME Output bus storeAll returned inverted value --- build.properties | 2 +- .../machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index b6ab999f42..f593a84e9a 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.35.00 +gt.version=5.09.36.00 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index 12d839d221..9b74b979f4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -65,12 +65,16 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc public boolean storeAll(ItemStack aStack) { if (!GregTech_API.mAE2) return false; - int tTotal = aStack.stackSize; - int tStored = store(aStack); - aStack.stackSize -= tStored; - return tTotal == tStored; + aStack.stackSize = store(aStack); + return aStack.stackSize == 0; } + /** + * Attempt to store items in connected ME network. Returns how many items did not fit (if the network was down e.g.) + * + * @param stack input stack + * @return amount of items left over + */ @Optional.Method(modid = "appliedenergistics2") public int store(final ItemStack stack) { if (stack == null) @@ -80,9 +84,8 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc if (proxy == null) return stack.stackSize; IMEMonitor sg = proxy.getStorage().getItemInventory(); - final IEnergySource src = proxy.getEnergy(); IAEItemStack toStore = AEApi.instance().storage().createItemStack(stack); - IAEItemStack rest = Platform.poweredInsert( src, sg, toStore, getRequest()); + IAEItemStack rest = Platform.poweredInsert( proxy.getEnergy(), sg, toStore, getRequest()); if (rest != null) return (int)rest.getStackSize(); return 0; -- cgit From 83b5d8703d5f34f17a70f30fa04ce13f41c44afe Mon Sep 17 00:00:00 2001 From: repo_alt Date: Tue, 20 Jul 2021 15:15:58 +0300 Subject: Made digital chest prioritized like partitioned cell --- .../tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index d78dd722fa..9c8c5faaf9 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -102,7 +102,10 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti @Optional.Method(modid = "appliedenergistics2") @Override public boolean isPrioritized(appeng.api.storage.data.IAEItemStack iaeItemStack) { - return false; + ItemStack s = getItemStack(); + if (s == null || iaeItemStack == null) + return false; + return iaeItemStack.isSameType(s); } @Optional.Method(modid = "appliedenergistics2") -- cgit From 43dbba9c51369dd229f8a0c349c3109d22dbac15 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Wed, 21 Jul 2021 23:19:40 +0800 Subject: make it thread safe --- src/main/java/gregtech/api/util/GT_Recipe.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 315d70a522..d970175560 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static gregtech.api.enums.GT_Values.*; @@ -388,7 +389,7 @@ public class GT_Recipe implements Comparable { if (mInputs.length > 0 && aInputs == null) return false; - HashSet isUsed = new HashSet<>(); + ConcurrentHashMap isUsed = new ConcurrentHashMap<>(); for (ItemStack tStack : mInputs) { ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); @@ -398,8 +399,8 @@ public class GT_Recipe implements Comparable { int it = 0; for (ItemStack aStack : aInputs) { it ++; - if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isUsed.contains(it)) { - isUsed.add(it); + if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isUsed.containsKey(it)) { + isUsed.put(it, true); if (GTppRecipeHelper) {//remove once the fix is out if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) { if (!GT_Utility.areStacksEqual(aStack, tStack, false)) -- cgit From 41044b43def2259f87c1a5e0a3bc67dcfaea52cd Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Thu, 22 Jul 2021 00:03:26 +0800 Subject: change it into hashset back --- src/main/java/gregtech/api/util/GT_Recipe.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 5db314ed30..5a337922d3 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -366,6 +366,9 @@ public class GT_Recipe implements Comparable { public static boolean GTppRecipeHelper; public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) { + + HashSet isVisited = new HashSet<>(); + if (mFluidInputs.length > 0 && aFluidInputs == null) return false; int amt; for (FluidStack tFluid : mFluidInputs) @@ -389,8 +392,6 @@ public class GT_Recipe implements Comparable { if (mInputs.length > 0 && aInputs == null) return false; - ConcurrentHashMap isUsed = new ConcurrentHashMap<>(); - for (ItemStack tStack : mInputs) { ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); if (unified_tStack != null) { @@ -399,8 +400,8 @@ public class GT_Recipe implements Comparable { int it = 0; for (ItemStack aStack : aInputs) { it ++; - if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isUsed.containsKey(it)) { - isUsed.put(it, true); + if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack) && !isVisited.contains(it)) { + isVisited.add(it); if (GTppRecipeHelper) {//remove once the fix is out if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) { if (!GT_Utility.areStacksEqual(aStack, tStack, false)) -- cgit From 7ed5c6119dbe26a6916d6f9b99b8aa87a7b26ee2 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Thu, 22 Jul 2021 00:12:23 +0800 Subject: Update GT_Recipe.java --- src/main/java/gregtech/api/util/GT_Recipe.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 5a337922d3..a04df205b7 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -367,8 +367,7 @@ public class GT_Recipe implements Comparable { public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) { - HashSet isVisited = new HashSet<>(); - + if (mInputs.length > 0 && aInputs == null) return false; if (mFluidInputs.length > 0 && aFluidInputs == null) return false; int amt; for (FluidStack tFluid : mFluidInputs) @@ -390,8 +389,8 @@ public class GT_Recipe implements Comparable { if (temp) return false; } - if (mInputs.length > 0 && aInputs == null) return false; - + HashSet isVisited = new HashSet<>(); + for (ItemStack tStack : mInputs) { ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); if (unified_tStack != null) { -- cgit From 72a2310bae425bbc8956fd1095855e9375bcb91b Mon Sep 17 00:00:00 2001 From: Usernm Date: Thu, 22 Jul 2021 00:08:56 +0300 Subject: Fix cleanroom blocks color Fix cleanroom maintenance and energy hatch color --- .../common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 6cf19d6867..e486596fe6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -190,7 +190,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas ++mGlassCount; } else { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ); - if ((!this.addMaintenanceToMachineList(tTileEntity, 82)) && (!this.addEnergyInputToMachineList(tTileEntity, 82))) { + if ((!this.addMaintenanceToMachineList(tTileEntity, 210)) && (!this.addEnergyInputToMachineList(tTileEntity, 210))) { if (tBlock instanceof ic2.core.block.BlockIC2Door) { if ((tMeta & 8) == 0) { // let's not fiddle with bits anymore. -- cgit From 201386d000274749ad4315802dc6ac06d9a7ea63 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 22 Jul 2021 09:43:09 +0800 Subject: Increase the EU cap even more --- .../metatileentity/implementations/GT_MetaTileEntity_Transformer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index 5cc4245bc8..8e8cc6de76 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -115,7 +115,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public long maxEUStore() { - return Math.max(512L, 1L << (mTier + 1)) + V[mTier + 1] * 2L; + return Math.max(512L, 1L << (mTier + 2)) + V[mTier + 1] * 4L; } @Override -- cgit From cc08b8898a3cdc3a207fe93ff7d2d6b359a66f9b Mon Sep 17 00:00:00 2001 From: repo_alt Date: Thu, 22 Jul 2021 12:41:17 +0300 Subject: Added caching to the ME output bus, to reduce stress on ME system in high output rate cases Also, added item detector cover support to the bus, so that the item detector will signal "full" in case of ME failure https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/8231 --- .../gregtech/common/covers/GT_Cover_ItemMeter.java | 18 +++- .../GT_MetaTileEntity_Hatch_OutputBus_ME.java | 100 +++++++++++++++++++-- 2 files changed, 109 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java index 0bd90745a4..f1c1bc7df7 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ItemMeter.java @@ -6,10 +6,13 @@ import gregtech.api.gui.widgets.GT_GuiFakeItemButton; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalChestBase; import net.minecraft.client.gui.GuiButton; @@ -43,13 +46,22 @@ public class GT_Cover_ItemMeter extends GT_CoverBehavior { long tMax = 0; long tUsed = 0; - if (aTileEntity instanceof GT_MetaTileEntity_DigitalChestBase) { - GT_MetaTileEntity_DigitalChestBase dc = (GT_MetaTileEntity_DigitalChestBase)aTileEntity; + IMetaTileEntity mte = ((IGregTechTileEntity)aTileEntity).getMetaTileEntity(); + if (mte instanceof GT_MetaTileEntity_DigitalChestBase) { + GT_MetaTileEntity_DigitalChestBase dc = (GT_MetaTileEntity_DigitalChestBase)mte; tMax = dc.getMaxItemCount(); // currently it is limited by int, but there is not much reason for that ItemStack[] inv = dc.getStoredItemData(); if (inv != null && inv.length > 1 && inv[1] != null) tUsed = inv[1].stackSize; - } else { + } + else if (mte instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) { + if (((GT_MetaTileEntity_Hatch_OutputBus_ME)mte).isLastOutputFailed()) + { + tMax = 64; + tUsed = 64; + } + } + else { int[] tSlots = (aCoverVariable & SLOT_MASK) > 0 ? new int[] {(aCoverVariable & SLOT_MASK) - 1} : aTileEntity.getAccessibleSlotsFromSide(aSide); diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index 9b74b979f4..ef3689f64c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -21,8 +21,12 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Utility; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH; @@ -30,6 +34,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_HATCH; public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatch_OutputBus { private BaseActionSource requestSource = null; private AENetworkProxy gridProxy = null; + ItemStack cachedStack = null; + long lastOutputTick = 0; + long tickCounter = 0; + boolean lastOutputFailed = false; public GT_MetaTileEntity_Hatch_OutputBus_ME(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 1, new String[]{ @@ -82,16 +90,67 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc try { AENetworkProxy proxy = getProxy(); if (proxy == null) - return stack.stackSize; - IMEMonitor sg = proxy.getStorage().getItemInventory(); - IAEItemStack toStore = AEApi.instance().storage().createItemStack(stack); - IAEItemStack rest = Platform.poweredInsert( proxy.getEnergy(), sg, toStore, getRequest()); - if (rest != null) - return (int)rest.getStackSize(); + { + lastOutputFailed = true; + int cacheSize = cachedStack == null ? 0 : cachedStack.stackSize; + cachedStack = null; + return stack.stackSize + cacheSize; + } + if (lastOutputFailed) // if last output failed, don't buffer + { + IMEMonitor sg = proxy.getStorage().getItemInventory(); + IAEItemStack toStore = AEApi.instance().storage().createItemStack(stack); + IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest()); + if (rest != null && rest.getStackSize() > 0) + return (int) rest.getStackSize(); + else + lastOutputFailed = false; + } + else if (cachedStack != null && ((tickCounter > (lastOutputTick+20)) || !cachedStack.isItemEqual(stack))) + { + lastOutputTick = tickCounter; + boolean sameStack = cachedStack.isItemEqual(stack); + if (sameStack) + cachedStack.stackSize += stack.stackSize; + IMEMonitor sg = proxy.getStorage().getItemInventory(); + IAEItemStack toStore = AEApi.instance().storage().createItemStack(cachedStack); + IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest()); + if (rest != null && rest.getStackSize() > 0) + { + lastOutputFailed = true; + cachedStack.stackSize = (int)rest.getStackSize(); + if (sameStack) // return all that was cached to sender + { + cachedStack = null; + return (int) rest.getStackSize(); + } + else // leave the cache, and return input to sender + { + cachedStack.stackSize = (int)rest.getStackSize(); + return stack.stackSize; + } + } + else + { + if (!sameStack) + cachedStack = stack.copy(); + else + cachedStack = null; + return 0; + } + } + else + { + if (cachedStack == null) + cachedStack = stack.copy(); + else + cachedStack.stackSize += stack.stackSize; + } return 0; } catch( final GridAccessException ignored ) { + lastOutputFailed = true; } return stack.stackSize; } @@ -131,4 +190,33 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc @Optional.Method(modid = "appliedenergistics2") public void gridChanged() { } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + tickCounter = aTick; + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) + { + super.saveNBTData(aNBT); + if (cachedStack != null) { + NBTTagCompound tTag = new NBTTagCompound(); + cachedStack.writeToNBT(tTag); + aNBT.setTag("cachedStack", tTag); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + NBTBase t = aNBT.getTag("cachedStack"); + if (t instanceof NBTTagCompound) + cachedStack = GT_Utility.loadItem((NBTTagCompound)t); + } + + public boolean isLastOutputFailed() { + return lastOutputFailed; + } } -- cgit From 41e3bfddf317ebb56f8c6e0110a0d47db29e1780 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Sat, 24 Jul 2021 11:34:14 +0300 Subject: Missing bit of ME output bus optimization (leftover piece of cached stack gets stuck in the bus) --- .../GT_MetaTileEntity_Hatch_OutputBus_ME.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index ef3689f64c..4b6ce12e65 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -118,7 +118,6 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc if (rest != null && rest.getStackSize() > 0) { lastOutputFailed = true; - cachedStack.stackSize = (int)rest.getStackSize(); if (sameStack) // return all that was cached to sender { cachedStack = null; @@ -191,9 +190,39 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc public void gridChanged() { } + @Optional.Method(modid = "appliedenergistics2") + private void flushCachedStack() + { + if (cachedStack == null) + return; + AENetworkProxy proxy = getProxy(); + if (proxy == null) { + lastOutputFailed = true; + return; + } + try { + IMEMonitor sg = proxy.getStorage().getItemInventory(); + IAEItemStack toStore = AEApi.instance().storage().createItemStack(cachedStack); + IAEItemStack rest = Platform.poweredInsert(proxy.getEnergy(), sg, toStore, getRequest()); + if (rest != null && rest.getStackSize() > 0) { + lastOutputFailed = true; + cachedStack.stackSize = (int) rest.getStackSize(); + } + else + cachedStack = null; + } + catch( final GridAccessException ignored ) + { + lastOutputFailed = true; + } + lastOutputTick = tickCounter; + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { tickCounter = aTick; + if (tickCounter > (lastOutputTick + 40)) + flushCachedStack(); super.onPostTick(aBaseMetaTileEntity, aTick); } -- cgit From 03ca88667a58241b7fe9ddcfb513ed20ab439ce4 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 24 Jul 2021 03:09:35 -0600 Subject: Update single-block boiler GUI to use getCapacity() Update single-block boiler GUI to use GT_MetaTileEntity_Boiler.getCapacity() for computing water and steam fill percentages. Also change lava boiler to have 32000 capacity (from 16000). --- src/main/java/gregtech/common/gui/GT_Container_Boiler.java | 12 +++++++----- .../java/gregtech/common/gui/GT_GUIContainer_Boiler.java | 4 ++-- .../boilers/GT_MetaTileEntity_Boiler_Bronze.java | 4 ++-- .../tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java | 7 +++++-- .../tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java | 4 ++-- .../boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java | 2 +- .../tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java | 4 ++-- 7 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java index f8c784fb70..aca73641f6 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java @@ -10,14 +10,12 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; public class GT_Container_Boiler extends GT_ContainerMetaTile_Machine { - private int mSteamCapacity = 0;//FB: UR - UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR public int mWaterAmount = 0; public int mSteamAmount = 0; public int mProcessingEnergy = 0; public int mTemperature = 2; - public GT_Container_Boiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aSteamCapacity) { + public GT_Container_Boiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); - this.mSteamCapacity = aSteamCapacity; } @Override @@ -44,14 +42,18 @@ public class GT_Container_Boiler extends GT_ContainerMetaTile_Machine { if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { return; } + + // GT_MetaTileEntity_Boilder.getCapacity() is used for both water and steam capacity. + int capacity = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).getCapacity(); + this.mTemperature = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mTemperature; this.mProcessingEnergy = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; this.mSteamAmount = (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mSteam.amount); this.mWaterAmount = (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid.amount); this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (this.mSteamCapacity - 100))); - this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / 15900)); + this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / capacity)); + this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / capacity)); this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); for (Object crafter : this.crafters) { diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java index 45406faec7..4af4826f93 100644 --- a/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java +++ b/src/main/java/gregtech/common/gui/GT_GUIContainer_Boiler.java @@ -5,8 +5,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; public class GT_GUIContainer_Boiler extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_Boiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName, int aSteamCapacity) { - super(new GT_Container_Boiler(aInventoryPlayer, aTileEntity, aSteamCapacity), "gregtech:textures/gui/" + aTextureName); + public GT_GUIContainer_Boiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName) { + super(new GT_Container_Boiler(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/" + aTextureName); } @Override diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java index 5a89f50476..41620dd711 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -76,12 +76,12 @@ public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "BronzeBoiler.png", 16000); + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "BronzeBoiler.png"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index c71126b146..6372e9f581 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -78,14 +78,17 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png"); } + @Override + public int getCapacity() { return 32000; } + @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_Boiler_Lava(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java index 59f84ebd91..5723865baf 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java @@ -114,12 +114,12 @@ public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, getCapacity()); + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", getCapacity()); + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java index ff77b049c4..e044b6fb9b 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java @@ -56,7 +56,7 @@ public class GT_MetaTileEntity_Boiler_Solar_Steel extends GT_MetaTileEntity_Boil @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarHPBoiler.png", getCapacity()); + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarHPBoiler.png"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java index 50f68425d7..ab51156868 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java @@ -66,12 +66,12 @@ public class GT_MetaTileEntity_Boiler_Steel extends GT_MetaTileEntity_Boiler_Bro @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png"); } @Override -- cgit From 6fcfb106188be4b4a8e954586302b5664853d9c7 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 24 Jul 2021 04:16:20 -0600 Subject: Fix method formatting --- .../common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index 6372e9f581..0ed5fd6c70 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -87,7 +87,9 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { } @Override - public int getCapacity() { return 32000; } + public int getCapacity() { + return 32000; + } @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { -- cgit From 1518df420c17df2e90f01a1ee1c00f7f02760025 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 24 Jul 2021 05:06:44 -0600 Subject: Add missing (- 100) to GUI calculations --- src/main/java/gregtech/common/gui/GT_Container_Boiler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java index aca73641f6..ee69ab8e4f 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java @@ -52,8 +52,8 @@ public class GT_Container_Boiler extends GT_ContainerMetaTile_Machine { this.mWaterAmount = (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mFluid.amount); this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); - this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / capacity)); - this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / capacity)); + this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (capacity - 100))); + this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / (capacity - 100))); this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); for (Object crafter : this.crafters) { -- cgit From f748b5d27785c4a5fcfd97928c467242f0e9f6f1 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 24 Jul 2021 05:28:53 -0600 Subject: Fix typo --- src/main/java/gregtech/common/gui/GT_Container_Boiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java index ee69ab8e4f..afceed249b 100644 --- a/src/main/java/gregtech/common/gui/GT_Container_Boiler.java +++ b/src/main/java/gregtech/common/gui/GT_Container_Boiler.java @@ -43,7 +43,7 @@ public class GT_Container_Boiler extends GT_ContainerMetaTile_Machine { return; } - // GT_MetaTileEntity_Boilder.getCapacity() is used for both water and steam capacity. + // GT_MetaTileEntity_Boiler.getCapacity() is used for both water and steam capacity. int capacity = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).getCapacity(); this.mTemperature = ((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).mTemperature; -- cgit From a054352898d814f33e6a14beb82817567caa45ca Mon Sep 17 00:00:00 2001 From: Sphyix Date: Mon, 26 Jul 2021 01:24:13 +0200 Subject: added hazmat armors --- src/main/java/gregtech/common/GT_Proxy.java | 157 +++++++++++++++++++++------- 1 file changed, 120 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 636d78be51..1a92984267 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -107,6 +107,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.stream.Collectors; import java.util.concurrent.locks.ReentrantLock; +import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.GT_Values.debugEntityCramming; @@ -477,39 +478,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { OrePrefixes.cellMolten.mContainerItem = ItemList.Cell_Empty.get(1L); OrePrefixes.cell.mContainerItem = ItemList.Cell_Empty.get(1L); - GregTech_API.sFrostHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sFrostHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sFrostHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sFrostHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - - GregTech_API.sHeatHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sHeatHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sHeatHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sHeatHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - - GregTech_API.sBioHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sBioHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sBioHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sBioHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - - GregTech_API.sGasHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - - GregTech_API.sRadioHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sRadioHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sRadioHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sRadioHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - - GregTech_API.sElectroHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - GregTech_API.sElectroHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - GregTech_API.sElectroHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - GregTech_API.sElectroHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); - GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_helmet, 1, 32767)); - GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_chestplate, 1, 32767)); - GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_leggings, 1, 32767)); - GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_boots, 1, 32767)); + GT_ModHandler.sNonReplaceableItems.add(new ItemStack(Items.bow, 1, 32767)); GT_ModHandler.sNonReplaceableItems.add(new ItemStack(Items.fishing_rod, 1, 32767)); @@ -586,10 +555,94 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_OreDictUnificator.registerOre("cropGrape", GT_ModHandler.getModItem("magicalcrops", "magicalcrops_CropProduce", 1L, 4)); GT_OreDictUnificator.registerOre("cropTea", GT_ModHandler.getModItem("ganyssurface", "teaLeaves", 1L, 0)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getModItem("EMT", "NanoBootsTraveller", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getModItem("EMT", "NanosuitGogglesRevealing", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getModItem("EMT", "QuantumBootsTraveller", 1L, 32767)); - GregTech_API.sGasHazmatList.add(GT_ModHandler.getModItem("EMT", "QuantumGogglesRevealing", 1L, 32767)); + // IC2 Hazmat + addFullHazmatToIC2Item("hazmatHelmet"); + addFullHazmatToIC2Item("hazmatChestplate"); + addFullHazmatToIC2Item("hazmatLeggings"); + addFullHazmatToIC2Item("hazmatBoots"); + addFullHazmatToIC2Item("nanoHelmet"); + addFullHazmatToIC2Item("nanoBoots"); + addFullHazmatToIC2Item("nanoLegs"); + addFullHazmatToIC2Item("nanoChestplate"); + addFullHazmatToIC2Item("quantumHelmet"); + addFullHazmatToIC2Item("quantumBodyarmor"); + addFullHazmatToIC2Item("quantumLeggings"); + addFullHazmatToIC2Item("quantumBoots"); + + //GraviSuite Hazmat + addFullHazmatToGeneralItem("GraviSuite", "graviChestPlate", 1L); + addFullHazmatToGeneralItem("GraviSuite", "advNanoChestPlate", 1L); + + // EMT Hazmat + addFullHazmatToGeneralItem("EMT", "itemArmorQuantumChestplate", 1L); + addFullHazmatToGeneralItem("EMT", "NanoBootsTraveller", 1L); + addFullHazmatToGeneralItem("EMT", "NanosuitGogglesRevealing", 1L); + addFullHazmatToGeneralItem("EMT", "QuantumBootsTraveller", 1L); + addFullHazmatToGeneralItem("EMT", "QuantumGogglesRevealing", 1L); + addFullHazmatToGeneralItem("EMT", "SolarHelmetRevealing", 1L); + addFullHazmatToGeneralItem("EMT", "NanosuitWing", 1L); + addFullHazmatToGeneralItem("EMT", "QuantumWing", 1L); + + // DraconicEvolution Hazmat + addFullHazmatToGeneralItem("DraconicEvolution", "draconicBoots", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "draconicHelm", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "draconicLeggs", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "draconicChest", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "wyvernBoots", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "wyvernHelm", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "wyvernLeggs", 1L, 0); + addFullHazmatToGeneralItem("DraconicEvolution", "wyvernChest", 1L, 0); + + //AdvancedSolarPanel + addFullHazmatToGeneralItem("AdvancedSolarPanel", "advanced_solar_helmet", 1L); + addFullHazmatToGeneralItem("AdvancedSolarPanel", "hybrid_solar_helmet", 1L); + addFullHazmatToGeneralItem("AdvancedSolarPanel", "ultimate_solar_helmet", 1L); + + //TaintedMagic Hazmat + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidwalkerBoots", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressHelmet", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressChestplate", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressLeggings", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressHelmet", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressChestplate", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressLeggings", 1L); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidmetalGoggles", 1L); + //TaintedMagic Hazmat + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidwalkerBoots", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressHelmet", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressChestplate", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressLeggings", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressHelmet", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressChestplate", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressLeggings", 1L, 0); + addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidmetalGoggles", 1L, 0); + + //WitchingGadgets Hazmat + addFullHazmatToGeneralItem("WitchingGadgets", "item.WG_PrimordialHelm", 1L); + addFullHazmatToGeneralItem("WitchingGadgets", "item.WG_PrimordialChest", 1L); + addFullHazmatToGeneralItem("WitchingGadgets", "item.WG_PrimordialLegs", 1L); + addFullHazmatToGeneralItem("WitchingGadgets", "item.WG_PrimordialBoots", 1L); + + //ThaumicTinkerer Hazmat + addFullHazmatToGeneralItem("ThaumicTinkerer", "ichorclothChestGem", 1L); + addFullHazmatToGeneralItem("ThaumicTinkerer", "ichorclothBootsGem", 1L); + addFullHazmatToGeneralItem("ThaumicTinkerer", "ichorclothHelmGem", 1L); + addFullHazmatToGeneralItem("ThaumicTinkerer", "ichorclothLegsGem", 1L); + + //GalaxySpace Hazmat + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_helmet", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_helmetglasses", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_plate", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_jetplate", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_leg", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_boots", 1L); + addFullHazmatToGeneralItem("GalaxySpace", "item.spacesuit_gravityboots", 1L); + + //Extra Hazmat + GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_helmet, 1, W)); + GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_chestplate, 1, W)); + GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_leggings, 1, W)); + GregTech_API.sElectroHazmatList.add(new ItemStack(Items.chainmail_boots, 1, W)); GregTech_API.sLoadStarted = true; for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { @@ -2043,4 +2096,34 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { if (event.block.getUnlocalizedName().equals("blockAlloyGlass")) GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); } + + public static void addFullHazmatToGeneralItem(String aModID, String aItem, long aAmount, int aMeta){ + ItemStack item = GT_ModHandler.getModItem(aModID, aItem, aAmount, aMeta); + GregTech_API.sGasHazmatList.add(item); + GregTech_API.sBioHazmatList.add(item); + GregTech_API.sFrostHazmatList.add(item); + GregTech_API.sHeatHazmatList.add(item); + GregTech_API.sRadioHazmatList.add(item); + GregTech_API.sElectroHazmatList.add(item); + } + + public static void addFullHazmatToGeneralItem(String aModID, String aItem, long aAmount){ + ItemStack item = GT_ModHandler.getModItem(aModID, aItem, aAmount, W); + GregTech_API.sGasHazmatList.add(item); + GregTech_API.sBioHazmatList.add(item); + GregTech_API.sFrostHazmatList.add(item); + GregTech_API.sHeatHazmatList.add(item); + GregTech_API.sRadioHazmatList.add(item); + GregTech_API.sElectroHazmatList.add(item); + } + + public static void addFullHazmatToIC2Item(String aItem){ + ItemStack item = GT_ModHandler.getIC2Item(aItem, 1L, W); + GregTech_API.sGasHazmatList.add(item); + GregTech_API.sBioHazmatList.add(item); + GregTech_API.sFrostHazmatList.add(item); + GregTech_API.sHeatHazmatList.add(item); + GregTech_API.sRadioHazmatList.add(item); + GregTech_API.sElectroHazmatList.add(item); + } } -- cgit From 6ec756003cfda588831ec45a961163bee266a7c8 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Mon, 26 Jul 2021 01:52:13 +0200 Subject: added tooltip to armors providing hazmat --- src/main/java/gregtech/common/GT_Proxy.java | 32 +++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 1a92984267..39102b6b46 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -60,6 +60,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.potion.Potion; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; @@ -70,10 +71,7 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import net.minecraftforge.event.entity.player.ArrowLooseEvent; -import net.minecraftforge.event.entity.player.ArrowNockEvent; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.terraingen.OreGenEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.ChunkDataEvent; @@ -2126,4 +2124,30 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GregTech_API.sRadioHazmatList.add(item); GregTech_API.sElectroHazmatList.add(item); } + + public static boolean providesProtection(ItemStack aStack){ + boolean isGas = GT_Utility.isStackInList(aStack, GregTech_API.sGasHazmatList); + boolean isBio = GT_Utility.isStackInList(aStack, GregTech_API.sBioHazmatList); + boolean isFrost = GT_Utility.isStackInList(aStack, GregTech_API.sFrostHazmatList); + boolean isHeat = GT_Utility.isStackInList(aStack, GregTech_API.sHeatHazmatList); + boolean isRadio = GT_Utility.isStackInList(aStack, GregTech_API.sRadioHazmatList); + boolean isElectro = GT_Utility.isStackInList(aStack, GregTech_API.sElectroHazmatList); + if(isGas && isBio && isFrost && isHeat && isRadio && isElectro) + return true; + return false; + } + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + if (event.itemStack == null) { + return; + } + else { + ItemStack aStackTemp = event.itemStack; + GT_ItemStack aStack = new GT_ItemStack(aStackTemp); + if (providesProtection(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE + "Provides full hazmat protection."); + } + } + } } -- cgit From 047277e7c499cab16529545bb82a27e2ced32c0e Mon Sep 17 00:00:00 2001 From: Sphyix Date: Mon, 26 Jul 2021 02:44:36 +0200 Subject: clean, fixed nano --- src/main/java/gregtech/common/GT_Proxy.java | 31 ++++++++--------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 39102b6b46..e35661a617 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -560,8 +560,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { addFullHazmatToIC2Item("hazmatBoots"); addFullHazmatToIC2Item("nanoHelmet"); addFullHazmatToIC2Item("nanoBoots"); - addFullHazmatToIC2Item("nanoLegs"); - addFullHazmatToIC2Item("nanoChestplate"); + addFullHazmatToIC2Item("nanoLeggings"); + addFullHazmatToIC2Item("nanoBodyarmor"); addFullHazmatToIC2Item("quantumHelmet"); addFullHazmatToIC2Item("quantumBodyarmor"); addFullHazmatToIC2Item("quantumLeggings"); @@ -605,15 +605,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressChestplate", 1L); addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressLeggings", 1L); addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidmetalGoggles", 1L); - //TaintedMagic Hazmat - addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidwalkerBoots", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressHelmet", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressChestplate", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemShadowFortressLeggings", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressHelmet", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressChestplate", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidFortressLeggings", 1L, 0); - addFullHazmatToGeneralItem("TaintedMagic", "ItemVoidmetalGoggles", 1L, 0); //WitchingGadgets Hazmat addFullHazmatToGeneralItem("WitchingGadgets", "item.WG_PrimordialHelm", 1L); @@ -2097,26 +2088,20 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public static void addFullHazmatToGeneralItem(String aModID, String aItem, long aAmount, int aMeta){ ItemStack item = GT_ModHandler.getModItem(aModID, aItem, aAmount, aMeta); - GregTech_API.sGasHazmatList.add(item); - GregTech_API.sBioHazmatList.add(item); - GregTech_API.sFrostHazmatList.add(item); - GregTech_API.sHeatHazmatList.add(item); - GregTech_API.sRadioHazmatList.add(item); - GregTech_API.sElectroHazmatList.add(item); + addItemToHazmatLists(item); } public static void addFullHazmatToGeneralItem(String aModID, String aItem, long aAmount){ ItemStack item = GT_ModHandler.getModItem(aModID, aItem, aAmount, W); - GregTech_API.sGasHazmatList.add(item); - GregTech_API.sBioHazmatList.add(item); - GregTech_API.sFrostHazmatList.add(item); - GregTech_API.sHeatHazmatList.add(item); - GregTech_API.sRadioHazmatList.add(item); - GregTech_API.sElectroHazmatList.add(item); + addItemToHazmatLists(item); } public static void addFullHazmatToIC2Item(String aItem){ ItemStack item = GT_ModHandler.getIC2Item(aItem, 1L, W); + addItemToHazmatLists(item); + } + + private static void addItemToHazmatLists(ItemStack item){ GregTech_API.sGasHazmatList.add(item); GregTech_API.sBioHazmatList.add(item); GregTech_API.sFrostHazmatList.add(item); -- cgit From dfabedc7c7b5c33369402c7fccc6536a470e98f0 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Mon, 26 Jul 2021 00:58:08 -0600 Subject: Comment out example code adding invalid ores --- build.properties | 2 +- .../java/gregtech/loaders/materialprocessing/ProcessingConfig.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/build.properties b/build.properties index 0b2e57e8f4..ef1106d29a 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.00 +gt.version=5.09.38.00 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java index 512a01f1ff..29d4fe376c 100644 --- a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java +++ b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java @@ -15,11 +15,15 @@ public class ProcessingConfig implements gregtech.api.interfaces.IMaterialHandle @Override public void onMaterialsInit() { /** This is just left here as an example of how to add new materials. **/ + // If you uncomment this, these custom ores will get added to the Deep Dark void miner ore list and cause bugged ores to be generated! + // See: com.dreammaster.bartworksHandler.VoidMinerLoader + /* int i = 0; for (int j = GregTech_API.sMaterialProperties.get("general", "AmountOfCustomMaterialSlots", 16); i < j; i++) { String aID = (i < 10 ? "0" : "") + i; new Materials(-1, TextureSet.SET_METALLIC, 1.0F, 0, 0, 0, 255, 255, 255, 0, "CustomMat" + aID, "CustomMat" + aID, 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, "custom", true, aID); } + */ } @Override -- cgit From 318d2753a34110d6edf6cfbd23711d799df4113e Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Mon, 26 Jul 2021 01:01:00 -0600 Subject: Fix comment --- src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java index 29d4fe376c..5a87070236 100644 --- a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java +++ b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java @@ -15,7 +15,7 @@ public class ProcessingConfig implements gregtech.api.interfaces.IMaterialHandle @Override public void onMaterialsInit() { /** This is just left here as an example of how to add new materials. **/ - // If you uncomment this, these custom ores will get added to the Deep Dark void miner ore list and cause bugged ores to be generated! + // If you uncomment this, these custom materials will get added to the Deep Dark void miner ore list and cause bugged ores to be generated! // See: com.dreammaster.bartworksHandler.VoidMinerLoader /* int i = 0; -- cgit From 1c10a3c9d8ab37d65d7b2278ced0198f8f8a9888 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Mon, 26 Jul 2021 10:27:47 -0600 Subject: Delete no longer accurate comment, and disable with if rather than commenting out --- .../loaders/materialprocessing/ProcessingConfig.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java index 5a87070236..23bc718bb4 100644 --- a/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java +++ b/src/main/java/gregtech/loaders/materialprocessing/ProcessingConfig.java @@ -15,15 +15,13 @@ public class ProcessingConfig implements gregtech.api.interfaces.IMaterialHandle @Override public void onMaterialsInit() { /** This is just left here as an example of how to add new materials. **/ - // If you uncomment this, these custom materials will get added to the Deep Dark void miner ore list and cause bugged ores to be generated! - // See: com.dreammaster.bartworksHandler.VoidMinerLoader - /* - int i = 0; - for (int j = GregTech_API.sMaterialProperties.get("general", "AmountOfCustomMaterialSlots", 16); i < j; i++) { - String aID = (i < 10 ? "0" : "") + i; - new Materials(-1, TextureSet.SET_METALLIC, 1.0F, 0, 0, 0, 255, 255, 255, 0, "CustomMat" + aID, "CustomMat" + aID, 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, "custom", true, aID); + if (false) { + int i = 0; + for (int j = GregTech_API.sMaterialProperties.get("general", "AmountOfCustomMaterialSlots", 16); i < j; i++) { + String aID = (i < 10 ? "0" : "") + i; + new Materials(-1, TextureSet.SET_METALLIC, 1.0F, 0, 0, 0, 255, 255, 255, 0, "CustomMat" + aID, "CustomMat" + aID, 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, "custom", true, aID); + } } - */ } @Override -- cgit From 9b202fde14af6bc7215b4288e7953aaa4ff798aa Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Wed, 28 Jul 2021 10:28:28 -0600 Subject: Delete dynamic recipe generation code --- build.properties | 2 +- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 13126de925..14b31b0cc5 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.01 +gt.version=5.09.37.02 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 701a81b6ba..41184a17ac 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -16,13 +16,11 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.loaders.oreprocessing.ProcessingLog; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.mutable.MutableBoolean; import org.lwjgl.input.Keyboard; @@ -108,10 +106,6 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - //Dynamic recipe adding for newly found logWoods - wont be visible in nei most probably - if (tRecipe == null) - tRecipe = addRecipesDynamically(tInputs, tFluids, tTier); - if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) return false; @@ -133,21 +127,6 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock return true; } - private GT_Recipe addRecipesDynamically(ItemStack[] tInputs, FluidStack[] tFluids, int tTier) { - if (tInputs.length > 1 || (tInputs[0] != null && tInputs[0].getItem() != GT_Utility.getIntegratedCircuit(0).getItem())) { - int oreId = OreDictionary.getOreID("logWood"); - for (ItemStack is : tInputs) { - for (int id : OreDictionary.getOreIDs(is)) { - if (oreId == id) { - ProcessingLog.addPyrolyeOvenRecipes(is); - return GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - } - } - } - } - return null; - } - @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; -- cgit From de8829ca474fd3a8e7b3d4c64d5c70b00c8070e0 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 29 Jul 2021 19:11:41 -0600 Subject: Oredict clay buckets + fix railcraft item IDs --- build.properties | 2 +- src/main/java/gregtech/api/util/GT_ModHandler.java | 8 ++++---- src/main/java/gregtech/common/GT_Proxy.java | 6 ++++++ .../gregtech/loaders/preload/GT_Loader_OreDictionary.java | 11 ++++++----- 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 14b31b0cc5..a553d39ee7 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.02 +gt.version=5.09.37.03 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 7e66e6cc2a..ac9f7bd3d4 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -383,14 +383,14 @@ public class GT_ModHandler { } /** - * Gets an Item from RailCraft + * Gets an Item from the specified mod */ public static ItemStack getModItem(String aModID, String aItem, long aAmount) { return getModItem(aModID, aItem, aAmount, null); } /** - * Gets an Item from RailCraft, and returns a Replacement Item if not possible + * Gets an Item from the specified mod, and returns a Replacement Item if not possible */ public static ItemStack getModItem(String aModID, String aItem, long aAmount, ItemStack aReplacement) { if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null; @@ -398,7 +398,7 @@ public class GT_ModHandler { } /** - * Gets an Item from RailCraft, but the Damage Value can be specified + * Gets an Item from the specified mod, but the Damage Value can be specified */ public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta) { ItemStack rStack = getModItem(aModID, aItem, aAmount); @@ -408,7 +408,7 @@ public class GT_ModHandler { } /** - * Gets an Item from RailCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible + * Gets an Item from the specified mod, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible */ public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta, ItemStack aReplacement) { ItemStack rStack = getModItem(aModID, aItem, aAmount, aReplacement); diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index e35661a617..6006b77626 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -553,6 +553,12 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_OreDictUnificator.registerOre("cropGrape", GT_ModHandler.getModItem("magicalcrops", "magicalcrops_CropProduce", 1L, 4)); GT_OreDictUnificator.registerOre("cropTea", GT_ModHandler.getModItem("ganyssurface", "teaLeaves", 1L, 0)); + // Clay buckets, which don't get registered until Iguana Tweaks pre-init + GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Empty, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); + // IC2 Hazmat addFullHazmatToIC2Item("hazmatHelmet"); addFullHazmatToIC2Item("hazmatChestplate"); diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_OreDictionary.java b/src/main/java/gregtech/loaders/preload/GT_Loader_OreDictionary.java index efb54fa25d..7165650072 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_OreDictionary.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_OreDictionary.java @@ -31,6 +31,7 @@ public class GT_Loader_OreDictionary implements Runnable { GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Water, new ItemStack(Items.water_bucket, 1, 0)); GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Lava, new ItemStack(Items.lava_bucket, 1, 0)); GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Milk, new ItemStack(Items.milk_bucket, 1, 0)); + // Clay buckets handled in gregtech.common.GT_Proxy.onLoad() as they aren't registered until Iguana Tweaks pre-init. GT_OreDictUnificator.set(OrePrefixes.bottle, Materials.Empty, new ItemStack(Items.glass_bottle, 1, 0)); GT_OreDictUnificator.set(OrePrefixes.bottle, Materials.Water, new ItemStack(Items.potionitem, 1, 0)); @@ -88,16 +89,16 @@ public class GT_Loader_OreDictionary implements Runnable { GT_OreDictUnificator.registerOre(OreDictNames.enderChest, new ItemStack(Blocks.ender_chest, 1)); } GT_OreDictUnificator.registerOre(OreDictNames.craftingAnvil, new ItemStack(Blocks.anvil, 1)); - GT_OreDictUnificator.registerOre(OreDictNames.craftingAnvil, GT_ModHandler.getModItem("Railcraft", "tile.railcraft.anvil", 1L, 0)); + GT_OreDictUnificator.registerOre(OreDictNames.craftingAnvil, GT_ModHandler.getModItem("Railcraft", "anvil", 1L, 0)); GT_OreDictUnificator.registerOre(OreDictNames.craftingIndustrialDiamond, ItemList.IC2_Industrial_Diamond.get(1L)); GT_OreDictUnificator.registerOre(OrePrefixes.dust, Materials.Wood, GT_ModHandler.getModItem("ThermalExpansion", "sawdust", 1L)); GT_OreDictUnificator.registerOre(OrePrefixes.glass, Materials.Reinforced, GT_ModHandler.getIC2Item("reinforcedGlass", 1L)); GT_OreDictUnificator.registerOre(OrePrefixes.glass, Materials.Reinforced, GT_ModHandler.getModItem("ThermalExpansion", "glassHardened", 1L)); - GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Basalt, GT_ModHandler.getModItem("Railcraft", "tile.railcraft.cube", 1L, 6)); - GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Marble, GT_ModHandler.getModItem("Railcraft", "tile.railcraft.cube", 1L, 7)); - GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Basalt, GT_ModHandler.getModItem("Railcraft", "tile.railcraft.brick.abyssal", 1L, 32767)); - GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Marble, GT_ModHandler.getModItem("Railcraft", "tile.railcraft.brick.quarried", 1L, 32767)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Basalt, GT_ModHandler.getModItem("Railcraft", "cube", 1L, 6)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Marble, GT_ModHandler.getModItem("Railcraft", "cube", 1L, 7)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Basalt, GT_ModHandler.getModItem("Railcraft", "brick.abyssal", 1L, 32767)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Marble, GT_ModHandler.getModItem("Railcraft", "brick.quarried", 1L, 32767)); GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Obsidian, new ItemStack(Blocks.obsidian, 1, 32767)); GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Stone, new ItemStack(Blocks.stone, 1, 32767)); GT_OreDictUnificator.registerOre(OrePrefixes.stoneMossy, new ItemStack(Blocks.mossy_cobblestone, 1, 32767)); -- cgit From 60782c9fe2699ea43ed90a8eaa800756317dca77 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 29 Jul 2021 22:05:04 -0600 Subject: Add clay bucket ore prefix; fix oredicting --- src/main/java/gregtech/api/enums/OrePrefixes.java | 6 ++++++ src/main/java/gregtech/common/GT_Proxy.java | 10 ++++++---- .../tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java | 4 ++++ .../java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 5 +++-- 4 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index ba91886c99..3aaea29f28 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -102,6 +102,7 @@ public enum OrePrefixes { cellMolten("Cells of Molten stuff", "Molten ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 31), // Hot Cell full of molten stuff, which can be used in the Plasma Generator. cell("Cells", "", " Cell", true, true, true, true, false, false, true, true, false, false, B[4] | B[8], M * 1, 64, 30), // Regular Gas/Fluid Cell. Introduced by Calclavia bucket("Buckets", "", " Bucket", true, true, true, true, false, false, true, false, false, false, B[4] | B[8], M * 1, 16, -1), // A vanilla Iron Bucket filled with the Material. + bucketClay("Clay Buckets", "", " Clay Bucket", true, true, true, true, false, false, true, false, false, false, B[4] | B[8], M * 1, 16, -1), // An Iguana Tweaks Clay Bucket filled with the Material. bottle("Bottles", "", " Bottle", true, true, true, true, false, false, false, false, false, false, B[4] | B[8], -1, 16, -1), // Glass Bottle containing a Fluid. capsule("Capsules", "", " Capsule", false, true, true, true, false, false, false, false, false, false, B[4] | B[8], M * 1, 16, -1), crystal("Crystals", "", " Crystal", false, true, false, false, false, false, true, false, false, false, B[2], M * 1, 64, -1), @@ -413,6 +414,10 @@ public enum OrePrefixes { bucket.mNotGeneratedItems.add(Materials.Lava); bucket.mNotGeneratedItems.add(Materials.Milk); bucket.mNotGeneratedItems.add(Materials.Water); + bucketClay.mNotGeneratedItems.add(Materials.Empty); + bucketClay.mNotGeneratedItems.add(Materials.Lava); + bucketClay.mNotGeneratedItems.add(Materials.Milk); + bucketClay.mNotGeneratedItems.add(Materials.Water); bottle.mNotGeneratedItems.add(Materials.Empty); bottle.mNotGeneratedItems.add(Materials.Water); bottle.mNotGeneratedItems.add(Materials.Milk); @@ -522,6 +527,7 @@ public enum OrePrefixes { cableGt02.mSecondaryMaterial = new MaterialStack(Materials.Rubber, plate.mMaterialAmount); cableGt01.mSecondaryMaterial = new MaterialStack(Materials.Rubber, plate.mMaterialAmount); bucket.mSecondaryMaterial = new MaterialStack(Materials.Iron, ingot.mMaterialAmount * 3); + bucketClay.mSecondaryMaterial = new MaterialStack(Materials.Clay, dust.mMaterialAmount * 5); cell.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellPlasma.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellMolten.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 6006b77626..042818758e 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -554,10 +554,12 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_OreDictUnificator.registerOre("cropTea", GT_ModHandler.getModItem("ganyssurface", "teaLeaves", 1L, 0)); // Clay buckets, which don't get registered until Iguana Tweaks pre-init - GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Empty, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucket, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); + OrePrefixes.bucketClay.mContainerItem = GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Empty, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); + FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.Milk.getFluid(1000L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Milk, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L))); // IC2 Hazmat addFullHazmatToIC2Item("hazmatHelmet"); diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index 0ed5fd6c70..aeb0a66173 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -127,6 +127,10 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { this.mProcessingEnergy += 1000 * ENERGY_PER_LAVA; aBaseMetaTileEntity.decrStackSize(2, 1); aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucketClay.get(Materials.Lava))) { + this.mProcessingEnergy += 1000 * ENERGY_PER_LAVA; + aBaseMetaTileEntity.decrStackSize(2, 1); + // Clay lava buckets break, so you don't get it back. } } diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 641aa6146e..bb5dcf6dcf 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2502,8 +2502,9 @@ public class GT_MachineRecipeLoader implements Runnable { tKey = "GT_FILL_WATER_BUCKET"; GT_LanguageManager.addStringLocalization(GT_MachineRecipeLoader.aTextTCGTPage + tKey, "You have discovered a way of filling a bucket with aqua essentia in order to simply get water."); GregTech_API.sThaumcraftCompat.addResearch(tKey, "Water Transmutation", "Filling buckets with water", null, "ALCHEMY", GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), 2, 0, 16, 5, Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.PERMUTATIO, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L)), null, new Object[]{GT_MachineRecipeLoader.aTextTCGTPage + tKey, - GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), - GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L)))}); + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L)))}); tKey = "GT_TRANSZINC"; GT_LanguageManager.addStringLocalization(GT_MachineRecipeLoader.aTextTCGTPage + tKey, "You have discovered a way to multiply zinc by steeping zinc nuggets in metallum harvested from other metals."); -- cgit From 7bd04b922aabff23349e19785e14a6d85130e3c3 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 29 Jul 2021 22:24:20 -0600 Subject: Fix duplicate Thaumcraft recipe --- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index bb5dcf6dcf..b0293cde7b 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2502,8 +2502,9 @@ public class GT_MachineRecipeLoader implements Runnable { tKey = "GT_FILL_WATER_BUCKET"; GT_LanguageManager.addStringLocalization(GT_MachineRecipeLoader.aTextTCGTPage + tKey, "You have discovered a way of filling a bucket with aqua essentia in order to simply get water."); GregTech_API.sThaumcraftCompat.addResearch(tKey, "Water Transmutation", "Filling buckets with water", null, "ALCHEMY", GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), 2, 0, 16, 5, Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.PERMUTATIO, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L)), null, new Object[]{GT_MachineRecipeLoader.aTextTCGTPage + tKey, - GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), - GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.capsule, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Water, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.AQUA, 4L)))}); tKey = "GT_TRANSZINC"; -- cgit From 412d64445546216444f0afbcc562e2ea6b1681d0 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 30 Jul 2021 12:41:54 +0800 Subject: Remove debug print --- src/main/java/gregtech/api/gui/GT_Container_BasicTank.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') 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 0ce9ab9232..477e52d103 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -52,9 +52,6 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { IFluidAccess tDrainableAccess = IFluidAccess.from(tTank, false); return handleFluidSlotClick(tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate()); } - if (mTileEntity.isServerSide()) { - aPlayer.addChatComponentMessage(new ChatComponentText(String.format("Slot Index: %d, aMouseClick: %d, Shift Hold: %d", aShifthold, aMouseclick, aShifthold))); - } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } -- cgit From 546b42d7440839477455b818133d80221c70c582 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 29 May 2021 23:52:15 +0800 Subject: Initial StructureLib integration --- build.gradle | 7 +- build.properties | 1 + src/main/java/gregtech/GT_Mod.java | 1 + .../api/metatileentity/BaseMetaTileEntity.java | 35 ++++- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 122 +++++++++++++++++ .../GT_MetaTileEntity_MultiBlockBase.java | 9 +- .../gregtech/api/util/GT_StructureUtility.java | 71 ++++++++++ .../java/gregtech/api/util/IGT_HatchAdder.java | 14 ++ .../GT_MetaTileEntity_AbstractMultiFurnace.java | 72 ++++------ .../GT_MetaTileEntity_ElectricBlastFurnace.java | 146 +++++++++------------ .../multi/GT_MetaTileEntity_MultiFurnace.java | 82 +++++------- src/main/resources/mcmod.info | 3 +- 12 files changed, 368 insertions(+), 195 deletions(-) create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java create mode 100644 src/main/java/gregtech/api/util/GT_StructureUtility.java create mode 100644 src/main/java/gregtech/api/util/IGT_HatchAdder.java (limited to 'src') diff --git a/build.gradle b/build.gradle index 8949f060c3..a69dd021b5 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ repositories { } maven { name = "chickenbones" - url = "http://chickenbones.net/maven/" + url = "https://nexus.covers1624.net/repository/maven-hosted/" } maven { name = "ic2, forestry" @@ -84,12 +84,17 @@ repositories { name = 'gtnh_download_source' artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]") } + maven { + name = "jitpack.io" + url = "https://jitpack.io" + } } dependencies { //Hard dep to start (Without this, it wont compile nor start) compile 'com.google.code.findbugs:jsr305:1.3.9' compile "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" + compile ("com.github.GTNewHorizons:StructureLib:${config.structurelib.version}:deobf") //Hard dep to compile (Without this, it wont compile, not even as library) api "appeng:appliedenergistics2:${config.ae2.version}:dev" diff --git a/build.properties b/build.properties index 14b31b0cc5..8392f3c2a1 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 gt.version=5.09.37.02 +structurelib.version=1.0.1 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index c601130ab9..d9a8d72ecd 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -74,6 +74,7 @@ import static gregtech.api.enums.GT_Values.MOD_ID_FR; @SuppressWarnings("ALL") @Mod(modid = "gregtech", name = "GregTech", version = "MC1710", useMetadata = false, dependencies = " required-after:IC2;" + + " required-after:structurelib;" + " after:dreamcraft;" + " after:Forestry;" + " after:PFAAGeologica;" + diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 6c43799638..d108236a39 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -8,6 +8,10 @@ import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -25,11 +29,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import gregtech.common.GT_Client; import gregtech.common.GT_Pollution; import ic2.api.Direction; @@ -73,7 +73,7 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @Optional.InterfaceList(value = { @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) -public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable { +public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider { private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; protected MetaTileEntity mMetaTileEntity; protected long mStoredEnergy = 0, mStoredSteam = 0; @@ -2368,4 +2368,27 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public void setShutdownStatus(boolean newStatus) { mWasShutdown = newStatus; } + + @Override + public IAlignment getAlignment() { + return getMetaTileEntity() instanceof IAlignmentProvider ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() : new BasicAlignment(); + } + + private class BasicAlignment implements IAlignment { + + @Override + public ExtendedFacing getExtendedFacing() { + return ExtendedFacing.of(ForgeDirection.getOrientation(getFrontFacing())); + } + + @Override + public void setExtendedFacing(ExtendedFacing alignment) { + setFrontFacing((byte) Math.max(alignment.getDirection().ordinal(), 5)); + } + + @Override + public IAlignmentLimits getAlignmentLimits() { + return (direction, rotation, flip) -> rotation.isNotRotated() && flip.isNotFlipped(); + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java new file mode 100644 index 0000000000..7d06378ce1 --- /dev/null +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -0,0 +1,122 @@ +package gregtech.api.metatileentity.implementations; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; +import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Enhanced multiblock base class, featuring following improvement over {@link GT_MetaTileEntity_MultiBlockBase} + *

+ * 1. TecTech style declarative structure check utilizing StructureLib. + * 2. Arbitrarily rotating the whole structure, if allowed to. + * + * @param type of this + */ +public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment { + private ExtendedFacing mExtendedFacing; + private final IAlignmentLimits mLimits; + + protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mLimits = getInitialAlignmentLimits(); + } + + protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) { + super(aName); + mLimits = getInitialAlignmentLimits(); + } + + @Override + public ExtendedFacing getExtendedFacing() { + return mExtendedFacing; + } + + @Override + public void setExtendedFacing(ExtendedFacing newExtendedFacing) { + if (mExtendedFacing != newExtendedFacing) { + stopMachine(); + mExtendedFacing = newExtendedFacing; + IGregTechTileEntity base = getBaseMetaTileEntity(); + mMachine = false; + mUpdate = 100; + if (getBaseMetaTileEntity().isServerSide()) { + StructureLibAPI.sendAlignment((IAlignmentProvider) base, + new NetworkRegistry.TargetPoint(base.getWorld().provider.dimensionId, + base.getXCoord(), base.getYCoord(), base.getZCoord(), 512)); + } else { + base.issueTextureUpdate(); + } + } + } + + @Override + public final boolean isFacingValid(byte aFacing) { + return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); + } + + @Override + public void onFacingChange() { + toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); + } + + @Override + public IAlignmentLimits getAlignmentLimits() { + return mLimits; + } + + public abstract IStructureDefinition getStructureDefinition(); + + protected IAlignmentLimits getInitialAlignmentLimits() { + return UNLIMITED; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("mRotation", (byte) mExtendedFacing.getRotation().getIndex()); + aNBT.setByte("mFlip", (byte) mExtendedFacing.getFlip().getIndex()); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mExtendedFacing = ExtendedFacing.of(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()), + Rotation.byIndex(aNBT.getByte("mRotation")), + Flip.byIndex(aNBT.getByte("mFlip"))); + } + + @Override + public abstract GT_MetaTileEntity_EnhancedMultiBlockBase newMetaEntity(IGregTechTileEntity aTileEntity); + + @SuppressWarnings("unchecked") + private IStructureDefinition> getCastedStructureDefinition() { + return (IStructureDefinition>) getStructureDefinition(); + } + + protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { + IGregTechTileEntity tTile = getBaseMetaTileEntity(); + return getCastedStructureDefinition().check(this, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, !mMachine); + } + + protected final boolean buildPiece(String piece, ItemStack trigger, boolean hintOnly, int horizontalOffset, int verticalOffset, int depthOffset) { + IGregTechTileEntity tTile = getBaseMetaTileEntity(); + return getCastedStructureDefinition().buildOrHints(this, trigger, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, hintOnly); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (aBaseMetaTileEntity.isClientSide()) + StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity); + } +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 0de4dfecbb..3b1a963c9e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -26,6 +26,7 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import java.util.List; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; @@ -676,8 +677,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return false; } - private boolean dumpFluid(FluidStack copiedFluidStack, boolean restrictiveHatchesOnly){ - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + protected static boolean dumpFluid(List aOutputHatches, FluidStack copiedFluidStack, boolean restrictiveHatchesOnly){ + for (GT_MetaTileEntity_Hatch_Output tHatch : aOutputHatches) { if (!isValidMetaTileEntity(tHatch) || (restrictiveHatchesOnly && tHatch.mMode == 0)) { continue; } @@ -709,8 +710,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean addOutput(FluidStack aLiquid) { if (aLiquid == null) return false; FluidStack copiedFluidStack = aLiquid.copy(); - if (!dumpFluid(copiedFluidStack, true)){ - dumpFluid(copiedFluidStack, false); + if (!dumpFluid(mOutputHatches, copiedFluidStack, true)){ + dumpFluid(mOutputHatches, copiedFluidStack, false); } return false; } diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java new file mode 100644 index 0000000000..c8d845ec19 --- /dev/null +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -0,0 +1,71 @@ +package gregtech.api.util; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class GT_StructureUtility { + private GT_StructureUtility() { + throw new AssertionError("Not instantiable"); + } + + public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots) { + return ofHatchAdder(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1); + } + + public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta) { + if (IGT_HatchAdder == null || hintBlock == null) { + throw new IllegalArgumentException(); + } + return new IStructureElementNoPlacement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta); + return true; + } + }; + } + + public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + return ofHatchAdderOptional(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); + } + + public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + if (IGT_HatchAdder == null || hintBlock == null) { + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + Block worldBlock = world.getBlock(x, y, z); + return (tileEntity instanceof IGregTechTileEntity && + IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2); + return true; + } + }; + } +} diff --git a/src/main/java/gregtech/api/util/IGT_HatchAdder.java b/src/main/java/gregtech/api/util/IGT_HatchAdder.java new file mode 100644 index 0000000000..be0194fc65 --- /dev/null +++ b/src/main/java/gregtech/api/util/IGT_HatchAdder.java @@ -0,0 +1,14 @@ +package gregtech.api.util; + + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public interface IGT_HatchAdder { + /** + * Callback to add hatch, needs to check if hatch is valid (and add it) + * @param iGregTechTileEntity hatch + * @param aShort requested texture index, or null if not... + * @return managed to add hatch (structure still valid) + */ + boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort); +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java index 1ac4df6d73..84203ef849 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java @@ -1,16 +1,16 @@ package gregtech.common.tileentities.machines.multi; -import gregtech.api.GregTech_API; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTileEntity_MultiBlockBase { +public abstract class GT_MetaTileEntity_AbstractMultiFurnace> extends GT_MetaTileEntity_EnhancedMultiBlockBase { - private static final int CASING_INDEX = 11; + protected HeatingCoilLevel mCoilLevel; protected GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -25,55 +25,21 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTile return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - protected HeatingCoilLevel getInitialHeatLevel(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { - Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + 1, 1, zDir); - if (!(coil instanceof IHeatingCoil)) - return null; - IHeatingCoil heatingCoil = (IHeatingCoil) coil; - byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); - return heatingCoil.getCoilHeat(tUsedMeta); - } - - protected boolean checkStructure(HeatingCoilLevel heatingCap, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity){ - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (!checkTopLayer(i, j, xDir, zDir, aBaseMetaTileEntity)) - return false; - - if (!checkBottomLayer(i, j, xDir, zDir, aBaseMetaTileEntity)) - return false; - - if (!checkCoils(heatingCap, i, j, xDir, zDir, aBaseMetaTileEntity)) - return false; - } + protected final boolean addCoil(Block aBlock, int aMeta) { + if (aBlock instanceof IHeatingCoil) { + if (mCoilLevel != null) + return mCoilLevel == ((IHeatingCoil) aBlock).getCoilHeat(aMeta); + mCoilLevel = ((IHeatingCoil) aBlock).getCoilHeat(aMeta); + return true; } - return true; + return false; } - protected abstract boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity); - protected abstract boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity); - - protected boolean checkBottomLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity){ - if ((xDir + i == 0) && (zDir + j == 0)) - return true; - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - return true; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - return true; - if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - return true; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - return true; - - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) - return false; - return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) == CASING_INDEX; + protected boolean addBottomHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + return addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex) || + addInputToMachineList(aTileEntity, aBaseCasingIndex) || + addOutputToMachineList(aTileEntity, aBaseCasingIndex) || + addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex); } @Override @@ -95,4 +61,10 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace extends GT_MetaTile public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // even though flipping doesn't really change the overall structure, but maybe someone want it somehow + return (direction, rotation, flip) -> direction.offsetY == 0 && rotation.isNotRotated(); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 5e99491c2e..733710e539 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -1,22 +1,22 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -25,21 +25,36 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; +import java.util.ArrayList; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_AbstractMultiFurnace { +public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_AbstractMultiFurnace implements IConstructable { private int mHeatingCapacity = 0; - private int controllerY; + private final ArrayList mPollutionOutputHatches = new ArrayList<>(); private final FluidStack[] pollutionFluidStacks = {Materials.CarbonDioxide.getGas(1000), Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000)}; private static final int CASING_INDEX = 11; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ttt", "tmt", "ttt"}, + {"CCC", "C-C", "CCC",}, + {"CCC", "C-C", "CCC",}, + {"b~b", "bbb", "bbb"} + })) + .addElement('t', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) + .addElement('m', ofHatchAdder(GT_MetaTileEntity_ElectricBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2)) + .addElement('C', ofBlockAdder(GT_MetaTileEntity_ElectricBlastFurnace::addCoil, GregTech_API.sBlockCasings5, 0)) + .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) + .build(); public GT_MetaTileEntity_ElectricBlastFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -50,7 +65,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + public GT_MetaTileEntity_ElectricBlastFurnace newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_ElectricBlastFurnace(this.mName); } @@ -119,8 +134,8 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; } @Override @@ -225,68 +240,33 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab return timesOverclocked; } - private boolean checkMachineFunction(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - controllerY = aBaseMetaTileEntity.getYCoord(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - this.mHeatingCapacity = 0; - - replaceDeprecatedCoils(aBaseMetaTileEntity); - HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir); - if (heatingCap == null) - return false; - - if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity)) - return false; - - this.mHeatingCapacity = (int) heatingCap.getHeat(); - this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); - return true; - } - - @Override - protected boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) { - if ((i == 0) && (j == 0)) { - return addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), CASING_INDEX); + public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mPollutionOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } - if (addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), CASING_INDEX)) - return true; - - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) - return false; - - return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) == CASING_INDEX; + return false; } @Override - protected boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) { - if ((i == 0) && (j == 0)) { - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) - return false; + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mHeatingCapacity = 0; - return aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir); - } + replaceDeprecatedCoils(aBaseMetaTileEntity); - Block blockLow = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j); - if (!(blockLow instanceof IHeatingCoil)) - return false; + mCoilLevel = null; - Block blockHi = aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j); - if (!(blockHi instanceof IHeatingCoil)) + if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false; - byte metaLow = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j); - HeatingCoilLevel coilHeatLow = ((IHeatingCoil) blockLow).getCoilHeat(metaLow); - byte metaHi = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j); - HeatingCoilLevel coilHeatHi = ((IHeatingCoil) blockHi).getCoilHeat(metaHi); - - return heatingCap == coilHeatLow && heatingCap == coilHeatHi; - } + if (mCoilLevel == null) + return false; - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - return this.checkMachineFunction(aBaseMetaTileEntity, aStack); + this.mHeatingCapacity = (int) mCoilLevel.getHeat() + 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { @@ -326,7 +306,6 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab public boolean addOutput(FluidStack aLiquid) { if (aLiquid == null) return false; - int targetHeight; FluidStack tLiquid = aLiquid.copy(); boolean isOutputPollution = false; for (FluidStack pollutionFluidStack : pollutionFluidStacks) { @@ -336,8 +315,9 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab isOutputPollution = true; break; } + ArrayList tOutputHatches; if (isOutputPollution) { - targetHeight = this.controllerY + 3; + tOutputHatches = this.mPollutionOutputHatches; int pollutionReduction = 0; for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { if (!isValidMetaTileEntity(tHatch)) @@ -347,23 +327,10 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab } tLiquid.amount = tLiquid.amount * (pollutionReduction + 5) / 100; } else { - targetHeight = this.controllerY; + tOutputHatches = this.mOutputHatches; } - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? !tHatch.outputsSteam() : !tHatch.outputsLiquids()) - continue; - - if (tHatch.getBaseMetaTileEntity().getYCoord() != targetHeight) - continue; - - int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) { - return tHatch.fill(tLiquid, true) >= tLiquid.amount; - } else if (tAmount > 0) { - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - } - return false; + return dumpFluid(tOutputHatches, tLiquid, true) || + dumpFluid(tOutputHatches, tLiquid, false); } @Override @@ -401,4 +368,15 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1,3,0); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + // TODO implement me + return new String[0]; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 3bf7dc4cfb..14dfe6f237 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -1,11 +1,10 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; @@ -14,7 +13,6 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -24,18 +22,30 @@ import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; import static gregtech.api.enums.GT_Values.VN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMultiFurnace { +public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMultiFurnace { private int mLevel = 0; private int mCostDiscount = 1; private static final int CASING_INDEX = 11; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, new String[][]{ + {"ccc", "cmc", "ccc"}, + {"CCC", "C-C", "CCC",}, + {"b~b", "bbb", "bbb"} + }) + .addElement('c', ofBlock(GregTech_API.sBlockCasings1, CASING_INDEX)) + .addElement('m', ofHatchAdder(GT_MetaTileEntity_MultiFurnace::addMufflerToMachineList, CASING_INDEX, 2)) + .addElement('C', ofBlockAdder(GT_MetaTileEntity_MultiFurnace::addCoil, GregTech_API.sBlockCasings5, 0)) + .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_MultiFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) + .build(); public GT_MetaTileEntity_MultiFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -46,7 +56,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + public GT_MetaTileEntity_MultiFurnace newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_MultiFurnace(this.mName); } @@ -149,55 +159,29 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu return true; } - private boolean checkMachineFunction(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ this.mLevel = 0; this.mCostDiscount = 1; replaceDeprecatedCoils(aBaseMetaTileEntity); - HeatingCoilLevel heatingCap = getInitialHeatLevel(aBaseMetaTileEntity, xDir, zDir); - if (heatingCap == null) - return false; - - if (!checkStructure(heatingCap, xDir, zDir, aBaseMetaTileEntity)) - return false; - - this.mLevel = heatingCap.getLevel(); - this.mCostDiscount = heatingCap.getCostDiscount(); - return true; - } - @Override - protected boolean checkCoils(HeatingCoilLevel heatingCap, int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) { - if ((i == 0) && (j == 0)) - return aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir); + mCoilLevel = null; - Block coilM = aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j); - if (!(coilM instanceof IHeatingCoil)) + if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false; - byte usedMetaM = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j); - - IHeatingCoil heatingCoilM = (IHeatingCoil) coilM; - HeatingCoilLevel heatingLevelM = heatingCoilM.getCoilHeat(usedMetaM); - return heatingLevelM == heatingCap; - } - - @Override - protected boolean checkTopLayer(int i, int j, int xDir, int zDir, IGregTechTileEntity aBaseMetaTileEntity) { - if ((i == 0) && (j == 0)) { - return addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), CASING_INDEX); - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) + if (mCoilLevel == null) return false; - return aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) == CASING_INDEX; - } - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack){ - return this.checkMachineFunction(aBaseMetaTileEntity,aStack); + this.mLevel = mCoilLevel.getLevel(); + this.mCostDiscount = mCoilLevel.getCostDiscount(); + return true; } private void replaceDeprecatedCoils(IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 1432a19054..0ec17827de 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -16,7 +16,8 @@ "parent": "", "screenshots": [], "dependencies": [ - "Industrialcraft" + "Industrialcraft", + "structurelib" ] } ] -- cgit From cb876c46e9f185b73556c1c8ed7ca2751cac2cdc Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 31 May 2021 01:09:30 +0800 Subject: Implement IConstructable for demo multis --- .../api/metatileentity/BaseMetaTileEntity.java | 2 +- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 35 +++++++++++++++++++++- src/main/java/gregtech/api/util/GT_Utility.java | 15 +++++++++- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 17 ++--------- .../multi/GT_MetaTileEntity_MultiFurnace.java | 17 ++++++----- 5 files changed, 62 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index d108236a39..6eb06d8fae 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -2383,7 +2383,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public void setExtendedFacing(ExtendedFacing alignment) { - setFrontFacing((byte) Math.max(alignment.getDirection().ordinal(), 5)); + setFrontFacing((byte) Math.min(alignment.getDirection().ordinal(), ForgeDirection.UNKNOWN.ordinal() - 1)); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 7d06378ce1..c3d41664b7 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -4,15 +4,21 @@ import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.IAlignment; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.input.Keyboard; + +import java.util.concurrent.atomic.AtomicReferenceArray; /** * Enhanced multiblock base class, featuring following improvement over {@link GT_MetaTileEntity_MultiBlockBase} @@ -22,7 +28,8 @@ import net.minecraftforge.common.util.ForgeDirection; * * @param type of this */ -public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment { +public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment, IConstructable { + private static final AtomicReferenceArray tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length); private ExtendedFacing mExtendedFacing; private final IAlignmentLimits mLimits; @@ -76,6 +83,32 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase getStructureDefinition(); + protected abstract GT_Multiblock_Tooltip_Builder createTooltip(); + + @Override + public String[] getDescription() { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return getTooltip().getStructureInformation(); + } else { + return getTooltip().getInformation(); + } + } + + protected GT_Multiblock_Tooltip_Builder getTooltip() { + int tId = getBaseMetaTileEntity().getMetaTileID(); + GT_Multiblock_Tooltip_Builder tooltip = tooltips.get(tId); + if (tooltip == null) { + tooltip = createTooltip(); + tooltips.set(tId, tooltip); + } + return tooltip; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return getTooltip().getStructureInformation(); + } + protected IAlignmentLimits getInitialAlignmentLimits() { return UNLIMITED; } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 28faeae7e3..c7cee8c9c2 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -3,6 +3,8 @@ package gregtech.api.util; import cofh.api.transport.IItemDuct; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; @@ -1939,7 +1941,7 @@ public class GT_Utility { tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET+ " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " D: " +EnumChatFormatting.AQUA+ aWorld.provider.dimensionId +EnumChatFormatting.RESET+ " -----"); try { - if (tTileEntity != null && tTileEntity instanceof IInventory) + if (tTileEntity instanceof IInventory) tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET); else tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET); @@ -1978,6 +1980,17 @@ public class GT_Utility { } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } + try { + if (tTileEntity instanceof IAlignmentProvider) { + IAlignment tAlignment = ((IAlignmentProvider) tTileEntity).getAlignment(); + if (tAlignment != null) { + rEUAmount += 100; + tList.add(trans("219", "Extended Facing: ") + EnumChatFormatting.GREEN + tAlignment.getExtendedFacing() + EnumChatFormatting.RESET); + } + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } try { if (tTileEntity instanceof ic2.api.tile.IWrenchable) { rEUAmount += 100; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 733710e539..149c7a4172 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -23,7 +23,6 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -70,8 +69,8 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab } @Override - public String[] getDescription() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Blast Furnace") .addInfo("Controller block for the Electric Blast Furnace") .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus") @@ -95,11 +94,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab .addStructureInfo("Recovery amount scales with Muffler Hatch tier") .addOutputHatch("Platline fluids, Any bottom layer casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -373,10 +368,4 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1,3,0); } - - @Override - public String[] getStructureDescription(ItemStack stackSize) { - // TODO implement me - return new String[0]; - } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 14dfe6f237..aae7497f04 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -1,5 +1,6 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; @@ -29,7 +30,7 @@ import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMultiFurnace { +public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMultiFurnace implements IConstructable { private int mLevel = 0; private int mCostDiscount = 1; @@ -61,8 +62,8 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu } @Override - public String[] getDescription() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Furnace") .addInfo("Controller Block for the Multi Smelter") .addInfo("Smelts up to 8-128 items at once") @@ -79,9 +80,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu .addInputBus("Any bottom casing") .addOutputBus("Any bottom casing") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - return tt.getInformation(); - return tt.getStructureInformation(); + return tt; } @Override @@ -173,7 +172,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu mCoilLevel = null; - if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) + if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0)) return false; if (mCoilLevel == null) @@ -238,4 +237,8 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu }; } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 2, 0); + } } -- cgit From 86f69a4300e0bdb5c9921f37c84bb446e464ec78 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Mon, 31 May 2021 10:13:56 +0200 Subject: feat(texture API): integrate ExtendedFacing rotation Add ExtendedFacing rotation to the texture API. Rotatable ExtendedFacing textures can be created with: ```java TextureFactory.builder().addIcon(IICon).extFacing().build(); ``` Improve and unify internal implementation of standard oriented and glow textures. --- src/main/java/gregtech/GT_Mod.java | 3 +- .../gregtech/api/interfaces/ITextureBuilder.java | 8 + .../java/gregtech/api/util/LightingHelper.java | 1 + .../common/render/GT_RenderedGlowTexture.java | 213 ------------ .../gregtech/common/render/GT_RenderedTexture.java | 383 +++++++++++++++------ .../common/render/GT_StdRenderedTexture.java | 36 -- .../gregtech/common/render/GT_TextureBuilder.java | 11 +- 7 files changed, 290 insertions(+), 365 deletions(-) delete mode 100644 src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java delete mode 100644 src/main/java/gregtech/common/render/GT_StdRenderedTexture.java (limited to 'src') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index d9a8d72ecd..278908b9a0 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -1,6 +1,7 @@ package gregtech; import com.google.common.base.Stopwatch; +import com.gtnewhorizon.structurelib.StructureLib; import cpw.mods.fml.common.*; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.EntityRegistry; @@ -74,7 +75,7 @@ import static gregtech.api.enums.GT_Values.MOD_ID_FR; @SuppressWarnings("ALL") @Mod(modid = "gregtech", name = "GregTech", version = "MC1710", useMetadata = false, dependencies = " required-after:IC2;" + - " required-after:structurelib;" + + " required-after:" + StructureLib.MOD_ID + ";" + " after:dreamcraft;" + " after:Forestry;" + " after:PFAAGeologica;" + diff --git a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java index 8a4d715ccb..d72b538243 100644 --- a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java +++ b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java @@ -1,5 +1,6 @@ package gregtech.api.interfaces; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import gregtech.api.render.TextureFactory; import net.minecraft.block.Block; import net.minecraftforge.common.util.ForgeDirection; @@ -63,6 +64,13 @@ public interface ITextureBuilder { */ ITextureBuilder stdOrient(); + /** + * Texture will orientate from block's {@link ExtendedFacing} + * + * @return {@link ITextureBuilder} for chaining + */ + ITextureBuilder extFacing(); + /** * Texture always render with full brightness to glow in the dark * diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index 598253b7d7..f131ef74a0 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -255,6 +255,7 @@ public class LightingHelper { } else { + if (hasBrightnessOverride) tessellator.setBrightness(brightnessOverride); tessellator.setColorOpaque_F(rgb[0] * lightness, rgb[1] * lightness, rgb[2] * lightness); } diff --git a/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java b/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java deleted file mode 100644 index 899e4d7c5d..0000000000 --- a/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java +++ /dev/null @@ -1,213 +0,0 @@ -package gregtech.common.render; - -import gregtech.GT_Mod; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.IColorModulationContainer; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.ITexture; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; - -import static gregtech.api.util.LightingHelper.MAX_BRIGHTNESS; - -/** - * This {@link ITexture} implementation renders texture with max brightness to glow in the dark. - */ - -class GT_RenderedGlowTexture implements ITexture, IColorModulationContainer { - protected final IIconContainer mIconContainer; - private final short[] mRGBa; - - GT_RenderedGlowTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { - if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); - mIconContainer = GT_Mod.gregtechproxy.mRenderGlowTextures ? aIcon : BlockIcons.VOID; - mRGBa = aRGBa; - } - - @Override - public short[] getRGBA() { - return mRGBa; - } - - @Override - public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - final boolean enableAO = aRenderer.enableAO; - aRenderer.enableAO = false; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorOpaque(255, 255, 255); - aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.enableAO = enableAO; - } - - @Override - public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - aRenderer.field_152631_f = true; - final boolean enableAO = aRenderer.enableAO; - aRenderer.enableAO = false; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorOpaque(255, 255, 255); - aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.field_152631_f = false; - aRenderer.enableAO = enableAO; - } - - @Override - public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - final boolean enableAO = aRenderer.enableAO; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); - final Tessellator tessellator = Tessellator.instance; - IIcon aIcon = mIconContainer.getIcon(); - - float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); - float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); - float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - minU = 16.0F - aIcon.getMaxU(); - maxU = 16.0F - aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - minV = aIcon.getMinV(); - maxV = aIcon.getMaxV(); - } - - double minX = aX + aRenderer.renderMinX; - double maxX = aX + aRenderer.renderMaxX; - double minY = aY + aRenderer.renderMinY; - double minZ = aZ + aRenderer.renderMinZ; - double maxZ = aZ + aRenderer.renderMaxZ; - - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); - - if (mIconContainer.getOverlayIcon() != null) { - minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); - maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); - minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - minU = 16.0F - aIcon.getMaxU(); - maxU = 16.0F - aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - minV = aIcon.getMinV(); - maxV = aIcon.getMaxV(); - } - - minX = aX + (float) aRenderer.renderMinX; - maxX = aX + (float) aRenderer.renderMaxX; - minY = aY + (float) aRenderer.renderMinY; - minZ = aZ + (float) aRenderer.renderMinZ; - maxZ = aZ + (float) aRenderer.renderMaxZ; - - Tessellator.instance.setColorOpaque(255, 255, 255); - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.enableAO = enableAO; - } - - @Override - public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - final boolean enableAO = aRenderer.enableAO; - aRenderer.enableAO = false; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorOpaque(255, 255, 255); - aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.enableAO = enableAO; - } - - @Override - public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - final boolean enableAO = aRenderer.enableAO; - aRenderer.enableAO = false; - aRenderer.field_152631_f = true; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorOpaque(255, 255, 255); - aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.field_152631_f = false; - aRenderer.enableAO = enableAO; - } - - @Override - public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API - if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; - final boolean enableAO = aRenderer.enableAO; - aRenderer.enableAO = false; - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); - Tessellator.instance.setBrightness(MAX_BRIGHTNESS); - Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); - aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - aRenderer.enableAO = enableAO; - } - - @Override - public boolean isValidTexture() { - return mIconContainer != null; - } -} diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index 9e76634385..135ebf28c6 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -1,55 +1,92 @@ package gregtech.common.render; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; +import gregtech.GT_Mod; import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.LightingHelper; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IconFlipped; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import static gregtech.api.util.LightingHelper.MAX_BRIGHTNESS; + class GT_RenderedTexture implements ITexture, IColorModulationContainer { protected final IIconContainer mIconContainer; private final short[] mRGBa; + private final boolean glow; + private final boolean stdOrient; + private final boolean useExtFacing; - GT_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { + GT_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha, boolean glow, boolean stdOrient, boolean extFacing) { if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); mIconContainer = aIcon; mRGBa = aRGBa; + this.glow = glow; + this.stdOrient = stdOrient; + this.useExtFacing = extFacing; } @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - aRenderer.field_152631_f = true; // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingXPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.EAST.ordinal(), mRGBa); - aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingXPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.EAST.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); - aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); - aRenderer.field_152631_f = false; } @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingXNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.WEST.ordinal(), mRGBa); - aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingXNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.WEST.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); - aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); } @@ -58,14 +95,24 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingYPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.UP.ordinal(), mRGBa); - aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingYPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.UP.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff); - aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); } @@ -74,96 +121,24 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); - final Tessellator tessellator = Tessellator.instance; - IIcon aIcon = mIconContainer.getIcon(); - - float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); - float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); - float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - minU = 16.0F - aIcon.getMaxU(); - maxU = 16.0F - aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - minV = aIcon.getMinV(); - maxV = aIcon.getMaxV(); - } - - double minX = aX + aRenderer.renderMinX; - double maxX = aX + aRenderer.renderMaxX; - double minY = aY + aRenderer.renderMinY; - double minZ = aZ + aRenderer.renderMinZ; - double maxZ = aZ + aRenderer.renderMaxZ; - + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - } else { - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - } - tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); - + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingYNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { - minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); - maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); - minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - minU = 16.0F - aIcon.getMaxU(); - maxU = 16.0F - aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - minV = aIcon.getMinV(); - maxV = aIcon.getMaxV(); - } - - minX = aX + (float)aRenderer.renderMinX; - maxX = aX + (float)aRenderer.renderMaxX; - minY = aY + (float)aRenderer.renderMinY; - minZ = aZ + (float)aRenderer.renderMinZ; - maxZ = aZ + (float)aRenderer.renderMaxZ; - - lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); - - if (aRenderer.enableAO) { - tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); - tessellator.setBrightness(aRenderer.brightnessTopLeft); - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); - tessellator.setBrightness(aRenderer.brightnessBottomLeft); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); - tessellator.setBrightness(aRenderer.brightnessBottomRight); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); - tessellator.setBrightness(aRenderer.brightnessTopRight); - } else { - tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); - tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); - tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); - } - tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); + Tessellator.instance.setColorRGBA(255, 255, 255, 255); + renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); } @@ -172,14 +147,24 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingZPos(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); - aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingZPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); - aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); } @@ -188,18 +173,26 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { // TODO: Uncomment this once all addons have migrated to the new Texture API //startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); - aRenderer.field_152631_f = true; + final boolean enableAO = aRenderer.enableAO; LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingZNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); - aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (glow) { + if (aRenderer.useInventoryTint) + return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.enableAO = false; + lighting.setLightnessOverride(1.0F); + if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); + } + lighting.setupLightingZNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); + ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); - aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getOverlayIcon(), rotation); } + aRenderer.enableAO = enableAO; // TODO: Uncomment this once all addons have migrated to the new Texture API //draw(aRenderer); - aRenderer.field_152631_f = false; } @Override @@ -211,4 +204,170 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { public boolean isValidTexture() { return mIconContainer != null; } + + /** + * Renders the given texture to the bottom face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceYNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateBottom = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateBottom = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateBottom = 3; + break; + default: + aRenderer.uvRotateBottom = 0; + break; + } + + aRenderer.renderFaceYNeg(Blocks.air, x, y, z, new IconFlipped(icon, !stdOrient, false)); + aRenderer.uvRotateBottom = 0; + } + + /** + * Renders the given texture to the top face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceYPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateTop = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateTop = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateTop = 3; + break; + default: + aRenderer.uvRotateTop = 0; + break; + } + + aRenderer.renderFaceYPos(Blocks.air, x, y, z, icon); + aRenderer.uvRotateTop = 0; + } + + /** + * Renders the given texture to the north (z-negative) face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceZNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + aRenderer.field_152631_f = true; + // **NOT A BUG**: aRenderer.uvRotateEast REALLY CONTROLS THE ROTATION OF THE NORTH SIDE + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateEast = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateEast = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateEast = 3; + break; + default: + aRenderer.uvRotateEast = 0; + break; + } + + aRenderer.renderFaceZNeg(Blocks.air, x, y, z, icon); + aRenderer.uvRotateEast = 0; + aRenderer.field_152631_f = false; + } + + /** + * Renders the given texture to the south (z-positive) face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceZPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + // **NOT A BUG**: aRenderer.uvRotateWest REALLY CONTROLS THE ROTATION OF THE SOUTH SIDE + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateWest = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateWest = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateWest = 3; + break; + default: + aRenderer.uvRotateWest = 0; + break; + } + + aRenderer.renderFaceZPos(Blocks.air, x, y, z, icon); + aRenderer.uvRotateWest = 0; + } + + /** + * Renders the given texture to the west (x-negative) face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceXNeg(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + // **NOT A BUG**: aRenderer.uvRotateNorth REALLY CONTROLS THE ROTATION OF THE WEST SIDE + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateNorth = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateNorth = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateNorth = 3; + break; + default: + aRenderer.uvRotateNorth = 0; + break; + } + + aRenderer.renderFaceXNeg(Blocks.air, x, y, z, icon); + aRenderer.uvRotateNorth = 0; + } + + /** + * Renders the given texture to the east (x-positive) face of the block. Args: block, x, y, z, texture + */ + protected void renderFaceXPos(RenderBlocks aRenderer, double x, double y, double z, IIcon icon, ExtendedFacing extendedFacing) { + aRenderer.field_152631_f = true; + // **NOT A BUG**: aRenderer.uvRotateSouth REALLY CONTROLS THE ROTATION OF THE EAST SIDE + switch (useExtFacing ? extendedFacing.getRotation() : Rotation.NORMAL) { + case COUNTER_CLOCKWISE: + aRenderer.uvRotateSouth = 2; + break; + case CLOCKWISE: + aRenderer.uvRotateSouth = 1; + break; + case UPSIDE_DOWN: + aRenderer.uvRotateSouth = 3; + break; + default: + aRenderer.uvRotateSouth = 0; + break; + } + + aRenderer.renderFaceXPos(Blocks.air, x, y, z, icon); + aRenderer.uvRotateSouth = 0; + aRenderer.field_152631_f = false; + } + + private ExtendedFacing getExtendedFacing(int x, int y, int z) { + if (stdOrient) return ExtendedFacing.DEFAULT; + World w = Minecraft.getMinecraft().theWorld; + if (w == null) return ExtendedFacing.DEFAULT; + TileEntity te = w.getTileEntity(x, y, z); + if (te instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (meta instanceof IAlignmentProvider) { + return ((IAlignmentProvider) meta).getAlignment().getExtendedFacing(); + } else if (meta != null) { + return ExtendedFacing.of(ForgeDirection.getOrientation(meta.getBaseMetaTileEntity().getFrontFacing())); + } + } else if (te instanceof IAlignmentProvider) { + return ((IAlignmentProvider) te).getAlignment().getExtendedFacing(); + } + return ExtendedFacing.DEFAULT; + } } diff --git a/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java b/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java deleted file mode 100644 index ba0f9d3a91..0000000000 --- a/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.common.render; - -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.util.LightingHelper; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * This ITexture implementation extends the GT_RenderedTexture class - * to render with bottom side flipped as with dumb blocks rendering. - * It is used in Ore blocks rendering so they better blends with dumb block ores - * from vanilla or other mods, when seen from bottom. - */ -class GT_StdRenderedTexture extends GT_RenderedTexture{ - - GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { - super(aIcon, aRGBa, allowAlpha); - } - - @Override - public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - // TODO: Uncomment this once all addons have migrated to the new Texture API - //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); - LightingHelper lighting = new LightingHelper(aRenderer); - lighting.setupLightingYNeg(aBlock, aX, aY, aZ) - .setupColor(ForgeDirection.DOWN.ordinal(), getRGBA()); - aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); - if (mIconContainer.getOverlayIcon() != null) { - lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); - aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); - } - // TODO: Uncomment this once all addons have migrated to the new Texture API - //draw(aRenderer); - } -} diff --git a/src/main/java/gregtech/common/render/GT_TextureBuilder.java b/src/main/java/gregtech/common/render/GT_TextureBuilder.java index 22446f99a5..82bce4c8c4 100644 --- a/src/main/java/gregtech/common/render/GT_TextureBuilder.java +++ b/src/main/java/gregtech/common/render/GT_TextureBuilder.java @@ -21,6 +21,7 @@ public class GT_TextureBuilder implements ITextureBuilder { private short[] rgba; private boolean allowAlpha; private boolean stdOrient; + private boolean extFacing; private boolean glow; public GT_TextureBuilder() { @@ -76,6 +77,12 @@ public class GT_TextureBuilder implements ITextureBuilder { return this; } + @Override + public ITextureBuilder extFacing() { + this.extFacing = true; + return this; + } + @Override public ITextureBuilder glow() { glow = true; @@ -88,9 +95,7 @@ public class GT_TextureBuilder implements ITextureBuilder { if (!textureLayers.isEmpty()) return new GT_MultiTexture(textureLayers.toArray(new ITexture[0])); switch (iconContainerList.size()) { case 1: - if (stdOrient) return new GT_StdRenderedTexture(iconContainerList.get(0), rgba, allowAlpha); - if (glow) return new GT_RenderedGlowTexture(iconContainerList.get(0), rgba, allowAlpha); - return new GT_RenderedTexture(iconContainerList.get(0), rgba, allowAlpha); + return new GT_RenderedTexture(iconContainerList.get(0), rgba, allowAlpha, glow, stdOrient, extFacing); case 6: return new GT_SidedTexture( iconContainerList.get(ForgeDirection.DOWN.ordinal()), -- cgit From c1146c404994ee80c5b1d282bd0f03d3532bedca Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 31 May 2021 14:17:29 +0800 Subject: Turn off EBF rotation limit --- .../machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java index 84203ef849..ad49c72313 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.multi; -import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -61,10 +60,4 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace direction.offsetY == 0 && rotation.isNotRotated(); - } } -- cgit From f812b4a50c922290d6cdee4d1e5e20530814abdc Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 31 May 2021 22:59:51 +0800 Subject: Add GT_MetaTileEntity_CubicMultiBlockBase and a few minor changes 1. add ofCoil() IStructureElement to standardise how to add a homogeneous set of coils to the structure definition 2. Changed newMetaEntity's return type back to IMetaTileEntity to prevent addons crying out 3. Initialize mExtendedFacing to ensure rendering code don't step on null --- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 111 +++++++++++++++++++++ .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 9 +- .../gregtech/api/util/GT_StructureUtility.java | 73 ++++++++++++++ .../java/gregtech/api/util/IGT_HatchAdder.java | 5 +- .../GT_MetaTileEntity_AbstractMultiFurnace.java | 22 ++-- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 18 ++-- .../GT_MetaTileEntity_ImplosionCompressor.java | 60 ++++------- .../multi/GT_MetaTileEntity_MultiFurnace.java | 19 ++-- .../multi/GT_MetaTileEntity_ProcessingArray.java | 59 ++++------- .../multi/GT_MetaTileEntity_VacuumFreezer.java | 85 ++++++---------- 10 files changed, 288 insertions(+), 173 deletions(-) create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java new file mode 100644 index 0000000000..ef53c1bca2 --- /dev/null +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -0,0 +1,111 @@ +package gregtech.api.metatileentity.implementations; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.item.ItemStack; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +/** + * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere. + * Controller will be placed in front center of the structure. + *

+ * Note: You cannot use different casing for the same Class. Make a new subclass for it. + *

+ * Implementation tips: + * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole + * {@link #getStructureDefinition()} or change {@link #checkHatches(IGregTechTileEntity, ItemStack)}. The former is a total overkill, while the later cannot + * stop the structure check early. + * 2. To limit rotation, override {@link #getInitialAlignmentLimits()} + * + * @param + */ +public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase { + protected static final String STRUCTURE_PIECE_MAIN = "main"; + private static final ConcurrentMap> STRUCTURE_DEFINITIONS = new ConcurrentHashMap<>(); + private int mCasingAmount = 0; + + protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + protected GT_MetaTileEntity_CubicMultiBlockBase(String aName) { + super(aName); + } + + + private static IStructureDefinition> createStructure(GT_MetaTileEntity_CubicMultiBlockBase aTile) { + return StructureDefinition.>builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"hhh", "hhh", "hhh"}, + {"h-h", "hhh", "hhh"}, + {"hhh", "hhh", "hhh"}, + })) + .addElement('h', ofChain( + ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, aTile.getHatchTextureIndex(), 1), + onElementPass( + GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, + aTile.getCasingElement() + ) + )) + .build(); + } + + /** + * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere. + *

+ * The created definition contains a single piece named {@link #STRUCTURE_PIECE_MAIN}. + */ + @Override + @SuppressWarnings("unchecked") + public IStructureDefinition getStructureDefinition() { + return (IStructureDefinition) STRUCTURE_DEFINITIONS.computeIfAbsent(getBaseMetaTileEntity().getMetaTileID(), o -> createStructure(this)); + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasingAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && + mCasingAmount > getRequiredCasingCount() && + checkHatches(aBaseMetaTileEntity, aStack); + } + + /** + * Called by {@link #checkMachine(IGregTechTileEntity, ItemStack)} to check if all required hatches are present. + *

+ * Default implementation requires EXACTLY ONE maintenance hatch to be present, and ignore all other conditions. + * + * @param aBaseMetaTileEntity the tile entity of self + * @param aStack The item stack inside the controller + * @return true if the test passes, false otherwise + */ + protected boolean checkHatches(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return mMaintenanceHatches.size() == 1; + } + + protected abstract IStructureElement> getCasingElement(); + + /** + * The hatch's texture index. + */ + protected abstract int getHatchTextureIndex(); + + protected abstract int getRequiredCasingCount(); + + protected void onCorrectCasingAdded() { + mCasingAmount++; + } +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index c3d41664b7..89d2ce765e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -30,17 +30,15 @@ import java.util.concurrent.atomic.AtomicReferenceArray; */ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment, IConstructable { private static final AtomicReferenceArray tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length); - private ExtendedFacing mExtendedFacing; - private final IAlignmentLimits mLimits; + private ExtendedFacing mExtendedFacing = ExtendedFacing.DEFAULT; + private final IAlignmentLimits mLimits = getInitialAlignmentLimits(); protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - mLimits = getInitialAlignmentLimits(); } protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) { super(aName); - mLimits = getInitialAlignmentLimits(); } @Override @@ -128,9 +126,6 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase newMetaEntity(IGregTechTileEntity aTileEntity); - @SuppressWarnings("unchecked") private IStructureDefinition> getCastedStructureDefinition() { return (IStructureDefinition>) getStructureDefinition(); diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index c8d845ec19..1db672245c 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -3,13 +3,24 @@ package gregtech.api.util; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; +import java.util.function.Function; + +import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11; + public class GT_StructureUtility { + public static final int HINT_COIL_DEFAULT_DOTS = HINT_BLOCK_META_GENERIC_11; + private GT_StructureUtility() { throw new AssertionError("Not instantiable"); } @@ -68,4 +79,66 @@ public class GT_StructureUtility { } }; } + + /** + * Assume a default of LV coil. Assume all coils accepted. Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots. + * @see #ofCoil(BiPredicate, Function, int, Block, int) + */ + public static IStructureElement ofCoil(BiConsumer heatingCoilSetter, Function heatingCoilGetter) { + return ofCoil((t, l) -> { + heatingCoilSetter.accept(t, l); + return true; + }, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, GregTech_API.sBlockCasings5, 0); + } + + /** + * Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots + * @see #ofCoil(BiPredicate, Function, int, Block, int) + */ + public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, Block defaultCoil, int defaultMeta) { + return ofCoil(heatingCoilSetter, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, defaultCoil, defaultMeta); + } + + /** + * Heating coil structure element. + * @param heatingCoilSetter Notify the controller of this new coil. + * Got called exactly once per coil. + * Might be called less times if structure test fails. + * If the setter returns false then it assumes the coil is rejected. + * @param heatingCoilGetter Get the current heating level. Null means no coil recorded yet. + * @param dots The hinting dots + * @param defaultCoil The block to place when auto constructing + * @param defaultMeta The block meta to place when auto constructing + */ + public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, int dots, Block defaultCoil, int defaultMeta) { + if (heatingCoilSetter == null || heatingCoilGetter == null) { + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + if (!(block instanceof IHeatingCoil)) + return false; + HeatingCoilLevel existingLevel = heatingCoilGetter.apply(t), + newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); + if (existingLevel == null) { + return heatingCoilSetter.test(t, newLevel); + } else { + return newLevel == existingLevel; + } + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), dots); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, defaultCoil, defaultMeta, 3); + } + }; + } } diff --git a/src/main/java/gregtech/api/util/IGT_HatchAdder.java b/src/main/java/gregtech/api/util/IGT_HatchAdder.java index be0194fc65..362fddaf1f 100644 --- a/src/main/java/gregtech/api/util/IGT_HatchAdder.java +++ b/src/main/java/gregtech/api/util/IGT_HatchAdder.java @@ -6,9 +6,10 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public interface IGT_HatchAdder { /** * Callback to add hatch, needs to check if hatch is valid (and add it) + * * @param iGregTechTileEntity hatch - * @param aShort requested texture index, or null if not... + * @param aShort requested texture index, or null if not... * @return managed to add hatch (structure still valid) */ - boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort); + boolean apply(T t, IGregTechTileEntity iGregTechTileEntity, Short aShort); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java index ad49c72313..2409c1660c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java @@ -1,15 +1,13 @@ package gregtech.common.tileentities.machines.multi; import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; public abstract class GT_MetaTileEntity_AbstractMultiFurnace> extends GT_MetaTileEntity_EnhancedMultiBlockBase { - protected HeatingCoilLevel mCoilLevel; + private HeatingCoilLevel mCoilLevel; protected GT_MetaTileEntity_AbstractMultiFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -24,16 +22,6 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace { public GT_MetaTileEntity_ImplosionCompressor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Mul } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Implosion Compressor") .addInfo("Explosions are fun") @@ -57,11 +57,7 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Mul .addInputBus("Any casing") .addOutputBus("Any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -94,11 +90,6 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Mul return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredInputs(); @@ -147,31 +138,18 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Mul } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addMufflerToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16)) && (!addOutputToMachineList(tTileEntity, 16)) && (!addEnergyInputToMachineList(tTileEntity, 16))) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (((tBlock != GregTech_API.sBlockCasings2) || (tMeta != 0)) && ((tBlock != GregTech_API.sBlockCasings3) || (tMeta != 4))) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + protected IStructureElement> getCasingElement() { + return ofChain(ofBlock(GregTech_API.sBlockCasings2, 0), ofBlock(GregTech_API.sBlockCasings3, 4)); + } + + @Override + protected int getHatchTextureIndex() { + return 17; + } + + @Override + protected int getRequiredCasingCount() { + return 16; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index aae7497f04..96bc87ff74 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -13,20 +13,23 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_StructureUtility; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; import static gregtech.api.enums.GT_Values.VN; -import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; @@ -44,7 +47,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu }) .addElement('c', ofBlock(GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_MetaTileEntity_MultiFurnace::addMufflerToMachineList, CASING_INDEX, 2)) - .addElement('C', ofBlockAdder(GT_MetaTileEntity_MultiFurnace::addCoil, GregTech_API.sBlockCasings5, 0)) + .addElement('C', GT_StructureUtility.ofCoil(GT_MetaTileEntity_MultiFurnace::setCoilLevel, GT_MetaTileEntity_MultiFurnace::getCoilLevel)) .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_MultiFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) .build(); @@ -170,16 +173,16 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu replaceDeprecatedCoils(aBaseMetaTileEntity); - mCoilLevel = null; + setCoilLevel(null); if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0)) return false; - if (mCoilLevel == null) + if (getCoilLevel() == null) return false; - this.mLevel = mCoilLevel.getLevel(); - this.mCostDiscount = mCoilLevel.getCostDiscount(); + this.mLevel = getCoilLevel().getLevel(); + this.mCostDiscount = getCoilLevel().getCostDiscount(); return true; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index 684cead86c..cf29f13b9b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -1,5 +1,6 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureElement; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -9,9 +10,9 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_CubicMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_ProcessingArray_Manager; @@ -24,16 +25,15 @@ 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.FluidStack; import org.apache.commons.lang3.ArrayUtils; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE; @@ -41,7 +41,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_AR import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_GLOW; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.isValidForLowGravity; -public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMultiBlockBase { private GT_Recipe mLastRecipe; private int tTier = 0; @@ -62,7 +62,7 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Processing Array") .addInfo("Runs supplied machines as if placed in the world") @@ -83,11 +83,7 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl .addOutputBus("Any casing") .addOutputHatch("Any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -146,11 +142,6 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl return aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.basicmachine."); } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - private String mMachine = ""; @Override @@ -328,32 +319,18 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 48)) && (!addInputToMachineList(tTileEntity, 48)) && (!addOutputToMachineList(tTileEntity, 48)) && (!addEnergyInputToMachineList(tTileEntity, 48))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings4) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 14; + protected IStructureElement> getCasingElement() { + return ofBlock(GregTech_API.sBlockCasings4, 0); + } + + @Override + protected int getHatchTextureIndex() { + return 48; + } + + @Override + protected int getRequiredCasingCount() { + return 14; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java index c800592d0d..0050799ea2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -1,19 +1,19 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureUtility; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_CubicMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -23,7 +23,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZE import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; -public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMultiBlockBase { public GT_MetaTileEntity_VacuumFreezer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -38,25 +38,21 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_MultiBloc } @Override - public String[] getDescription() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Vacuum Freezer") - .addInfo("Controller Block for the Vacuum Freezer") - .addInfo("Cools hot ingots and cells") - .addSeparator() - .beginStructureBlock(3, 3, 3, true) - .addController("Front center") - .addCasingInfo("Frost Proof Machine Casing", 16) - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputBus("Any casing") - .addOutputBus("Any casing") - .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Vacuum Freezer") + .addInfo("Controller Block for the Vacuum Freezer") + .addInfo("Cools hot ingots and cells") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Frost Proof Machine Casing", 16) + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputBus("Any casing") + .addOutputBus("Any casing") + .toolTipFinisher("Gregtech"); + return tt; } @Override @@ -95,11 +91,6 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_MultiBloc return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredInputs(); @@ -131,32 +122,18 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_MultiBloc } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + protected IStructureElement> getCasingElement() { + return StructureUtility.ofBlock(GregTech_API.sBlockCasings2, 1); + } + + @Override + protected int getHatchTextureIndex() { + return 17; + } + + @Override + protected int getRequiredCasingCount() { + return 16; } @Override -- cgit From 00b66349dd83b36406c794e5110b01a937e418c6 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 31 May 2021 23:37:03 +0800 Subject: render rotated controllers front face --- .../multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 8 ++++---- .../multi/GT_MetaTileEntity_ImplosionCompressor.java | 8 ++++---- .../machines/multi/GT_MetaTileEntity_MultiFurnace.java | 13 +++++++------ .../machines/multi/GT_MetaTileEntity_ProcessingArray.java | 8 ++++---- .../machines/multi/GT_MetaTileEntity_VacuumFreezer.java | 8 ++++---- 5 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 21b06bc749..b7f09203e0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -107,12 +107,12 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab if (aActive) return new ITexture[]{ casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index 0ea6faef89..41b40f56fa 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -65,12 +65,12 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Cub if (aSide == aFacing) { if (aActive) return new ITexture[]{ BlockIcons.casingTexturePages[0][16], - TextureFactory.of(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.casingTexturePages[0][16], - TextureFactory.of(OVERLAY_FRONT_IMPLOSION_COMPRESSOR), - TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16]}; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 96bc87ff74..34d10a06c6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -24,6 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE; @@ -40,11 +41,11 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu private static final int CASING_INDEX = 11; private static final String STRUCTURE_PIECE_MAIN = "main"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, new String[][]{ + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ {"ccc", "cmc", "ccc"}, {"CCC", "C-C", "CCC",}, {"b~b", "bbb", "bbb"} - }) + })) .addElement('c', ofBlock(GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_MetaTileEntity_MultiFurnace::addMufflerToMachineList, CASING_INDEX, 2)) .addElement('C', GT_StructureUtility.ofCoil(GT_MetaTileEntity_MultiFurnace::setCoilLevel, GT_MetaTileEntity_MultiFurnace::getCoilLevel)) @@ -91,12 +92,12 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu if (aSide != aFacing) return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; if (aActive) return new ITexture[]{ casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_MULTI_SMELTER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_MULTI_SMELTER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_MULTI_SMELTER_GLOW).extFacing().glow().build()}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index cf29f13b9b..0a46c47f7c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -91,12 +91,12 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu if (aSide == aFacing) { if (aActive) return new ITexture[]{ BlockIcons.casingTexturePages[0][48], - TextureFactory.of(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.casingTexturePages[0][48], - TextureFactory.of(OVERLAY_FRONT_PROCESSING_ARRAY), - TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_PROCESSING_ARRAY_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][48]}; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java index 0050799ea2..bef433e626 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -62,13 +62,13 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMult if (aActive) { rTexture = new ITexture[]{ casingTexturePages[0][17], - TextureFactory.of(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW).extFacing().glow().build()}; } else { rTexture = new ITexture[]{ casingTexturePages[0][17], - TextureFactory.of(OVERLAY_FRONT_VACUUM_FREEZER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_VACUUM_FREEZER_GLOW).extFacing().glow().build()}; } } else { rTexture = new ITexture[]{casingTexturePages[0][17]}; -- cgit From deb8c246fb86ba1829eb6d02c2f98cdf92fe4b7e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 31 May 2021 23:49:54 +0800 Subject: unbreak newMetaEntity --- .../tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 34d10a06c6..58d9a24f80 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -6,6 +6,7 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; @@ -61,7 +62,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu } @Override - public GT_MetaTileEntity_MultiFurnace newMetaEntity(IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_MultiFurnace(this.mName); } -- cgit From d736caaf43e43c2bd250f1b5d9a91c8dd06a6147 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 8 Jun 2021 06:31:42 +0800 Subject: allow gt wrench to rotate the front of controller also cleaned up GT_Client.java a little bit. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 13 + src/main/java/gregtech/common/GT_Client.java | 475 +++++++++++---------- 2 files changed, 251 insertions(+), 237 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 89d2ce765e..d925cc1d84 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -13,6 +13,7 @@ import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -69,6 +70,18 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase ROTATABLE_VANILLA_BLOCKS; + + private static final int[][] GRID_SWITCH_ARR = new int[][]{ + {0, 5, 3, 1, 2, 4}, + {5, 0, 1, 3, 2, 4}, + {1, 3, 0, 5, 2, 4}, + {3, 1, 5, 0, 2, 4}, + {4, 2, 3, 1, 0, 5}, + {2, 4, 3, 1, 5, 0}, + }; + + public static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES = { + new Scale(0.25).with(new Translation(0, 0, 0.375)), + new Scale(0.25).with(new Translation(0.375, 0, 0)), + new Scale(0.25).with(new Translation(0, 0, -0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, 0)), + }; + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_CORNER = { + new Scale(0.25).with(new Translation(0.375, 0, 0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, 0.375)), + new Scale(0.25).with(new Translation(0.375, 0, -0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, -0.375)), + }; static { - ROTATABLE_VANILLA_BLOCKS = Arrays.asList(new Block[]{ - Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, - Blocks.pumpkin, Blocks.lit_pumpkin - }); + ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, + Blocks.pumpkin, Blocks.lit_pumpkin); } private final HashSet mCapeList = new HashSet<>(); public static final GT_PollutionRenderer mPollutionRenderer = new GT_PollutionRenderer(); private final GT_CapeRenderer mCapeRenderer; - private final List mPosR; - private final List mPosG; - private final List mPosB; - private final List mPosA = Arrays.asList(new Object[0]); - private final List mNegR; - private final List mNegG; - private final List mNegB; - private final List mNegA = Arrays.asList(new Object[0]); - private final List mMoltenPosR; - private final List mMoltenPosG; - private final List mMoltenPosB; - private final List mMoltenPosA = Arrays.asList(new Object[0]); - private final List mMoltenNegR; - private final List mMoltenNegG; - private final List mMoltenNegB; - private final List mMoltenNegA = Arrays.asList(new Object[0]); + private final List mPosR; + private final List mPosG; + private final List mPosB; + private final List mPosA = Collections.emptyList(); + private final List mNegR; + private final List mNegG; + private final List mNegB; + private final List mNegA = Collections.emptyList(); + private final List mMoltenPosR; + private final List mMoltenPosG; + private final List mMoltenPosB; + private final List mMoltenPosA = Collections.emptyList(); + private final List mMoltenNegR; + private final List mMoltenNegG; + private final List mMoltenNegB; + private final List mMoltenNegA = Collections.emptyList(); private long mAnimationTick; - /**This is the place to def the value used below**/ + /** + * This is the place to def the value used below + **/ private long afterSomeTime; private boolean mAnimationDirection; private int mLastUpdatedBlockX; @@ -92,57 +124,34 @@ public class GT_Client extends GT_Proxy private GT_ClientPreference mPreference; private boolean mFirstTick = false; public GT_Client() { - mCapeRenderer = new GT_CapeRenderer(mCapeList); + mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; mAnimationDirection = false; isFirstClientPlayerTick = true; mMessage = ""; - mPosR = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone - }); - mPosG = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth - }); - mPosB = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, - Materials.InfusedWater, Materials.Thaumium - }); - mNegR = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mNegG = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mNegB = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mMoltenPosR = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone - }); - mMoltenPosG = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth - }); - mMoltenPosB = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, - Materials.InfusedWater, Materials.Thaumium - }); - mMoltenNegR = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); - mMoltenNegG = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); - mMoltenNegB = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); + mPosR = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); + mPosG = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth); + mPosB = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, + Materials.InfusedWater, Materials.Thaumium); + mNegR = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mNegG = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mNegB = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mMoltenPosR = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); + mMoltenPosG = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth); + mMoltenPosB = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, + Materials.InfusedWater, Materials.Thaumium); + mMoltenNegR = Collections.singletonList(Materials.InfusedEntropy); + mMoltenNegG = Collections.singletonList(Materials.InfusedEntropy); + mMoltenNegB = Collections.singletonList(Materials.InfusedEntropy); } private static boolean checkedForChicken = false; + private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverConnections) { if (!checkedForChicken) { try { @@ -159,11 +168,13 @@ public class GT_Client extends GT_Proxy GL11.glPushMatrix(); GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); - Rotation.sideRotations[aEvent.target.sideHit].glApply(); + int tSideHit = aEvent.target.sideHit; + Rotation.sideRotations[tSideHit].glApply(); + // draw grid GL11.glTranslated(0.0D, -0.501D, 0.0D); GL11.glLineWidth(2.0F); GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); - GL11.glBegin(1); + GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(+.50D, .0D, -.25D); GL11.glVertex3d(-.50D, .0D, -.25D); GL11.glVertex3d(+.50D, .0D, +.25D); @@ -174,88 +185,118 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(-.25D, .0D, +.50D); TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + // draw turning indicator + if (tTile instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { + IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); + if (tAlignment != null) { + ForgeDirection direction = tAlignment.getDirection(); + + GL11.glEnd(); + if (direction.ordinal() == tSideHit) + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + else if (direction.getOpposite().ordinal() == tSideHit) { + for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { + drawRotationMarker(t); + } + } else { + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES[Rotation.rotationTo(direction.ordinal(), tSideHit)]); + } + // resume glBegin + GL11.glBegin(GL11.GL_LINES); + } + } + + // draw connection indicators byte tConnections = 0; - if (tTile instanceof ICoverable){ + if (tTile instanceof ICoverable) { if (showCoverConnections) { for (byte i = 0; i < 6; i++) { - if ( ((ICoverable) tTile).getCoverIDAtSide(i) > 0) - tConnections = (byte)(tConnections + (1 << i)); + if (((ICoverable) tTile).getCoverIDAtSide(i) > 0) + tConnections = (byte) (tConnections + (1 << i)); } - } - else if (tTile instanceof BaseMetaPipeEntity) + } else if (tTile instanceof BaseMetaPipeEntity) tConnections = ((BaseMetaPipeEntity) tTile).mConnections; } if (tConnections>0) { - int[][] GridSwitchArr = new int[][]{ - {0, 5, 3, 1, 2, 4}, - {5, 0, 1, 3, 2, 4}, - {1, 3, 0, 5, 2, 4}, - {3, 1, 5, 0, 2, 4}, - {4, 2, 3, 1, 0, 5}, - {2, 4, 3, 1, 5, 0}, - }; - for (byte i = 0; i < 6; i++) { - if ((tConnections & (1 << i)) != 0) { - switch (GridSwitchArr[aEvent.target.sideHit][i]) { - case 0: - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, -.25D); - break; - case 1: - GL11.glVertex3d(-.25D, .0D, +.50D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, +.50D); - break; - case 2: - GL11.glVertex3d(-.50D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(-.50D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - break; - case 3: - GL11.glVertex3d(-.25D, .0D, -.50D); - GL11.glVertex3d(+.25D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, -.50D); - break; - case 4: - GL11.glVertex3d(+.50D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(+.50D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, -.25D); - break; - case 5: - GL11.glVertex3d(+.50D, .0D, +.50D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(+.50D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, +.50D); - GL11.glVertex3d(+.50D, .0D, -.50D); - GL11.glVertex3d(+.25D, .0D, -.25D); - GL11.glVertex3d(+.50D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, -.50D); - GL11.glVertex3d(-.50D, .0D, +.50D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(-.50D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, +.50D); - GL11.glVertex3d(-.50D, .0D, -.50D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(-.50D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, -.50D); - break; - } - } - } + for (byte i = 0; i < 6; i++) { + if ((tConnections & (1 << i)) != 0) { + switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { + case 0: + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, -.25D); + break; + case 1: + GL11.glVertex3d(-.25D, .0D, +.50D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, +.50D); + break; + case 2: + GL11.glVertex3d(-.50D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(-.50D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + break; + case 3: + GL11.glVertex3d(-.25D, .0D, -.50D); + GL11.glVertex3d(+.25D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, -.50D); + break; + case 4: + GL11.glVertex3d(+.50D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(+.50D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, -.25D); + break; + case 5: + GL11.glVertex3d(+.50D, .0D, +.50D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(+.50D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, +.50D); + GL11.glVertex3d(+.50D, .0D, -.50D); + GL11.glVertex3d(+.25D, .0D, -.25D); + GL11.glVertex3d(+.50D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, -.50D); + GL11.glVertex3d(-.50D, .0D, +.50D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(-.50D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, +.50D); + GL11.glVertex3d(-.50D, .0D, -.50D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(-.50D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, -.50D); + break; + } + } + } } GL11.glEnd(); GL11.glPopMatrix(); } - private static void drawGrid(DrawBlockHighlightEvent aEvent) { - drawGrid(aEvent, false); + private static void drawRotationMarker(Transformation transform) { + GL11.glPushMatrix(); + transform.glApply(); + Tessellator t = Tessellator.instance; + t.startDrawing(GL11.GL_LINE_LOOP); + t.addVertex(-0.4d, 0d, -0.4d); + t.addVertex(-0.4d, 0d, 0.4d); + t.addVertex(0.4d, 0d, 0.4d); + t.addVertex(0.4d, 0d, -0.325d); + t.addVertex(0.45d, 0d, -0.325d); + t.addVertex(0.35d, 0d, -0.425d); + t.addVertex(0.25d, 0d, -0.325d); + t.addVertex(0.3d, 0d, -0.325d); + t.addVertex(0.3d, 0d, 0.3d); + t.addVertex(-0.3d, 0d, 0.3d); + t.addVertex(-0.3d, 0d, -0.4d); + t.draw(); + GL11.glPopMatrix(); } @Override @@ -286,7 +327,7 @@ public class GT_Client extends GT_Proxy @Override public void onPreLoad() { super.onPreLoad(); - String arr$[] = { + String[] arr = { "renadi", "hanakocz", "MysteryDump", "Flaver4", "x_Fame", "Peluche321", "Goshen_Ithilien", "manf", "Bimgo", "leagris", "IAmMinecrafter02", "Cerous", "Devilin_Pixy", "Bkarlsson87", "BadAlchemy", "CaballoCraft", "melanclock", "Resursator", "demanzke", "AndrewAmmerlaan", "Deathlycraft", "Jirajha", "Axlegear", "kei_kouma", "Dracion", "dungi", "Dorfschwein", "Zero Tw0", "mattiagraz85", "sebastiank30", @@ -301,12 +342,10 @@ public class GT_Client extends GT_Proxy "25FiveDetail", "AntiCivilBoy", "michaelbrady", "xXxIceFirexXx", "Speedynutty68", "GarretSidzaka", "HallowCharm977", "mastermind1919", "The_Hypersonic", "diamondguy2798", "zF4ll3nPr3d4t0r", "CrafterOfMines57", "XxELIT3xSNIP3RxX", "SuterusuKusanagi", "xavier0014", "adamros", "alexbegt" }; - int len$ = arr$.length; - for (int i$ = 0; i$ < len$; i$++) { - String tName = arr$[i$]; + for (String tName : arr) { mCapeList.add(tName.toLowerCase()); } - (new Thread(this)).start(); + new Thread(this).start(); mPollutionRenderer.preLoad(); @@ -356,47 +395,29 @@ public class GT_Client extends GT_Proxy @Override public void run() { - try { - GT_Log.out.println("GT_Mod: Downloading Cape List."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt").openStream()); + GT_Log.out.println("GT_Mod: Downloading Cape List."); + try (Scanner tScanner = new Scanner(new URL(GT_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine(); - if (!this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } + this.mCapeList.add(tScanner.nextLine().toLowerCase()); } } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - try { - GT_Log.out.println("GT New Horizons: Downloading Cape List."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("https://raw.githubusercontent.com/GTNewHorizons/CustomGTCapeHook-Cape-List/master/capes.txt").openStream()); - while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine(); - if (tName.contains(":")) { - int splitLocation = tName.indexOf(":"); - String username = tName.substring(0, splitLocation); - if (!this.mCapeList.contains(username.toLowerCase()) && !this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } - } else { - if (!this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } - } - } - } catch (Throwable e) { - } - /**try { - GT_Log.out.println("GT_Mod: Downloading News."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("http://files.minecraftforge.net/maven/com/gregoriust/gregtech/message.txt").openStream()); + GT_Log.out.println("GT New Horizons: Downloading Cape List."); + try (Scanner tScanner = new Scanner(new URL(GTNH_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { - this.mMessage = (this.mMessage + tScanner.nextLine() + " "); + String tName = tScanner.nextLine().toLowerCase(); + if (tName.contains(":")) { + if (!this.mCapeList.contains(tName.substring(0, tName.indexOf(":")))) { + this.mCapeList.add(tName); + } + } else { + this.mCapeList.add(tName); + } } } catch (Throwable e) { - }**/ + e.printStackTrace(GT_Log.err); + } } @Override @@ -418,34 +439,31 @@ public class GT_Client extends GT_Proxy GT_Values.NW.sendToServer(new GT_Packet_ClientPreference(mPreference)); } afterSomeTime++; - if(afterSomeTime>=100L) { - afterSomeTime=0; - StatFileWriter sfw= Minecraft.getMinecraft().thePlayer.getStatFileWriter(); + if (afterSomeTime >= 100L) { + afterSomeTime = 0; + StatFileWriter sfw = Minecraft.getMinecraft().thePlayer.getStatFileWriter(); try { - for(GT_Recipe recipe:GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { - recipe.mHidden=GT_Values.hideAssLineRecipes && !sfw.hasAchievementUnlocked(GT_Mod.achievements.getAchievement(recipe.getOutput(0).getUnlocalizedName())); + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + recipe.mHidden = GT_Values.hideAssLineRecipes && !sfw.hasAchievementUnlocked(GT_Mod.achievements.getAchievement(recipe.getOutput(0).getUnlocalizedName())); } - } catch (Exception ignored){} + } catch (Exception ignored) { + } } - ArrayList tList = new ArrayList(); - for (Map.Entry tEntry : GT_Utility.sPlayedSoundMap.entrySet()) { - if (tEntry.getValue().intValue() < 0) {//Integer -> Integer -> int? >_<, fix - tList.add(tEntry.getKey()); + for (Iterator> iterator = GT_Utility.sPlayedSoundMap.entrySet().iterator(); iterator.hasNext(); ) { + Map.Entry tEntry = iterator.next(); + if (tEntry.getValue() < 0) { + iterator.remove(); } else { - tEntry.setValue(Integer.valueOf(tEntry.getValue().intValue() - 1)); + tEntry.setValue(tEntry.getValue() - 1); } } - GT_PlayedSound tKey; - for (Iterator i$ = tList.iterator(); i$.hasNext(); GT_Utility.sPlayedSoundMap.remove(tKey)) { - tKey = (GT_PlayedSound) i$.next(); - } - if(!GregTech_API.mServerStarted) GregTech_API.mServerStarted = true; + if (!GregTech_API.mServerStarted) GregTech_API.mServerStarted = true; if (GT_Values.updateFluidDisplayItems) { MovingObjectPosition trace = Minecraft.getMinecraft().objectMouseOver; if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && (mLastUpdatedBlockX != trace.blockX && - mLastUpdatedBlockY != trace.blockY && - mLastUpdatedBlockZ != trace.blockZ || afterSomeTime % 10 == 0)) { + mLastUpdatedBlockY != trace.blockY && + mLastUpdatedBlockZ != trace.blockZ || afterSomeTime % 10 == 0)) { mLastUpdatedBlockX = trace.blockX; mLastUpdatedBlockY = trace.blockY; mLastUpdatedBlockZ = trace.blockZ; @@ -508,102 +526,85 @@ public class GT_Client extends GT_Proxy public void receiveRenderEvent(net.minecraftforge.client.event.RenderPlayerEvent.Pre aEvent) { if (GT_Utility.getFullInvisibility(aEvent.entityPlayer)) { aEvent.setCanceled(true); - return; - } else { - return; } } @SubscribeEvent public void onClientTickEvent(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) { if (aEvent.phase == cpw.mods.fml.common.gameevent.TickEvent.Phase.END) { - if(changeDetected>0)changeDetected--; - int newHideValue=shouldHeldItemHideThings(); - if(newHideValue!=hideValue){ - hideValue=newHideValue; - changeDetected=5; + if (changeDetected > 0) changeDetected--; + int newHideValue = shouldHeldItemHideThings(); + if (newHideValue != hideValue) { + hideValue = newHideValue; + changeDetected = 5; } mAnimationTick++; - if (mAnimationTick % 50L == 0L) - {mAnimationDirection = !mAnimationDirection;} + if (mAnimationTick % 50L == 0L) { + mAnimationDirection = !mAnimationDirection; + } int tDirection = mAnimationDirection ? 1 : -1; - for (Iterator i$ = mPosR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Object o : mPosR) { + Materials tMaterial = (Materials) o; tMaterial.mRGBa[0] += tDirection; } - for (Iterator i$ = mPosG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosG) { tMaterial.mRGBa[1] += tDirection; } - for (Iterator i$ = mPosB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosB) { tMaterial.mRGBa[2] += tDirection; } - for (Iterator i$ = mPosA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosA) { tMaterial.mRGBa[3] += tDirection; } - for (Iterator i$ = mNegR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegR) { tMaterial.mRGBa[0] -= tDirection; } - for (Iterator i$ = mNegG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegG) { tMaterial.mRGBa[1] -= tDirection; } - for (Iterator i$ = mNegB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegB) { tMaterial.mRGBa[2] -= tDirection; } - for (Iterator i$ = mNegA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegA) { tMaterial.mRGBa[3] -= tDirection; } - for (Iterator i$ = mMoltenPosR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosR) { tMaterial.mMoltenRGBa[0] += tDirection; } - for (Iterator i$ = mMoltenPosG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosG) { tMaterial.mMoltenRGBa[1] += tDirection; } - for (Iterator i$ = mMoltenPosB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosB) { tMaterial.mMoltenRGBa[2] += tDirection; } - for (Iterator i$ = mMoltenPosA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosA) { tMaterial.mMoltenRGBa[3] += tDirection; } - for (Iterator i$ = mMoltenNegR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegR) { tMaterial.mMoltenRGBa[0] -= tDirection; } - for (Iterator i$ = mMoltenNegG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegG) { tMaterial.mMoltenRGBa[1] -= tDirection; } - for (Iterator i$ = mMoltenNegB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegB) { tMaterial.mMoltenRGBa[2] -= tDirection; } - for (Iterator i$ = mMoltenNegA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegA) { tMaterial.mMoltenRGBa[3] -= tDirection; } @@ -620,8 +621,8 @@ public class GT_Client extends GT_Proxy do { if (i >= j) break; - if (GT_Utility.areStacksEqual((ItemStack) mSoundItems.get(i), aStack)) { - tString = (String) mSoundNames.get(i); + if (GT_Utility.areStacksEqual(mSoundItems.get(i), aStack)) { + tString = mSoundNames.get(i); break; } i++; -- cgit From 38e0b4eb935f8aa4d5950889eb1928af085af192 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 8 Jun 2021 08:54:20 +0800 Subject: migrate a few more multis over also removed the stupid ConcurrentHashMap in GT_MetaTileEntity_CubicMultiBlockBase Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 39 ++-- .../multi/GT_MetaTileEntity_DieselEngine.java | 117 ++++-------- .../multi/GT_MetaTileEntity_DistillationTower.java | 212 +++++++++++---------- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 2 + .../GT_MetaTileEntity_ExtremeDieselEngine.java | 17 +- .../multi/GT_MetaTileEntity_LargeTurbine.java | 147 ++++++-------- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 9 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 9 +- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 11 +- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 9 +- 10 files changed, 244 insertions(+), 328 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index ef53c1bca2..c84ca61eec 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -6,9 +6,7 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -30,7 +28,20 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; */ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase { protected static final String STRUCTURE_PIECE_MAIN = "main"; - private static final ConcurrentMap> STRUCTURE_DEFINITIONS = new ConcurrentHashMap<>(); + protected static final IStructureDefinition> STRUCTURE_DEFINITION = StructureDefinition.>builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"hhh", "hhh", "hhh"}, + {"h-h", "hhh", "hhh"}, + {"hhh", "hhh", "hhh"}, + })) + .addElement('h', ofChain( + defer(t -> ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, t.getHatchTextureIndex(), 1)), + onElementPass( + GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, + defer(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement) + ) + )) + .build(); private int mCasingAmount = 0; protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) { @@ -41,24 +52,6 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> createStructure(GT_MetaTileEntity_CubicMultiBlockBase aTile) { - return StructureDefinition.>builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {"hhh", "hhh", "hhh"}, - {"h-h", "hhh", "hhh"}, - {"hhh", "hhh", "hhh"}, - })) - .addElement('h', ofChain( - ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, aTile.getHatchTextureIndex(), 1), - onElementPass( - GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, - aTile.getCasingElement() - ) - )) - .build(); - } - /** * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere. *

@@ -67,7 +60,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase getStructureDefinition() { - return (IStructureDefinition) STRUCTURE_DEFINITIONS.computeIfAbsent(getBaseMetaTileEntity().getMetaTileID(), o -> createStructure(this)); + return (IStructureDefinition) STRUCTURE_DEFINITION; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index e697208a4a..1783a0c328 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -1,15 +1,16 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -21,18 +22,35 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Collection; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; - -public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"---", "iii", "chc", "chc", "ccc", }, + {"---", "i~i", "hgh", "hgh", "cdc", }, + {"---", "iii", "chc", "chc", "ccc", }, + })) + .addElement('i', defer(t -> ofBlock(t.getIntakeBlock(), t.getIntakeMeta()))) + .addElement('c', defer(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('g', defer(t -> ofBlock(t.getGearboxBlock(), t.getGearboxMeta()))) + .addElement('d', defer(t -> ofHatchAdder(GT_MetaTileEntity_DieselEngine::addDynamoToMachineList, t.getCasingTextureIndex(), 0))) + .addElement('h', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_DieselEngine::addToMachineList, t.getCasingTextureIndex(), 0, t.getCasingBlock(), t.getCasingMeta()))) + .build(); protected int fuelConsumption = 0; protected int fuelValue = 0; protected int fuelRemaining = 0; @@ -41,13 +59,13 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock public GT_MetaTileEntity_DieselEngine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - + public GT_MetaTileEntity_DieselEngine(String aName) { super(aName); } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Combustion Generator") .addInfo("Controller block for the Large Combustion Engine") @@ -71,11 +89,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock .addInputHatch("Lubricant, next to a Gear Box") .addInputHatch("Oxygen, optional, next to a Gear Box") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -83,12 +97,12 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock if (aSide == aFacing) { if (aActive) return new ITexture[]{ casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_DIESEL_ENGINE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[0][50]}; } @@ -182,67 +196,13 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - byte tSide = getBaseMetaTileEntity().getBackFacing(); - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); - - if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 1) != getGearboxBlock() && getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 2) != getGearboxBlock()) { - return false; - } - if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 1) != getGearboxMeta() && getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 2) != getGearboxMeta()) { - return false; - } - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if ((i != 0) || (j != 0)) { - for (byte k = 0; k < 4; k = (byte) (k + 1)) { - - final int fX = tX - (tSide == 5 ? 1 : tSide == 4 ? -1 : i), - fZ = tZ - (tSide == 2 ? -1 : tSide == 3 ? 1 : i), - aY = tY + j, - aX = tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - aZ = tZ + (tSide == 2 ? -k : tSide == 3 ? k : i); - - final Block frontAir = getBaseMetaTileEntity().getBlock(fX, aY, fZ); - final String frontAirName = frontAir.getUnlocalizedName(); - if(!(getBaseMetaTileEntity().getAir(fX, aY, fZ) || frontAirName.equalsIgnoreCase("tile.air") || frontAirName.equalsIgnoreCase("tile.railcraft.residual.heat"))) { - return false; //Fail if vent blocks are obstructed - } + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } - if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { - if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { - // Do nothing - } else if (!addMufflerToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? 2 : tSide == 4 ? -2 : 0), tY + 1, tZ + (tSide == 3 ? 2 : tSide == 2 ? -2 : 0)), getCasingTextureIndex())) { - return false; //Fail if no muffler top middle back - } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ))) { - return false; - } - } else if (k == 0) { - if(!(getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getIntakeBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getIntakeMeta())) { - return false; - } - } else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) { - // Do nothing - } else { - return false; - } - } - } - } - } - this.mDynamoHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { - this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); - } else { - return false; - } - } - return true; + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 1) && !mMufflerHatches.isEmpty() && mMaintenanceHatches.size() == 1; } public Block getCasingBlock() { @@ -353,4 +313,9 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlock public boolean isGivingInformation() { return true; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 1, 1); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index e12f36f331..ff7b801b15 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; @@ -7,30 +10,63 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final int CASING_INDEX = 49; - private short controllerY; + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ + {"b~b", "bbb", "bbb"}, + })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ + {"lll", "lcl", "lll"} + })) + .addElement('b', ofChain( + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + .addElement('l', ofChain( + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addLayerOutputHatch, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + .addElement('c', ofChain( + onElementPass(GT_MetaTileEntity_DistillationTower::onTopLayerFound, ofBlock(GregTech_API.sBlockCasings4, 1)), + isAir() + )) + .build(); + private final List> mOutputHatchesByLayer = new ArrayList<>(); + private int mHeight; + private int mCasing; + private boolean mTopLayerFound; public GT_MetaTileEntity_DistillationTower(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -46,7 +82,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Distillery") .addInfo("Controller block for the Distillation Tower") @@ -62,11 +98,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi .addOutputBus("Any bottom layer casing") .addOutputHatch("2-11x Output Hatches (One per layer except bottom layer)") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -75,12 +107,12 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi if (aActive) return new ITexture[]{ BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.of(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.of(OVERLAY_FRONT_DISTILLATION_TOWER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)}; } @@ -100,14 +132,8 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); for (int i = 0; i < tFluidList.size() - 1; i++) { for (int j = i + 1; j < tFluidList.size(); j++) { @@ -152,63 +178,54 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi return false; } + private void onCasingFound() { + mCasing++; + } + + private void onTopLayerFound() { + mTopLayerFound = true; + onCasingFound(); + } + + private boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) + return false; + while (mOutputHatchesByLayer.size() < mHeight + 1) + mOutputHatchesByLayer.add(new ArrayList<>()); + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatchesByLayer.get(mHeight).add(tHatch); + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - controllerY = aBaseMetaTileEntity.getYCoord(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int y = 0; //height - int casingAmount = 0; - boolean reachedTop = false; + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; - for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width - for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth - if (x != 0 || z != 0) { - IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); - Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - if (!addInputToMachineList(tileEntity, CASING_INDEX) - && !addOutputToMachineList(tileEntity, CASING_INDEX) - && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) - && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { - casingAmount++; - } else { - return false; - } - } - } - } - } - y++; + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) + return false; - while (y < 12 && !reachedTop) { - for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width - for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth - IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); - Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - if (aBaseMetaTileEntity.getAirOffset(x, y, z)) { - if (x != xDir || z != zDir) { - return false; - } - } else { - if (x == xDir && z == zDir) { - reachedTop = true; - } - if (!addOutputToMachineList(tileEntity, CASING_INDEX) - && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) - && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { - casingAmount++; - } else { - return false; - } - } - } - } - } - y++; - } - return casingAmount >= 7 * y - 5 && y >= 3 && y <= 12 && reachedTop; + // check each layer + while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) + // not top + mHeight++; + + // validate final invariants... + return mCasing >= 7 * mHeight - 5 && mHeight >= 2 && mTopLayerFound && mMaintenanceHatches.size() == 1; } @Override @@ -226,40 +243,25 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Multi return 0; } - @Override public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } -@Override - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) return false; - FluidStack tLiquid = aLiquid.copy(); - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { - if (tHatch.getBaseMetaTileEntity().getYCoord() == this.controllerY + 1) { - int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) { - return tHatch.fill(tLiquid, true) >= tLiquid.amount; - } else if (tAmount > 0) { - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - } - } - } - return false; - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { - if (mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() == this.controllerY + 1 + i) { - mOutputHatches.get(i).fill(mOutputFluids2[i], true); - } - } - } + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i].copy(); + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + for (int i = 1; i < 12; i++) { + buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 1, i, 0); } + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index b7f09203e0..010a73f777 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -264,6 +264,8 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab if (getCoilLevel() == null) return false; + if (mMaintenanceHatches.size() != 1) + this.mHeatingCapacity = (int) getCoilLevel().getHeat() + 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); return true; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java index 2457a65dec..f85f27935e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java @@ -16,7 +16,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE; @@ -35,7 +34,7 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Die } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Combustion Generator") .addInfo("Controller block for the Extreme Combustion Engine") @@ -59,11 +58,7 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Die .addInputHatch("Lubricant, next to a Gear Box") .addInputHatch("Liquid Oxygen, optional, next to a Gear Box") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -76,12 +71,12 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Die if (aSide == aFacing) { if (aActive) return new ITexture[]{ casingTexturePages[0][60], - TextureFactory.of(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[0][60], - TextureFactory.of(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[0][60]}; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index a43de4cd9d..55c22900bd 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -1,36 +1,63 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElementCheckOnly; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_MultiBlockBase { +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {" ", " xxx ", " ", " ", " ",}, + {" --- ", "xcccx", " chc ", " chc ", " ccc ",}, + {" --- ", "xc~cx", " h-h ", " h-h ", " cdc ",}, + {" --- ", "xcccx", " chc ", " chc ", " ccc ",}, + {" ", " xxx ", " ", " ", " ",}, + })) + .addElement('c', defer(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('d', defer(t -> ofHatchAdder(GT_MetaTileEntity_LargeTurbine::addDynamoToMachineList, t.getCasingTextureIndex(), 0))) + .addElement('h', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_LargeTurbine::addToMachineList, t.getCasingTextureIndex(), 0, t.getCasingBlock(), t.getCasingMeta()))) + .addElement('x', (IStructureElementCheckOnly) (aContext, aWorld, aX, aY, aZ) -> { + TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); + return !(tTile instanceof IGregTechTileEntity) || !(((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine); + }) + .build(); protected int baseEff = 0; protected int optFlow = 0; protected double realOptFlow = 0; protected int storedFluid = 0; protected int counter = 0; - protected boolean looseFit=false; + protected boolean looseFit = false; public GT_MetaTileEntity_LargeTurbine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } + public GT_MetaTileEntity_LargeTurbine(String aName) { super(aName); } @@ -45,67 +72,14 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); } + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - byte tSide = getBaseMetaTileEntity().getBackFacing(); - if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2))) { - int tAirCount = 0; - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { - tAirCount++; - } - } - } - } - if (tAirCount != 10) { - return false; - } - for (byte i = 2; i < 6; i = (byte) (i + 1)) { - IGregTechTileEntity tTileEntity; - if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && - (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && - ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine))) { - return false; - } - } - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); - for (byte i = -1; i < 2; i = (byte) (i + 1)) { - for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if ((i != 0) || (j != 0)) { - for (byte k = 0; k < 4; k = (byte) (k + 1)) { - if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { - if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { - return false; - } - } else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } else { - return false; - } - } - } - } - } - this.mDynamoHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { - this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex()); - } else { - return false; - } - } else { - return false; - } - } else { - return false; - } - return true; + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1); } public abstract Block getCasingBlock(); @@ -114,11 +88,11 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M public abstract byte getCasingTextureIndex(); - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + @Override + public boolean addToMachineList(IGregTechTileEntity tTileEntity, int aBaseCasingIndex) { + return addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex()) || addInputToMachineList(tTileEntity, getCasingTextureIndex()) || addOutputToMachineList(tTileEntity, getCasingTextureIndex()) || addMufflerToMachineList(tTileEntity, getCasingTextureIndex()); } - @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); @@ -131,19 +105,19 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M @Override public boolean checkRecipe(ItemStack aStack) { - if((counter&7)==0 && (aStack==null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() >179)) { - stopMachine(); - return false; + if ((counter & 7) == 0 && (aStack == null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() > 179)) { + stopMachine(); + return false; } ArrayList tFluids = getStoredFluids(); if (tFluids.size() > 0) { if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { counter = 0; - baseEff = GT_Utility.safeInt((long)((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - optFlow = GT_Utility.safeInt((long)Math.max(Float.MIN_NORMAL, + baseEff = GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + optFlow = GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() - * ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed * 50)); if(optFlow<=0 || baseEff<=0){ stopMachine();//in case the turbine got removed @@ -197,6 +171,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M } return 0; } + @Override public boolean explodesOnComponentBreak(ItemStack aStack) { return true; @@ -234,22 +209,22 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M } String[] ret = new String[]{ // 8 Lines available for information panels - tRunning + ": " + EnumChatFormatting.RED+mEUt+EnumChatFormatting.RESET+" EU/t", /* 1 */ + tRunning + ": " + EnumChatFormatting.RED + mEUt + EnumChatFormatting.RESET + " EU/t", /* 1 */ tMaintainance, /* 2 */ - StatCollector.translateToLocal("GT5U.turbine.efficiency")+": "+EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.RESET+"%", /* 2 */ - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ /* 3 */ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+GT_Utility.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t" + /* 4 */ - EnumChatFormatting.YELLOW+" ("+(looseFit?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", /* 5 */ - StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", /* 6 */ - StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+EnumChatFormatting.RED+Integer.toString(tDura)+EnumChatFormatting.RESET+"%", /* 7 */ - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" /* 8 */ + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + EnumChatFormatting.YELLOW + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", /* 2 */ + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + /* 3 */ + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t" + /* 4 */ + EnumChatFormatting.YELLOW + " (" + (looseFit ? StatCollector.translateToLocal("GT5U.turbine.loose") : StatCollector.translateToLocal("GT5U.turbine.tight")) + ")", /* 5 */ + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + EnumChatFormatting.GOLD + storedFluid + EnumChatFormatting.RESET + "L", /* 6 */ + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + EnumChatFormatting.RED + tDura + EnumChatFormatting.RESET + "%", /* 7 */ + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ }; if (!this.getClass().getName().contains("Steam")) - ret[4]=StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+GT_Utility.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t"; + ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t"; return ret; - - + + } @Override @@ -257,4 +232,8 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_M return true; } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 2, 1); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index b8f3d835fa..88a01dc310 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -12,7 +12,6 @@ import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Collection; @@ -38,7 +37,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Gas Turbine") .addInfo("Controller block for the Large Gas Turbine") @@ -53,11 +52,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT .addMufflerHatch("Side centered") .addInputHatch("Gas Fuel, Side centered") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } public int getFuelValue(FluidStack aLiquid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index fb510f1352..6a0074539d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -43,7 +42,7 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Steam Turbine") .addInfo("Controller block for the Large High Pressure Steam Turbine") @@ -60,11 +59,7 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La .addInputHatch("Superheated Steam, Side centered") .addOutputHatch("Steam, Side centered") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index bf1506ec81..094e7c20f9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -6,9 +6,9 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.render.TextureFactory; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; @@ -20,7 +20,6 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Collection; @@ -45,7 +44,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Plasma Turbine") .addInfo("Controller block for the Large Plasma Generator") @@ -60,11 +59,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar .addInputHatch("Plasma Fluid, Side centered") .addOutputHatch("Molten Fluid, optional, Side centered") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } public int getFuelValue(FluidStack aLiquid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 44e7dfd695..49bffa1e7e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -46,7 +45,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Steam Turbine") .addInfo("Controller block for the Large Steam Turbine") @@ -63,11 +62,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg .addInputHatch("Steam, Side centered") .addOutputHatch("Distilled Water, Side centered") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override -- cgit From 2085a8654580f2b1b457343cf5c225ecb1800dd6 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 9 Jun 2021 06:51:47 +0800 Subject: Fix rotate front face highlight Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 93 +++++++++++++++++----------- 1 file changed, 57 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 4ff9e69a2a..154b8d7308 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -26,11 +26,22 @@ import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.net.GT_Packet_ClientPreference; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.entities.GT_Entity_Arrow_Potion; import gregtech.common.net.MessageUpdateFluidDisplayItem; -import gregtech.common.render.*; +import gregtech.common.render.GT_CapeRenderer; +import gregtech.common.render.GT_FlaskRenderer; +import gregtech.common.render.GT_FluidDisplayStackRenderer; +import gregtech.common.render.GT_MetaGenerated_Item_Renderer; +import gregtech.common.render.GT_MetaGenerated_Tool_Renderer; +import gregtech.common.render.GT_PollutionRenderer; +import gregtech.common.render.GT_Renderer_Block; +import gregtech.common.render.GT_Renderer_Entity_Arrow; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -51,7 +62,13 @@ import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import java.net.URL; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Scanner; // Referenced classes of package gregtech.common: // GT_Proxy @@ -72,18 +89,27 @@ public class GT_Client extends GT_Proxy {2, 4, 3, 1, 5, 0}, }; - public static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); - private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES = { - new Scale(0.25).with(new Translation(0, 0, 0.375)), - new Scale(0.25).with(new Translation(0.375, 0, 0)), - new Scale(0.25).with(new Translation(0, 0, -0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, 0)), + // don't ask. these "just works" + private static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS = { + new Scale(0.25).with(new Translation(0, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(0.375, 0, 0)).compile(), + new Scale(0.25).with(new Translation(0, 0, -0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, 0)).compile(), + }; + private static final int[] ROTATION_MARKER_TRANSFORMS_SIDES = { + -1, -1, 2, 0, 3, 1, + -1, -1, 0, 2, 3, 1, + 0, 2, -1, -1, 3, 1, + 2, 0, -1, -1, 3, 1, + 1, 3, 2, 0, -1, -1, + 3, 1, 2, 0, -1, -1 }; private static final Transformation[] ROTATION_MARKER_TRANSFORMS_CORNER = { - new Scale(0.25).with(new Translation(0.375, 0, 0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, 0.375)), - new Scale(0.25).with(new Translation(0.375, 0, -0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, -0.375)), + new Scale(0.25).with(new Translation(0.375, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(0.375, 0, -0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, -0.375)).compile(), }; static { @@ -185,28 +211,6 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(-.25D, .0D, +.50D); TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - // draw turning indicator - if (tTile instanceof IGregTechTileEntity && - ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { - IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); - if (tAlignment != null) { - ForgeDirection direction = tAlignment.getDirection(); - - GL11.glEnd(); - if (direction.ordinal() == tSideHit) - drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); - else if (direction.getOpposite().ordinal() == tSideHit) { - for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { - drawRotationMarker(t); - } - } else { - drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES[Rotation.rotationTo(direction.ordinal(), tSideHit)]); - } - // resume glBegin - GL11.glBegin(GL11.GL_LINES); - } - } - // draw connection indicators byte tConnections = 0; if (tTile instanceof ICoverable) { @@ -276,7 +280,24 @@ public class GT_Client extends GT_Proxy } } GL11.glEnd(); - GL11.glPopMatrix(); + // draw turning indicator + if (tTile instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { + IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); + if (tAlignment != null) { + ForgeDirection direction = tAlignment.getDirection(); + if (direction.ordinal() == tSideHit) + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + else if (direction.getOpposite().ordinal() == tSideHit) { + for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { + drawRotationMarker(t); + } + } else { + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit*6+direction.ordinal()]]); + } + } + } + GL11.glPopMatrix(); // get back to player center } private static void drawRotationMarker(Transformation transform) { -- cgit From 3a472099af01778f5b62cc4ab2aaf6dc5cfff299 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 10 Jun 2021 05:23:15 +0800 Subject: migrate even more multis over Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 2 +- .../GT_MetaTileEntity_ConcreteBackfiller1.java | 5 +- .../GT_MetaTileEntity_ConcreteBackfiller2.java | 35 +-- .../GT_MetaTileEntity_ConcreteBackfillerBase.java | 12 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 89 ++++--- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 8 +- .../multi/GT_MetaTileEntity_HeatExchanger.java | 149 +++++------ .../multi/GT_MetaTileEntity_LargeBoiler.java | 139 +++++------ .../GT_MetaTileEntity_LargeChemicalReactor.java | 131 +++++----- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 2 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 3 +- .../multi/GT_MetaTileEntity_OilCracker.java | 276 ++++++++++----------- .../multi/GT_MetaTileEntity_OilDrill1.java | 5 +- .../multi/GT_MetaTileEntity_OilDrill2.java | 5 +- .../multi/GT_MetaTileEntity_OilDrill3.java | 5 +- .../multi/GT_MetaTileEntity_OilDrillBase.java | 17 +- .../multi/GT_MetaTileEntity_OreDrillingPlant1.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant2.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant3.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant4.java | 5 +- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 8 +- 24 files changed, 423 insertions(+), 494 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 154b8d7308..8e06207267 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -293,7 +293,7 @@ public class GT_Client extends GT_Proxy drawRotationMarker(t); } } else { - drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit*6+direction.ordinal()]]); + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]]); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java index a509d35ad3..af1468396b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_ConcreteBackfillerBase { public GT_MetaTileEntity_ConcreteBackfiller1(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_Con } @Override - public String[] getDescription() { - return getDescriptionInternal(""); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("Concrete Backfiller"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java index d1f44580c6..05646676e7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java @@ -6,10 +6,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import static gregtech.api.enums.GT_Values.VN; - -import org.lwjgl.input.Keyboard; - public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_ConcreteBackfillerBase { public GT_MetaTileEntity_ConcreteBackfiller2(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -20,35 +16,8 @@ public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_Con } @Override - public String[] getDescription() { - String casings = getCasingBlockItem().get(0).getDisplayName(); - - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Concrete Backfiller") - .addInfo("Controller Block for the Advanced Concrete Backfiller") - .addInfo("Will fill in areas below it with light concrete. This goes through walls") - .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") - .addInfo("Will pull back the pipes after it finishes that layer") - .addInfo("Put Programmed Circuits into a Data Access Hatch to config radius. Buggy") - .addInfo("Radius = (total config value)x2 blocks. Default 64, Maximum 128")//broken - .addSeparator() - .beginStructureBlock(3, 7, 3, false) - .addController("Front bottom") - .addStructureInfo(casings + " form the 3x1x3 Base") - .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") - .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") - .addMaintenanceHatch("Any base casing") - .addStructureInfo("Data Access Hatch: Any base casing") - .addInputBus("Mining Pipes, optional, any base casing") - .addInputHatch("GT Concrete, any base casing") - .addOutputBus("Mining Pipes, optional, any base casing") - .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("Advanced Concrete Backfiller"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index a64fea5ab0..2341452ebe 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -11,8 +11,6 @@ import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.VN; -import org.lwjgl.input.Keyboard; - public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase { private int mLastXOff = 0, mLastZOff = 0; @@ -25,12 +23,12 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi super(aName); } - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String aStructureName) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Concrete Backfiller") - .addInfo("Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""))//Unused? + .addInfo("Controller Block for the " + aStructureName) .addInfo("Will fill in areas below it with light concrete. This goes through walls") .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") .addInfo("Will pull back the pipes after it finishes that layer") @@ -47,11 +45,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi .addInputHatch("GT Concrete, any base casing") .addOutputBus("Mining Pipes, optional, any base casing") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + return tt; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index a57a237060..8916c9f42a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -7,10 +10,10 @@ import gregtech.api.interfaces.IChunkLoader; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; @@ -27,18 +30,45 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_GLOW; import static gregtech.api.enums.Textures.BlockIcons.getCasingTextureForId; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase implements IChunkLoader { +public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_EnhancedMultiBlockBase implements IChunkLoader { private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0); private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0); private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe); private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip); + protected static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {" ", " f ", " "}, + {" ", " f ", " "}, + {" ", " f ", " "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {"b~b", "bbb", "bbb"}, + })) + .addElement('f', defer(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) + .addElement('c', defer(t -> ofBlock(t.casingBlock, t.casingMeta))) + .addElement('b', defer(t -> ofChain( + ofBlock(t.casingBlock, t.casingMeta), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addEnergyInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addDataAccessToMachineList, t.casingTextureIndex, 1) + ))) + .build(); private Block casingBlock; private int casingMeta; @@ -82,12 +112,12 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_ORE_DRILL_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_ORE_DRILL), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_GLOW).extFacing().glow().build()}; } return new ITexture[]{getCasingTextureForId(casingTextureIndex)}; } @@ -318,37 +348,20 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } } + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { updateCoordinates(); - //check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) - && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addInputToMachineList(tTileEntity, casingTextureIndex) - && !addOutputToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex) - && !addDataAccessToMachineList(tTileEntity, casingTextureIndex)) - return false; - } - } - if(!checkHatches()) return false; - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false; - //check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) - return false; - } - return true; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier(); } private void updateCoordinates() { @@ -370,14 +383,17 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return true; } + @Deprecated protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); } //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) + @Deprecated protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); } + @Deprecated protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta); } @@ -484,4 +500,9 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } @Override public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;} + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 6, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 010a73f777..22171e6e04 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -4,6 +4,7 @@ import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -35,6 +36,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAS import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.ofCoil; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; @@ -55,7 +57,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab })) .addElement('t', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_MetaTileEntity_ElectricBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2)) - .addElement('C', GT_StructureUtility.ofCoil(GT_MetaTileEntity_ElectricBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) + .addElement('C', ofCoil(GT_MetaTileEntity_ElectricBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) .build(); @@ -256,7 +258,9 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab replaceDeprecatedCoils(aBaseMetaTileEntity); - setCoilLevel(null); + setCoilLevel(HeatingCoilLevel.None); + + mPollutionOutputHatches.clear(); if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 9ce1de3fec..0579c4871b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -1,44 +1,69 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import net.minecraft.block.Block; 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.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; - -public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final int CASING_INDEX = 50; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "cCc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"c~c", "cHc", "ccc"}, + })) + .addElement('P', ofBlock(GregTech_API.sBlockCasings2, 14)) + .addElement('C', ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addColdFluidOutputToMachineList, CASING_INDEX, 2)) + .addElement('H', ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addHotFluidInputToMachineList, CASING_INDEX, 3)) + .addElement('c', ofChain( + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_HeatExchanger::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, (byte) 2)) + )) + .build(); public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) - private static boolean controller; private GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; private GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; private boolean superheated = false; private int superheated_threshold=0; private float water; + private int mCasingAmount; public GT_MetaTileEntity_HeatExchanger(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -48,7 +73,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Heat Exchanger") .addInfo("Controller Block for the Large Heat Exchanger") @@ -68,11 +93,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc .addOutputHatch("Cold fluid, top center") .addOutputHatch("Steam/SH Steam, any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -92,15 +113,15 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aSide == aFacing) { if (aActive) return new ITexture[]{ - casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW).glow().build()}; + casingTexturePages[0][CASING_INDEX], + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ - casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_HEAT_EXCHANGER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_GLOW).glow().build()}; + casingTexturePages[0][CASING_INDEX], + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_GLOW).extFacing().glow().build()}; } - return new ITexture[]{casingTexturePages[0][50]}; + return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; } @Override @@ -114,8 +135,8 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> !r.isUpsideDown(); } @Override @@ -208,57 +229,20 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - int tCasingAmount = 0; - controller = false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((i != 0) || (j != 0)) { - for (int k = 0; k <= 3; k++) { - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } else { - if (!addHotFluidInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j), 50)) { - return false; - } - if (!addColdFluidOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), 50)) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != getPipeMeta()) { - return false; - } + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != getPipeMeta()) { - return false; - } - } - } - } - return tCasingAmount >= 20; + private void onCasingAdded() { + mCasingAmount++; } - public boolean ignoreController(Block tTileEntity) { - return !controller && tTileEntity == GregTech_API.sBlockMachines; + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mOutputColdFluidHatch = null; + mInputHotFluidHatch = null; + mCasingAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0) && mCasingAmount >= 20 && mMaintenanceHatches.size() == 1; } public boolean addColdFluidOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -286,26 +270,6 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc return false; } - public Block getCasingBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getCasingMeta() { - return 2; - } - - public byte getCasingTextureIndex() { - return 50; - } - - public Block getPipeBlock() { - return GregTech_API.sBlockCasings2; - } - - public byte getPipeMeta() { - return 14; - } - @Override public int getMaxEfficiency(ItemStack aStack) { return 10000; @@ -351,4 +315,9 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + EnumChatFormatting.GREEN + superheated_threshold + EnumChatFormatting.RESET }; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 3, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index 841a4fb57c..7f409f38f4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.GT_Mod; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -8,7 +10,7 @@ import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -20,25 +22,52 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.STEAM_PER_WATER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_GLOW; - -public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "ccc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"f~f", "fff", "fff"}, + })) + .addElement('P', defer(t -> ofBlock(t.getPipeBlock(), t.getPipeMeta()))) + .addElement('c', defer(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addOutputToMachineList, t.getCasingTextureIndex(), 2), + onElementPass(GT_MetaTileEntity_LargeBoiler::onCasingAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .addElement('f', defer(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getCasingTextureIndex(), 1), + onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .build(); private boolean firstRun = true; private int mSuperEfficencyIncrease = 0; private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config private int excessWater = 0; //Eliminate rounding errors for water private int excessFuel = 0; //Eliminate rounding errors for fuels that burn half items private int excessProjectedEU = 0; //Eliminate rounding errors from throttling the boiler + private int mCasingAmount; + private int mFireboxAmount; public GT_MetaTileEntity_LargeBoiler(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -49,7 +78,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Boiler") .addInfo("Controller block for the Large " + getCasingMaterial() + " Boiler") @@ -71,11 +100,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu .addInputHatch("Water, Any firebox") .addOutputHatch("Steam, any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } public abstract String getCasingMaterial(); @@ -107,12 +132,12 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ BlockIcons.getCasingTextureForId(getCasingTextureIndex()), - TextureFactory.of(OVERLAY_FRONT_LARGE_BOILER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.getCasingTextureForId(getCasingTextureIndex()), - TextureFactory.of(OVERLAY_FRONT_LARGE_BOILER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; } @@ -127,11 +152,6 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { //Do we have an integrated circuit with a valid configuration? @@ -249,65 +269,25 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu super.onPostTick(aBaseMetaTileEntity, aTick); } + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + private void onCasingAdded() { + mCasingAmount++; + } + + private void onFireboxAdded() { + mFireboxAmount++; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - int tCasingAmount = 0; - int tFireboxAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i != 0 || j != 0) { - for (int k = 1; k <= 4; k++) { - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), getCasingTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } else { - for (int k = 1; k <= 3; k++) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getPipeMeta()) { - return false; - } - } - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 4, zDir + j), getCasingTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 4, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 4, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (xDir + i != 0 || zDir + j != 0) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if (!addMaintenanceToMachineList(tTileEntity, getFireboxTextureIndex()) && !addInputToMachineList(tTileEntity, getFireboxTextureIndex()) && !addMufflerToMachineList(tTileEntity, getFireboxTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != getFireboxBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != getFireboxMeta()) { - return false; - } - tFireboxAmount++; - } - } - } - } - return tCasingAmount >= 24 && tFireboxAmount >= 3; + mCasingAmount = 0; + mFireboxAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 4, 0) && mCasingAmount >= 24 && mFireboxAmount >= 3 && + mMaintenanceHatches.size() == 1 && !mMufflerHatches.isEmpty(); } @Override @@ -347,4 +327,9 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu this.excessProjectedEU %= adjustedEUt; return adjustedBurnTime; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 4, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index c9de809b58..072f54e4af 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -1,33 +1,63 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; - -public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_MultiBlockBase { - - private final int CASING_INDEX = 176; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final int CASING_INDEX = 176; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "cxc", "ccc"}, + {"c~c", "xPx", "cxc"}, + {"ccc", "cxc", "ccc"}, + })) + .addElement('P', ofBlock(GregTech_API.sBlockCasings8, 1)) + .addElement('c', ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) + )) + .addElement('x', ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCoilAdded, ofBlock(GregTech_API.sBlockCasings5, 0)), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) + )) + .build(); + + private int mCasingAmount; + private int mCoilAmount; public GT_MetaTileEntity_LargeChemicalReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -43,7 +73,7 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu } @Override - public String[] getDescription() { + public GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Chemical Reactor") .addInfo("Controller block for the Large Chemical Reactor") @@ -63,11 +93,7 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu .addOutputHatch("Any casing") .addStructureInfo("You can have multiple hatches/busses") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -76,12 +102,12 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ casingTexturePages[1][48], - TextureFactory.of(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[1][48], - TextureFactory.of(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[1][48]}; } @@ -162,56 +188,25 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int casingAmount = 0; - boolean hasHeatingCoil = false; - // x=width, z=depth, y=height - for (int x = -1 + xDir; x <= xDir + 1; x++) { - for (int z = -1 + zDir; z <= zDir + 1; z++) { - for (int y = -1; y <= 1; y++) { - if (x == 0 && y == 0 && z == 0) { - continue; - } - IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); - Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - int centerCoords = 0; - if (x == xDir) { - centerCoords++; - } - if (y == 0) { - centerCoords++; - } - if (z == zDir) { - centerCoords++; - } - if (centerCoords == 3) { - if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { - continue; - } else { - return false; - } - } - if (centerCoords == 2 && block == GregTech_API.sBlockCasings5 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) { - hasHeatingCoil = true; - continue; - } - if (!addInputToMachineList(tileEntity, CASING_INDEX) && !addOutputToMachineList(tileEntity, CASING_INDEX) - && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) - && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) { - casingAmount++; - } else { - return false; - } - } + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } - } - } + private void onCasingAdded() { + mCasingAmount++; + } - } - return casingAmount >= 8 && hasHeatingCoil && !mEnergyHatches.isEmpty() && !mMaintenanceHatches.isEmpty(); + private void onCoilAdded() { + mCoilAmount++; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasingAmount = 0; + mCoilAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && + mCasingAmount >= 8 && mCoilAmount == 1 && + !mEnergyHatches.isEmpty() && mMaintenanceHatches.size() == 1; } @Override @@ -234,4 +229,8 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu return false; } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 1, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 88a01dc310..214e0648c2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -33,7 +33,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_SS_ACTIVE5) : TextureFactory.of(LARGETURBINE_SS5) : casingTexturePages[0][58]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_SS_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_SS5).extFacing().build() : casingTexturePages[0][58]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index 6a0074539d..0d22271a34 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_TI_ACTIVE5) : TextureFactory.of(LARGETURBINE_TI5) : casingTexturePages[0][59]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_TI_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_TI5).extFacing().build() : casingTexturePages[0][59]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index 094e7c20f9..efc3ecaea3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_TU_ACTIVE5) : TextureFactory.of(Textures.BlockIcons.LARGETURBINE_TU5) : casingTexturePages[0][60]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_TU_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(Textures.BlockIcons.LARGETURBINE_TU5).extFacing().build() : casingTexturePages[0][60]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 49bffa1e7e..8990ad3324 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -41,7 +41,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_ST_ACTIVE5) : TextureFactory.of(LARGETURBINE_ST5) : casingTexturePages[0][57]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_ST_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_ST5).extFacing().build() : casingTexturePages[0][57]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 58d9a24f80..20ef0fa6e7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -4,6 +4,7 @@ import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -175,7 +176,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu replaceDeprecatedCoils(aBaseMetaTileEntity); - setCoilLevel(null); + setCoilLevel(HeatingCoilLevel.None); if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0)) return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 0a0088246b..e4f96db248 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -1,43 +1,73 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.mutable.MutableInt; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; -import java.util.BitSet; +import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { - private ForgeDirection orientation; - private int controllerX, controllerZ; - +public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final byte CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"lcmcr", "lcmcr", "lcmcr"}, + {"lc~cr", "l---r", "lcmcr"}, + {"lcmcr", "lcmcr", "lcmcr"}, + })) + .addElement('c', ofCoil(GT_MetaTileEntity_OilCracker::setCoilLevel, GT_MetaTileEntity_OilCracker::getCoilLevel)) + .addElement('l', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addLeftHatchToMachineList, CASING_INDEX, 2), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 2)) + )) + .addElement('r', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 2), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 3)) + )) + .addElement('m', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMiddleInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + .build(); private HeatingCoilLevel heatLevel; + protected final List mMiddleInputHatches = new ArrayList<>(); + // 0 -> left, 1 -> right, any other -> not found + protected int mInputOnSide; + protected int mOutputOnSide; + protected int mCasingAmount; public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -48,7 +78,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Cracker") .addInfo("Controller block for the Oil Cracking Unit") @@ -68,19 +98,18 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa .addOutputHatch("Any left/right side casing") .addStructureInfo("Input/Output Hatches must be on opposite sides!") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) return tt.getInformation(); - return tt.getStructureInformation(); + return tt; } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { if (aActive) return new ITexture[]{casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_OIL_CRACKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_OIL_CRACKER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; } @@ -129,141 +158,97 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa return false; } - private boolean coilsNotPresent(IGregTechTileEntity aBaseMetaTileEntity, int x , int y, int z) { - - Block coil = aBaseMetaTileEntity.getBlockOffset(x, y, z); - - if (!(coil instanceof IHeatingCoil)) - return true; - - IHeatingCoil heatingCoil = (IHeatingCoil) coil; - byte meta = aBaseMetaTileEntity.getMetaIDOffset(x, y, z); - HeatingCoilLevel heatLevel = heatingCoil.getCoilHeat(meta); - if (heatLevel == HeatingCoilLevel.None) - return true; - - if (this.heatLevel == HeatingCoilLevel.None) - this.heatLevel = heatLevel; - - return this.heatLevel != heatLevel; + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; } - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.heatLevel = HeatingCoilLevel.None; - this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); - this.controllerX = aBaseMetaTileEntity.getXCoord(); - this.controllerZ = aBaseMetaTileEntity.getZCoord(); - int xDir = this.orientation.offsetX; - int zDir = this.orientation.offsetZ; - MutableInt amount = new MutableInt(0); - replaceDeprecatedCoils(aBaseMetaTileEntity); - BitSet flags = new BitSet(4); - - for (int depth = -1; depth < 2; depth++) - for (int height = -1; height < 2; height++) - for (int slice = -2; slice < 3; slice++) - if (xDir == 0) { - if (isStructureBroken(xDir, zDir, slice, height, depth, aBaseMetaTileEntity, amount, flags)) - return false; - } else { - if (isStructureBroken(xDir, zDir, depth, height, slice, aBaseMetaTileEntity, amount, flags)) - return false; - } - - if(checkInputOutputBroken(flags)) - return false; + public HeatingCoilLevel getCoilLevel() { + return heatLevel; + } - return amount.intValue() >= 18; + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + heatLevel = aCoilLevel; } - private boolean checkInputOutputBroken(BitSet flags){ - if (flags.get(0) && flags.get(2)) //input and output on side 1 - return true; - if (flags.get(1) && flags.get(3)) //input and output on side 2 - return true; - if (flags.get(1) && flags.get(2)) //input on both sides - return true; - return flags.get(2) && flags.get(3); //output on both sides + private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mMiddleInputHatches.add(tHatch); + } + return false; } - private boolean isStructureBroken( - int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount, - BitSet flags) { - if (b == 0 && c == 0 && (a == -1 || a == 0 || a == 1)) - return false; - if (a == 1 || a == -1) { - return coilsNotPresent(aBaseMetaTileEntity, xDir + a, b, c + zDir); + private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (mInputOnSide == 1) + return false; + mInputOnSide = 0; + mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mInputHatches.add(tHatch); } - else if (a == 2 || a == -2) { - return checkEndsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount, flags); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (mOutputOnSide == 1) + return false; + mInputOnSide = 1; + mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatches.add(tHatch); } - else if (a == 0) - return checkMiddleBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount); - return false; } - private boolean checkEndsBroken( - int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount, - BitSet flags - ){ - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - if (a == -2) - flags.set(0); //input on side 1 - else - flags.set(1); //input on side 2 - else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - if (a == -2) - flags.set(2); //output on side 1 - else - flags.set(3); //output on side 2 - else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) - return true; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) - return true; - amount.increment(); - } + private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (mInputOnSide == 0) + return false; + mInputOnSide = 1; + mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (mOutputOnSide == 0) + return false; + mInputOnSide = 0; + mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatches.add(tHatch); + } return false; } - private boolean checkMiddleBroken( int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount){ - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - return false; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - return false; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - return false; - if ((xDir + c) == 0 && b == 0 && (a + zDir) == 0) - return false; - if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) - return true; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) - return true; - amount.increment(); - return false; + private void onCasingAdded() { + mCasingAmount++; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + setCoilLevel(HeatingCoilLevel.None); + mCasingAmount = 0; + mMiddleInputHatches.clear(); + mInputOnSide = -1; + mOutputOnSide = -1; + replaceDeprecatedCoils(aBaseMetaTileEntity); + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18; } @Override @@ -330,22 +315,25 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa public ArrayList getStoredFluids() { ArrayList rList = new ArrayList<>(); for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { FluidStack tStack = tHatch.getFillableStack(); if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) { - if (isHatchInMiddleRing(tHatch)) - rList.add(tStack); - } else if (!isHatchInMiddleRing(tHatch)) rList.add(tStack); + } } } return rList; } - private boolean isHatchInMiddleRing(GT_MetaTileEntity_Hatch_Input inputHatch){ - if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) - return inputHatch.getBaseMetaTileEntity().getXCoord() == this.controllerX; - return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ; + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 1, 0); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java index 73d8131fed..610c21e89b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill1 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill1(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill1 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("I"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("I"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java index 9d36b340d3..eab1ebf614 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill2 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill2(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill2 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("II"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("II"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java index 8ebc658406..738f60544b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill3 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill3(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill3 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("III"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("III"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 44fb734534..554e5dfd63 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -19,7 +19,6 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -52,12 +51,12 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D if (aSide == aFacing) { if (aActive) return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_OIL_DRILL_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_OIL_DRILL), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_GLOW).extFacing().glow().build()}; } return new ITexture[]{getCasingTextureForId(casingTextureIndex)}; } @@ -77,7 +76,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D chunkRangeConfig = aNBT.getInteger("chunkRangeConfig"); } - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); @@ -98,11 +97,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D .addInputBus("Mining Pipes or Circuits, optional, any base casing") .addOutputHatch("Any base casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java index d23ce2edd0..ac3e40c5f5 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant1 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant1(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant1 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("I"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("I"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java index db7c4cd9e7..bf9c628911 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant2 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant2(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant2 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("II"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("II"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java index b7053a8ebd..411bbef3a7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant3 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant3(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant3 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("III"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("III"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java index db86b963ca..d7daea327c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant4 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant4(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant4 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("IV"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("IV"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 224f1de557..5b4444cec3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -332,7 +332,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile protected abstract int getBaseProgressTime(); - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); @@ -356,11 +356,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile .addInputHatch("Drilling Fluid, any base casing") .addOutputBus("Any base casing") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + return tt; } @Override -- cgit From 03a45da45fdd85f1276416c2586a98eba79a9b50 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 11 Jun 2021 02:48:50 +0800 Subject: migrate all other multis over Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 11 + .../multi/GT_MetaTileEntity_AssemblyLine.java | 233 ++++++++------------ .../multi/GT_MetaTileEntity_FusionComputer.java | 242 ++++++++++----------- .../multi/GT_MetaTileEntity_FusionComputer1.java | 8 +- .../multi/GT_MetaTileEntity_FusionComputer2.java | 9 +- .../multi/GT_MetaTileEntity_FusionComputer3.java | 8 +- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 230 +++++++------------- 7 files changed, 293 insertions(+), 448 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index d925cc1d84..e4bfef4a48 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -144,6 +144,17 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase>) getStructureDefinition(); } + /** + * Explanation of the world coordinate these offset means: + * + * Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped. + * + * The horizontalOffset would be the number of blocks on the left side of the controller, not counting controller itself. + * The verticalOffset would be the number of blocks on the top side of the controller, not counting controller itself. + * The depthOffset would be the number of blocks between you and controller, not counting controller itself. + * + * All these offsets can be negative. + */ protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { IGregTechTileEntity tTile = getBaseMetaTileEntity(); return getCastedStructureDefinition().check(this, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, !mMachine); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 6695c4d0a2..4c294aadfe 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -9,9 +12,10 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -19,22 +23,65 @@ import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; -public class GT_MetaTileEntity_AssemblyLine - extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMultiBlockBase { public ArrayList mDataAccessHatches = new ArrayList<>(); + private static final String STRUCTURE_PIECE_FIRST = "first"; + private static final String STRUCTURE_PIECE_SECOND = "second"; + private static final String STRUCTURE_PIECE_LATER = "later"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_FIRST, transpose(new String[][]{ + {" ", "e", " "}, + {"~", "l", "G"}, + {"g", "m", "g"}, + {"b", "i", "b"}, + })) + .addShape(STRUCTURE_PIECE_SECOND, transpose(new String[][]{ + {" ", "e", " "}, + {"d", "l", "G"}, + {"g", "m", "g"}, + {"b", "I", "b"}, + })) + .addShape(STRUCTURE_PIECE_LATER, transpose(new String[][]{ + {" ", "e", " "}, + {"G", "l", "G"}, + {"g", "m", "g"}, + {"b", "I", "b"}, + })) + .addElement('G', ofBlock(GregTech_API.sBlockCasings3, 10)) // grate machine casing + .addElement('l', ofBlock(GregTech_API.sBlockCasings2, 9)) // assembler machine casing + .addElement('m', ofBlock(GregTech_API.sBlockCasings2, 5)) // assembling line casing + .addElement('g', ofBlockAnyMeta(GameRegistry.findBlock("IC2", "blockAlloyGlass"))) + .addElement('e', ofHatchAdderOptional(GT_MetaTileEntity_AssemblyLine::addEnergyInputToMachineList, 16, 1, GregTech_API.sBlockCasings2, 0)) + .addElement('d', ofHatchAdderOptional(GT_MetaTileEntity_AssemblyLine::addDataAccessToMachineList, 42, 1, GregTech_API.sBlockCasings3, 10)) + .addElement('b', ofChain( + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addMaintenanceToMachineList, 16, 2), + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputHatchToMachineList, 16, 2), + ofBlock(GregTech_API.sBlockCasings2, 0) + )) + .addElement('I', ofChain( + // all blocks nearby use solid steel casing, so let's use the texture of that + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 2), + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addOutputToMachineList, 16, 2) + )) + .addElement('i', ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 2)) + .build(); public GT_MetaTileEntity_AssemblyLine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -50,7 +97,7 @@ public class GT_MetaTileEntity_AssemblyLine } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Assembling Line") .addInfo("Controller block for the Assembling Line") @@ -74,11 +121,7 @@ public class GT_MetaTileEntity_AssemblyLine .addInputHatch("Any layer 1 casing") .addOutputBus("Replaces Input Bus on final slice") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -87,12 +130,12 @@ public class GT_MetaTileEntity_AssemblyLine if (aActive) return new ITexture[]{ BlockIcons.casingTexturePages[0][16], - TextureFactory.of(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.casingTexturePages[0][16], - TextureFactory.of(OVERLAY_FRONT_ASSEMBLY_LINE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16]}; } @@ -112,11 +155,6 @@ public class GT_MetaTileEntity_AssemblyLine return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { if (GT_Values.D1) @@ -274,131 +312,21 @@ public class GT_MetaTileEntity_AssemblyLine } } + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mDataAccessHatches.clear(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (xDir != 0) { - for (int r = 0; r <= 16; r++) { - int i = r * xDir; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, 0, i); - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(0, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) == 10)) { - if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){ - return false; - } - } - if (!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) { - return false; - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i); - if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) { - if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i); - if (!addEnergyInputToMachineList(tTileEntity, 16)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) { - return false; - } - } - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, 0, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i) == 9)) { - return false; - } - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) == 5)) { - return false; - } - - - if (!(aBaseMetaTileEntity.getBlockOffset(xDir * 2, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, 0, i) == 10)) { - return false; - } - if (!aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) { - return false; - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i); - if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) { - return false; - } - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i); - if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) { - return r > 0 && !mEnergyHatches.isEmpty(); - } - } - } else { - for (int r = 0; r <= 16; r++) { - int i = r * -zDir; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 0, 0); - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, 0) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) == 10)) { - if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){ - return false; - } - } - if (!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")) { - return false; - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0); - if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) { - if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) { - return false; - } - } - - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir); - if (!addEnergyInputToMachineList(tTileEntity, 16)) { - if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) { - return false; - } - } - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir) == 9)) { - return false; - } - if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) == 5)) { - return false; - } - - - if (!(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir * 2) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir * 2) == 10)) { - return false; - } - if (!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2).getUnlocalizedName().equals("blockAlloyGlass")) { - return false; - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2); - if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) { - if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != GregTech_API.sBlockCasings2) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) { - return false; - } - } - tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir); - if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) { - return r > 0 && !mEnergyHatches.isEmpty(); - } - } + if (!checkPiece(STRUCTURE_PIECE_FIRST, 0, 1, 0)) + return false; + for (int i = 1; i < 16; i++) { + if (!checkPiece(i == 1 ? STRUCTURE_PIECE_SECOND : STRUCTURE_PIECE_LATER, -i, 1, 0)) + return false; + if (!mOutputBusses.isEmpty()) + return !mEnergyHatches.isEmpty() && mMaintenanceHatches.size() == 1; } return false; } @@ -443,6 +371,18 @@ public class GT_MetaTileEntity_AssemblyLine return false; } + private boolean addInputHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + return false; + } + @Override public int getMaxEfficiency(ItemStack aStack) { return 10000; @@ -462,4 +402,13 @@ public class GT_MetaTileEntity_AssemblyLine public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_FIRST, stackSize, hintsOnly, 0, 1, 0); + buildPiece(STRUCTURE_PIECE_SECOND, stackSize, hintsOnly, -1, 1, 0); + for (int i = 2; i < 16; i++) { + buildPiece(STRUCTURE_PIECE_LATER, stackSize, hintsOnly, -i, 1, 0); + } + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 8e54010ccb..bf2aeadcf8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -1,17 +1,19 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Recipe; @@ -23,25 +25,88 @@ 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.FluidStack; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW; - -public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity_MultiBlockBase { - +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity_EnhancedMultiBlockBase { + public static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + { + " ", + " ihi ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " i i ", + " h h ", + " i i ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " ihi ", + " ", + }, + { + " xhx ", + " hhccchh ", + " eccxhxcce ", + " eceh hece ", + " hce ech ", + " hch hch ", + "xcx xcx", + "hch hch", + "xcx xcx", + " hch hch ", + " hce ech ", + " eceh hece ", + " eccx~xcce ", + " hhccchh ", + " xhx ", + }, + { + " ", + " ihi ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " i i ", + " h h ", + " i i ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " ihi ", + " ", + } + })) + .addElement('c', defer(t -> ofBlock(t.getFusionCoil(), t.getFusionCoilMeta()))) + .addElement('h', defer(t -> ofBlock(t.getCasing(), t.getCasingMeta()))) + .addElement('i', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addInjector, 53, 1, t.getCasing(), t.getCasingMeta()))) + .addElement('e', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addEnergyInjector, 53, 1, t.getCasing(), t.getCasingMeta()))) + .addElement('x', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addExtractor, 53, 1, t.getCasing(), t.getCasingMeta()))) + .build(); public GT_Recipe mLastRecipe; public int mEUStore; static { Textures.BlockIcons.setCasingTextureForId(52, TextureFactory.of( - TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW).glow().build() + TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW).extFacing().build(), + TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW).extFacing().glow().build() )); } @@ -87,56 +152,14 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity super.loadNBTData(aNBT); } + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xCenter = getBaseMetaTileEntity().getXCoord() + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX * 5; - int yCenter = getBaseMetaTileEntity().getYCoord(); - int zCenter = getBaseMetaTileEntity().getZCoord() + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ * 5; - if (((isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter)) || (xCenter + 5 == getBaseMetaTileEntity().getXCoord())) - && ((isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter)) || (xCenter - 5 == getBaseMetaTileEntity().getXCoord())) - && ((isAdvancedMachineCasing(xCenter, yCenter, zCenter + 5)) || (zCenter + 5 == getBaseMetaTileEntity().getZCoord())) - && ((isAdvancedMachineCasing(xCenter, yCenter, zCenter - 5)) || (zCenter - 5 == getBaseMetaTileEntity().getZCoord())) && (checkCoils(xCenter, yCenter, zCenter)) - && (checkHulls(xCenter, yCenter, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter + 1, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter - 1, zCenter)) - && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 3, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 5, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 3, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 5, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter + 3, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter + 4, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter + 5, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter + 4, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter + 3, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter - 4, aBaseMetaTileEntity)) - && (addIfEnergyInjector(xCenter + 5, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter - 4, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter + 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 5, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter - 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 5, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter + 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 7, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter - 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 7, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter + 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 5, yCenter, zCenter + 1, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter - 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 5, yCenter, zCenter + 1, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter + 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 7, yCenter, zCenter + 1, aBaseMetaTileEntity)) - && (addIfExtractor(xCenter - 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 7, yCenter, zCenter + 1, aBaseMetaTileEntity)) - && (addIfInjector(xCenter + 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity)) - && (addIfInjector(xCenter + 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity)) - && (addIfInjector(xCenter - 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity)) - && (this.mEnergyHatches.size() >= 1) && (this.mOutputHatches.size() >= 1) && (this.mInputHatches.size() >= 2)) { - int mEnergyHatches_sS = this.mEnergyHatches.size(); - for (GT_MetaTileEntity_Hatch_Energy mEnergyHatch : this.mEnergyHatches) { - if (mEnergyHatch.mTier < tier()) - return false; - } - int mOutputHatches_sS = this.mOutputHatches.size(); - for (GT_MetaTileEntity_Hatch_Output mOutputHatch : this.mOutputHatches) { - if (mOutputHatch.mTier < tier()) - return false; - } - int mInputHatches_sS = this.mInputHatches.size(); - for (GT_MetaTileEntity_Hatch_Input mInputHatch : this.mInputHatches) { - if (mInputHatch.mTier < tier()) - return false; - } + if (checkPiece(STRUCTURE_PIECE_MAIN, 7, 1, 12) && mInputHatches.size() > 1 && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty()) { mWrench = true; mScrewdriver = true; mSoftHammer = true; @@ -148,97 +171,51 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity return false; } - private boolean checkTier(byte tier, ArrayList list) { - if (list != null) { - int list_sS=list.size(); - for (GT_MetaTileEntity_Hatch gt_metaTileEntity_hatch : list) { - if (gt_metaTileEntity_hatch.mTier < tier) { - return false; - } - } - } - return true; - } - - private boolean checkCoils(int aX, int aY, int aZ) { - return (isFusionCoil(aX + 6, aY, aZ - 1)) && (isFusionCoil(aX + 6, aY, aZ)) && (isFusionCoil(aX + 6, aY, aZ + 1)) && (isFusionCoil(aX + 5, aY, aZ - 3)) && (isFusionCoil(aX + 5, aY, aZ - 2)) - && (isFusionCoil(aX + 5, aY, aZ + 2)) && (isFusionCoil(aX + 5, aY, aZ + 3)) && (isFusionCoil(aX + 4, aY, aZ - 4)) && (isFusionCoil(aX + 4, aY, aZ + 4)) - && (isFusionCoil(aX + 3, aY, aZ - 5)) && (isFusionCoil(aX + 3, aY, aZ + 5)) && (isFusionCoil(aX + 2, aY, aZ - 5)) && (isFusionCoil(aX + 2, aY, aZ + 5)) - && (isFusionCoil(aX + 1, aY, aZ - 6)) && (isFusionCoil(aX + 1, aY, aZ + 6)) && (isFusionCoil(aX, aY, aZ - 6)) && (isFusionCoil(aX, aY, aZ + 6)) && (isFusionCoil(aX - 1, aY, aZ - 6)) - && (isFusionCoil(aX - 1, aY, aZ + 6)) && (isFusionCoil(aX - 2, aY, aZ - 5)) && (isFusionCoil(aX - 2, aY, aZ + 5)) && (isFusionCoil(aX - 3, aY, aZ - 5)) - && (isFusionCoil(aX - 3, aY, aZ + 5)) && (isFusionCoil(aX - 4, aY, aZ - 4)) && (isFusionCoil(aX - 4, aY, aZ + 4)) && (isFusionCoil(aX - 5, aY, aZ - 3)) - && (isFusionCoil(aX - 5, aY, aZ - 2)) && (isFusionCoil(aX - 5, aY, aZ + 2)) && (isFusionCoil(aX - 5, aY, aZ + 3)) && (isFusionCoil(aX - 6, aY, aZ - 1)) - && (isFusionCoil(aX - 6, aY, aZ)) && (isFusionCoil(aX - 6, aY, aZ + 1)); - } - - private boolean checkUpperOrLowerHulls(int aX, int aY, int aZ) { - return (isAdvancedMachineCasing(aX + 6, aY, aZ)) && (isAdvancedMachineCasing(aX + 5, aY, aZ - 3)) && (isAdvancedMachineCasing(aX + 5, aY, aZ - 2)) - && (isAdvancedMachineCasing(aX + 5, aY, aZ + 2)) && (isAdvancedMachineCasing(aX + 5, aY, aZ + 3)) && (isAdvancedMachineCasing(aX + 4, aY, aZ - 4)) - && (isAdvancedMachineCasing(aX + 4, aY, aZ + 4)) && (isAdvancedMachineCasing(aX + 3, aY, aZ - 5)) && (isAdvancedMachineCasing(aX + 3, aY, aZ + 5)) - && (isAdvancedMachineCasing(aX + 2, aY, aZ - 5)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 5)) && (isAdvancedMachineCasing(aX, aY, aZ - 6)) - && (isAdvancedMachineCasing(aX, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 5)) && (isAdvancedMachineCasing(aX - 2, aY, aZ + 5)) - && (isAdvancedMachineCasing(aX - 3, aY, aZ - 5)) && (isAdvancedMachineCasing(aX - 3, aY, aZ + 5)) && (isAdvancedMachineCasing(aX - 4, aY, aZ - 4)) - && (isAdvancedMachineCasing(aX - 4, aY, aZ + 4)) && (isAdvancedMachineCasing(aX - 5, aY, aZ - 3)) && (isAdvancedMachineCasing(aX - 5, aY, aZ - 2)) - && (isAdvancedMachineCasing(aX - 5, aY, aZ + 2)) && (isAdvancedMachineCasing(aX - 5, aY, aZ + 3)) && (isAdvancedMachineCasing(aX - 6, aY, aZ)); - } - - private boolean checkHulls(int aX, int aY, int aZ) { - return (isAdvancedMachineCasing(aX + 6, aY, aZ - 3)) && (isAdvancedMachineCasing(aX + 6, aY, aZ - 2)) && (isAdvancedMachineCasing(aX + 6, aY, aZ + 2)) - && (isAdvancedMachineCasing(aX + 6, aY, aZ + 3)) && (isAdvancedMachineCasing(aX + 3, aY, aZ - 6)) && (isAdvancedMachineCasing(aX + 3, aY, aZ + 6)) - && (isAdvancedMachineCasing(aX + 2, aY, aZ - 6)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 6)) - && (isAdvancedMachineCasing(aX - 2, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 3, aY, aZ - 6)) && (isAdvancedMachineCasing(aX - 3, aY, aZ + 6)) - && (isAdvancedMachineCasing(aX - 7, aY, aZ)) && (isAdvancedMachineCasing(aX + 7, aY, aZ)) && (isAdvancedMachineCasing(aX, aY, aZ - 7)) && (isAdvancedMachineCasing(aX, aY, aZ + 7)) - && (isAdvancedMachineCasing(aX - 6, aY, aZ - 3)) && (isAdvancedMachineCasing(aX - 6, aY, aZ - 2)) && (isAdvancedMachineCasing(aX - 6, aY, aZ + 2)) - && (isAdvancedMachineCasing(aX - 6, aY, aZ + 3)) && (isAdvancedMachineCasing(aX - 4, aY, aZ - 2)) && (isAdvancedMachineCasing(aX - 4, aY, aZ + 2)) - && (isAdvancedMachineCasing(aX + 4, aY, aZ - 2)) && (isAdvancedMachineCasing(aX + 4, aY, aZ + 2)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 4)) - && (isAdvancedMachineCasing(aX - 2, aY, aZ + 4)) && (isAdvancedMachineCasing(aX + 2, aY, aZ - 4)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 4)); - } - - private boolean addIfEnergyInjector(int aX, int aY, int aZ, IGregTechTileEntity aBaseMetaTileEntity) { - if (addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { - return true; - } - return isAdvancedMachineCasing(aX, aY, aZ); - } - - private boolean addIfInjector(int aX, int aY, int aZ, IGregTechTileEntity aTileEntity) { - if (addInputToMachineList(aTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { - return true; - } - return isAdvancedMachineCasing(aX, aY, aZ); + private boolean addEnergyInjector(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy)) return false; + GT_MetaTileEntity_Hatch_Energy tHatch = (GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity; + if (tHatch.mTier < tier()) return false; + tHatch.updateTexture(aBaseCasingIndex); + return mEnergyHatches.add(tHatch); } - private boolean addIfExtractor(int aX, int aY, int aZ, IGregTechTileEntity aTileEntity) { - if (addOutputToMachineList(aTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { - return true; - } - return isAdvancedMachineCasing(aX, aY, aZ); + private boolean addInjector(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input)) return false; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + if (tHatch.mTier < tier()) return false; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mInputHatches.add(tHatch); } - private boolean isAdvancedMachineCasing(int aX, int aY, int aZ) { - return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasing()) && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()); + private boolean addExtractor(IGregTechTileEntity aBaseMetaTileEntity, int aBaseCasingIndex) { + if (aBaseMetaTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output)) return false; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + if (tHatch.mTier < tier()) return false; + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatches.add(tHatch); } public abstract Block getCasing(); public abstract int getCasingMeta(); - private boolean isFusionCoil(int aX, int aY, int aZ) { - return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getFusionCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getFusionCoilMeta())); - } - public abstract Block getFusionCoil(); public abstract int getFusionCoilMeta(); - @Override - public abstract String[] getDescription(); - @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[]{TextureFactory.of(MACHINE_CASING_FUSION_GLASS), getTextureOverlay()}; + if (aSide == aFacing) return new ITexture[]{TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS).extFacing().build(), getTextureOverlay()}; if (aActive) return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(52)}; - return new ITexture[]{TextureFactory.of(MACHINE_CASING_FUSION_GLASS)}; + return new ITexture[]{TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS).extFacing().build()}; } /** @@ -477,4 +454,9 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity public boolean isGivingInformation() { return true; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 7, 1, 12); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java index 39b78c68bd..fd55bf715b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -62,7 +62,7 @@ public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionC } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Fusion Reactor") .addInfo("It's over 9000!!!") @@ -81,11 +81,7 @@ public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionC .addOutputHatch("1-16, Specified casings") .addStructureInfo("ALL Hatches must be LuV or better") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java index 2ffa8ba4e1..890b43cc7a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -7,7 +7,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION2; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION2_GLOW; @@ -62,7 +61,7 @@ public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionC } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Fusion Reactor") .addInfo("It's over 9000!!!") @@ -81,11 +80,7 @@ public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionC .addOutputHatch("1-16, Specified casings") .addStructureInfo("ALL Hatches must be ZPM or better") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java index e8ae396954..0a3bc89d20 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -62,7 +62,7 @@ public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionC } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Fusion Reactor") .addInfo("A SUN DOWN ON EARTH") @@ -81,11 +81,7 @@ public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionC .addOutputHatch("1-16, Specified casings") .addStructureInfo("ALL Hatches must be UV or better") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 41184a17ac..9ad84d061a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; @@ -7,11 +9,10 @@ import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -21,19 +22,61 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.mutable.MutableBoolean; -import org.lwjgl.input.Keyboard; +import net.minecraftforge.oredict.OreDictionary; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { +public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMultiBlockBase { private HeatingCoilLevel coilHeat; //public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0, Dyes.MACHINE_METAL.mRGBa); private static final int CASING_INDEX = 1090; + private static final IStructureDefinition STRUCTURE_DEFINITION = createStructureDefinition(); + + private static IStructureDefinition createStructureDefinition() { + Block casingBlock; + int casingMeta; + + if (Loader.isModLoaded("dreamcraft")) { + casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH"); + casingMeta = 2; + } else { + casingBlock = GregTech_API.sBlockCasings1; + casingMeta = 0; + } + return StructureDefinition.builder() + .addShape("main", transpose(new String[][]{ + {"ccccc", "ctttc", "ctttc", "ctttc", "ccccc"}, + {"ccccc", "c---c", "c---c", "c---c", "ccccc"}, + {"ccccc", "c---c", "c---c", "c---c", "ccccc"}, + {"bb~bb", "bCCCb", "bCCCb", "bCCCb", "bbbbb"}, + })) + .addElement('c', onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta))) + .addElement('C', ofCoil(GT_MetaTileEntity_PyrolyseOven::setCoilLevel, GT_MetaTileEntity_PyrolyseOven::getCoilLevel)) + .addElement('b', ofChain( + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta)) + )) + .addElement('t', ofChain( + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMufflerToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta)) + )) + .build(); + } + + private int mCasingAmount; public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -44,7 +87,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Coke Oven") .addInfo("Controller block for the Pyrolyse Oven") @@ -66,11 +109,7 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock .addOutputBus("Any bottom layer casing") .addOutputHatch("Any bottom layer casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -79,12 +118,12 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock if (aActive) return new ITexture[]{ BlockIcons.casingTexturePages[8][66], - TextureFactory.of(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.casingTexturePages[8][66], - TextureFactory.of(OVERLAY_FRONT_PYROLYSE_OVEN), - TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_PYROLYSE_OVEN_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[8][66]}; } @@ -128,156 +167,28 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - Block casingBlock; - int casingMeta; - - if (Loader.isModLoaded("dreamcraft")) { - casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH"); - casingMeta = 2; - } else { - casingBlock = GregTech_API.sBlockCasings1; - casingMeta = 0; - } - - replaceDeprecatedCoils(aBaseMetaTileEntity); - MutableBoolean firstCoil = new MutableBoolean(true); - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// inner 3x3 without height - if (checkInnerBroken( - xDir, zDir, - i, h, j, - aBaseMetaTileEntity, tTileEntity, - casingBlock, casingMeta, - firstCoil - ) - ) - return false; - } else {// outer 5x5 without height - if (checkOuterBroken( - xDir, zDir, - i, h, j, - aBaseMetaTileEntity, tTileEntity, - casingBlock, casingMeta - ) - ) - return false; - } - } - } - } - return true; + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; } - private boolean checkInnerBroken(int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - IGregTechTileEntity tTileEntity, - Block casingBlock, - int casingMeta, - MutableBoolean firstCoil - ) { - if (b == 0) {// inner floor (Coils) - return areCoilsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, firstCoil); - } else if (b == 3) {// inner ceiling (ulv casings + input + muffler) - return checkInnerCeilingBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, tTileEntity, casingBlock, casingMeta); - } else {// inside air - return !aBaseMetaTileEntity.getAirOffset(xDir + a, b, zDir + c); - } - } - - private boolean checkOuterBroken(int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - IGregTechTileEntity tTileEntity, - Block casingBlock, - int casingMeta) { - if (b == 0) {// outer floor (controller, output, energy, maintainance, rest ulv casings) - if (checkOuterFloorLoopControl(xDir, zDir, a, c, tTileEntity)) - return false; - } - // outer above floor (ulv casings) - if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) { - return true; - } - return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta; + private void onCasingAdded() { + mCasingAmount++; } - private boolean checkOuterFloorLoopControl(int xDir, - int zDir, - int a, - int c, - IGregTechTileEntity tTileEntity - ) { - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { - return true; - } - if (addOutputToMachineList(tTileEntity, CASING_INDEX)) { - return true; - } - - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) { - return true; - } - - return (xDir + a == 0) && (zDir + c == 0); + public HeatingCoilLevel getCoilLevel() { + return coilHeat; } - private boolean checkInnerCeilingBroken(int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - IGregTechTileEntity tTileEntity, - Block casingBlock, - int casingMeta) { - if ((addInputToMachineList(tTileEntity, CASING_INDEX)) || (addMufflerToMachineList(tTileEntity, CASING_INDEX))) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c) != casingBlock) { - return true; - } - return aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c) != casingMeta; + private void setCoilLevel(HeatingCoilLevel aCoilLevel) { + coilHeat = aCoilLevel; } - private boolean areCoilsBroken(int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableBoolean firstCoil - ) { - Block coil = aBaseMetaTileEntity.getBlockOffset(xDir + a, b, zDir + c); - - if (!(coil instanceof IHeatingCoil)) - return true; - - int metaID = aBaseMetaTileEntity.getMetaIDOffset(xDir + a, b, zDir + c); - - HeatingCoilLevel coilHeat = ((IHeatingCoil) coil).getCoilHeat(metaID); - - if (coilHeat == HeatingCoilLevel.None) { - return true; - } else { - if (firstCoil.isTrue()) { - this.coilHeat = coilHeat; - firstCoil.setFalse(); - } else return coilHeat != this.coilHeat; - } - return false; + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + coilHeat = HeatingCoilLevel.None; + mCasingAmount = 0; + replaceDeprecatedCoils(aBaseMetaTileEntity); + return checkPiece("main", 2, 3, 0) && mCasingAmount >= 60; } @Override @@ -325,4 +236,9 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlock } } } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece("main", stackSize, hintsOnly, 2, 3, 0); + } } -- cgit From 05c9015847ed770492152f93dee6beae45e61b4e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 11 Jun 2021 03:09:49 +0800 Subject: Fix rebase derp Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 3 +-- .../tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 8e06207267..3a2fc8b50f 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -26,6 +26,7 @@ import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.net.GT_Packet_ClientPreference; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ClientPreference; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_PlayedSound; import gregtech.api.util.GT_Recipe; @@ -46,7 +47,6 @@ import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -56,7 +56,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 8916c9f42a..f1bfbe80f0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -354,7 +354,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En } @Override - public IStructureDefinition getStructureDefinition() { + public final IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; } -- cgit From 6ea3101f0b5604f3f9260a41af6ef1848355c95f Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 15 Jun 2021 02:16:40 +0800 Subject: use TT serialization form Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index e4bfef4a48..e871146d4b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -127,16 +127,16 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase Date: Wed, 16 Jun 2021 11:05:12 +0800 Subject: optimize fuel recipe lookup Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_BasicGenerator.java | 27 +++++----- src/main/java/gregtech/api/util/GT_Recipe.java | 23 +++++++++ .../multi/GT_MetaTileEntity_DieselEngine.java | 57 ++++++++++------------ .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 10 ++-- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 10 ++-- .../postload/GT_ExtremeDieselFuelLoader.java | 13 ++--- 6 files changed, 72 insertions(+), 68 deletions(-) (limited to 'src') 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 9bbfbf0a3a..63151bde59 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 @@ -18,8 +18,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -import java.util.Collection; - import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank { @@ -271,19 +269,18 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public int getFuelValue(FluidStack aLiquid) { //System.out.println("Fluid stack check"); - if (aLiquid == null || getRecipes() == null) return 0; - FluidStack tLiquid; - Collection tRecipeList = getRecipes().mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)){ - long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid) / 100; - if(val> Integer.MAX_VALUE){ - throw new ArithmeticException("Integer LOOPBACK!"); - } - return (int) val; - } - return 0; + 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; + } + long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(aLiquid) / 100; + if(val> Integer.MAX_VALUE){ + throw new ArithmeticException("Integer LOOPBACK!"); + } + return (int) val; } public int getFuelValue(ItemStack aStack) { diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index a04df205b7..a5b263a145 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -197,6 +197,11 @@ public class GT_Recipe implements Comparable { this(aInput1, aOutput1, null, null, null, aFuelValue, aType); } + private static FluidStack[] tryGetFluidInputsFromCells(ItemStack aInput) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + return tFluid == null ? null : new FluidStack[] {tFluid}; + } + // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000! public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) { this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue)); @@ -977,6 +982,7 @@ public class GT_Recipe implements Comparable { * Just a Recipe Map with Utility specifically for Fuels. */ public static class GT_Recipe_Map_Fuel extends GT_Recipe_Map { + private final Map mRecipesByFluidInput = new HashMap<>(); public GT_Recipe_Map_Fuel(Collection aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); } @@ -1000,6 +1006,23 @@ public class GT_Recipe implements Comparable { public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) { return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU); } + + @Override + public GT_Recipe add(GT_Recipe aRecipe) { + aRecipe = super.add(aRecipe); + if (aRecipe.mInputs != null && aRecipe.mInputs.length == 1 && (aRecipe.mFluidInputs == null || aRecipe.mFluidInputs.length == 0)) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aRecipe.mInputs[0], true); + if (tFluid != null) { + tFluid.amount = 0; + mRecipesByFluidInput.put(tFluid.getUnlocalizedName(), aRecipe); + } + } + return aRecipe; + } + + public GT_Recipe findFuel(FluidStack aFluidInput) { + return mRecipesByFluidInput.get(aFluidInput.getUnlocalizedName()); + } } /** diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 1783a0c328..567297648a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -14,7 +14,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffl import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -24,7 +23,6 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Collection; import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; @@ -160,34 +158,30 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tFluids = getStoredFluids(); - Collection tRecipeList = getFuelMap().mRecipeList; - - if(!tFluids.isEmpty() && tRecipeList != null) { //Does input hatch have a diesel fuel? - for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches - for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes - FluidStack tLiquid; - if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null) { //Create fluidstack from current recipe - if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a diesel fluid - fuelConsumption = tLiquid.amount = boostEu ? (getBoostFactor() * getNominalOutput() / aFuel.mSpecialValue) : (getNominalOutput() / aFuel.mSpecialValue); //Calc fuel consumption - if(depleteInput(tLiquid)) { //Deplete that amount - boostEu = depleteInput(getBooster().getGas(2L * getAdditiveFactor())); - - if(tFluids.contains(Materials.Lubricant.getFluid(1L))) { //Has lubricant? - //Deplete Lubricant. 1000L should = 1 hour of runtime (if baseEU = 2048) - if(mRuntime % 72 == 0 || mRuntime == 0) depleteInput(Materials.Lubricant.getFluid((boostEu ? 2L : 1L) * getAdditiveFactor())); - } else return false; - - fuelValue = aFuel.mSpecialValue; - fuelRemaining = hatchFluid1.amount; //Record available fuel - this.mEUt = mEfficiency < 2000 ? 0 : getNominalOutput(); //Output 0 if startup is less than 20% - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = getEfficiencyIncrease(); - return true; - } - } - } - } + + // fast track lookup + if (!tFluids.isEmpty()) { + for (FluidStack tFluid : tFluids) { + GT_Recipe tRecipe = getFuelMap().findFuel(tFluid); + if (tRecipe == null) continue; + + FluidStack tLiquid = tFluid.copy(); + fuelConsumption = tLiquid.amount = boostEu ? (getBoostFactor() * getNominalOutput() / tRecipe.mSpecialValue) : (getNominalOutput() / tRecipe.mSpecialValue); //Calc fuel consumption + //Deplete that amount + if (!depleteInput(tLiquid)) return false; + boostEu = depleteInput(getBooster().getGas(2L * getAdditiveFactor())); + + //Deplete Lubricant. 1000L should = 1 hour of runtime (if baseEU = 2048) + if ((mRuntime % 72 == 0 || mRuntime == 0) && !depleteInput(Materials.Lubricant.getFluid((boostEu ? 2L : 1L) * getAdditiveFactor()))) + return false; + + fuelValue = tRecipe.mSpecialValue; + fuelRemaining = tFluid.amount; //Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : getNominalOutput(); //Output 0 if startup is less than 20% + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = getEfficiencyIncrease(); + return true; } } this.mEUt = 0; @@ -195,6 +189,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu return false; } + @Override public IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; @@ -299,7 +294,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu getIdealStatus() == getRepairStatus() ? EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(-mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t", + StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t", StatCollector.translateToLocal("GT5U.engine.consumption")+": " +EnumChatFormatting.YELLOW+fuelConsumption+EnumChatFormatting.RESET+" L/t", StatCollector.translateToLocal("GT5U.engine.value")+": " +EnumChatFormatting.YELLOW+fuelValue+EnumChatFormatting.RESET+" EU/L", StatCollector.translateToLocal("GT5U.turbine.fuel")+": " +EnumChatFormatting.GOLD+fuelRemaining+EnumChatFormatting.RESET+" L", diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 214e0648c2..27e4bf7084 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Collection; import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS5; import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5; @@ -56,12 +55,9 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT } public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null || GT_Recipe_Map.sTurbineFuels == null) return 0; - FluidStack tLiquid; - Collection tRecipeList = GT_Recipe_Map.sTurbineFuels.mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)) return tFuel.mSpecialValue; + if (aLiquid == null) return 0; + GT_Recipe tFuel = GT_Recipe_Map.sTurbineFuels.findFuel(aLiquid); + if (tFuel != null) return tFuel.mSpecialValue; return 0; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index efc3ecaea3..d1bf1e7c0b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -22,7 +22,6 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Collection; import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; @@ -63,12 +62,9 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar } public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null || GT_Recipe_Map.sTurbineFuels == null) return 0; - FluidStack tLiquid; - Collection tRecipeList = GT_Recipe_Map.sPlasmaFuels.mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)) return tFuel.mSpecialValue; + if (aLiquid == null) return 0; + GT_Recipe tFuel = GT_Recipe_Map.sPlasmaFuels.findFuel(aLiquid); + if (tFuel != null) return tFuel.mSpecialValue; return 0; } diff --git a/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java b/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java index dcb76ae17b..d85a47e3c9 100644 --- a/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_ExtremeDieselFuelLoader.java @@ -3,7 +3,6 @@ package gregtech.loaders.postload; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import net.minecraftforge.fluids.FluidStack; public class GT_ExtremeDieselFuelLoader implements Runnable { @@ -11,13 +10,11 @@ public class GT_ExtremeDieselFuelLoader implements Runnable { public void run() { GT_Log.out.println("GT_Mod: Adding extreme diesel fuel."); FluidStack tHOGStack = Materials.GasolinePremium.getFluid(1); - for (GT_Recipe tFuel : GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList) { - FluidStack tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true); - if (tLiquid != null && tHOGStack.isFluidEqual(tLiquid)) { - GT_Recipe.GT_Recipe_Map.sExtremeDieselFuels.add(tFuel); - return; - } + GT_Recipe tFuel = GT_Recipe.GT_Recipe_Map.sDieselFuels.findFuel(tHOGStack); + if (tFuel != null) { + GT_Recipe.GT_Recipe_Map.sExtremeDieselFuels.add(tFuel); + } else { + GT_Log.out.println("GT_Mod: No extreme diesel fuel found."); } - GT_Log.out.println("GT_Mod: No extreme diesel fuel found."); } } -- cgit From 62f04c2893a66c4f80383da1a973fad4708171d4 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:15:18 +0800 Subject: draw flipped textures & flipping markers Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- build.properties | 2 +- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 4 +- src/main/java/gregtech/common/GT_Client.java | 66 +++++++++++++++--- .../gregtech/common/render/GT_IconFlipped.java | 80 ++++++++++++++++++++++ .../gregtech/common/render/GT_RenderedTexture.java | 20 ++++-- 5 files changed, 154 insertions(+), 18 deletions(-) create mode 100644 src/main/java/gregtech/common/render/GT_IconFlipped.java (limited to 'src') diff --git a/build.properties b/build.properties index 8392f3c2a1..e4f67386b8 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 gt.version=5.09.37.02 -structurelib.version=1.0.1 +structurelib.version=1.0.2 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index e871146d4b..76dbca86b1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -75,7 +75,9 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase 0) { - drawGrid(aEvent, true); + drawGrid(aEvent, true, false, true); return; } return; @@ -538,7 +586,7 @@ public class GT_Client extends GT_Proxy if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) - drawGrid(aEvent, true); + drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } } diff --git a/src/main/java/gregtech/common/render/GT_IconFlipped.java b/src/main/java/gregtech/common/render/GT_IconFlipped.java new file mode 100644 index 0000000000..c3eee2900f --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_IconFlipped.java @@ -0,0 +1,80 @@ +package gregtech.common.render; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; + +@SideOnly(Side.CLIENT) +public class GT_IconFlipped implements IIcon { + private final IIcon baseIcon; + private final boolean flipU; + private final boolean flipV; + + public GT_IconFlipped(IIcon baseIcon, boolean flipU, boolean flipV) { + this.baseIcon = baseIcon; + this.flipU = flipU; + this.flipV = flipV; + } + + /** + * Returns the width of the icon, in pixels. + */ + public int getIconWidth() { + return this.baseIcon.getIconWidth(); + } + + /** + * Returns the height of the icon, in pixels. + */ + public int getIconHeight() { + return this.baseIcon.getIconHeight(); + } + + /** + * Returns the minimum U coordinate to use when rendering with this icon. + */ + public float getMinU() { + return this.flipU ? this.baseIcon.getMaxU() : this.baseIcon.getMinU(); + } + + /** + * Returns the maximum U coordinate to use when rendering with this icon. + */ + public float getMaxU() { + return this.flipU ? this.baseIcon.getMinU() : this.baseIcon.getMaxU(); + } + + /** + * Gets a U coordinate on the icon. 0 returns uMin and 16 returns uMax. Other arguments return in-between values. + */ + public float getInterpolatedU(double p_94214_1_) { + float f = this.getMaxU() - this.getMinU(); + return this.getMinU() + f * ((float) p_94214_1_ / 16.0F); + } + + /** + * Returns the minimum V coordinate to use when rendering with this icon. + */ + public float getMinV() { + return this.flipV ? this.baseIcon.getMaxV() : this.baseIcon.getMinV(); + } + + /** + * Returns the maximum V coordinate to use when rendering with this icon. + */ + public float getMaxV() { + return this.flipV ? this.baseIcon.getMinV() : this.baseIcon.getMaxV(); + } + + /** + * Gets a V coordinate on the icon. 0 returns vMin and 16 returns vMax. Other arguments return in-between values. + */ + public float getInterpolatedV(double p_94207_1_) { + float f = this.getMaxV() - this.getMinV(); + return this.getMinV() + f * ((float) p_94207_1_ / 16.0F); + } + + public String getIconName() { + return this.baseIcon.getIconName(); + } +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index 135ebf28c6..e35e2dbb6b 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -2,6 +2,7 @@ package gregtech.common.render; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import gregtech.GT_Mod; import gregtech.api.interfaces.IColorModulationContainer; @@ -12,7 +13,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.LightingHelper; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IconFlipped; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; @@ -225,7 +225,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYNeg(Blocks.air, x, y, z, new IconFlipped(icon, !stdOrient, false)); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateBottom = 0; } @@ -249,7 +250,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateTop = 0; } @@ -274,7 +276,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateEast = 0; aRenderer.field_152631_f = false; } @@ -299,7 +302,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateWest = 0; } @@ -323,7 +327,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateNorth = 0; } @@ -348,7 +353,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateSouth = 0; aRenderer.field_152631_f = false; } -- cgit From a47c5003192c87f6960d490abedd1e342acb56bd Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:33:53 +0800 Subject: make fuel recipe map index building a bit more robust Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_Recipe.java | 3 ++- src/main/java/gregtech/api/util/GT_Utility.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index a5b263a145..19f46dfd15 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1010,7 +1010,8 @@ public class GT_Recipe implements Comparable { @Override public GT_Recipe add(GT_Recipe aRecipe) { aRecipe = super.add(aRecipe); - if (aRecipe.mInputs != null && aRecipe.mInputs.length == 1 && (aRecipe.mFluidInputs == null || aRecipe.mFluidInputs.length == 0)) { + if (aRecipe.mInputs != null && GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 1 && + (aRecipe.mFluidInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 0)) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(aRecipe.mInputs[0], true); if (tFluid != null) { tFluid.amount = 0; diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index c7cee8c9c2..bb2c644f95 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2884,4 +2884,8 @@ public class GT_Utility { dropItem.delayBeforeCanPickup = 0; } } + + public static long getNonnullElementCount(Object[] tArray) { + return Arrays.stream(tArray).filter(Objects::nonNull).count(); + } } -- cgit From cb5c00dbf4100abfec238fd52722e9dfe60292e1 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 16 Jun 2021 17:45:04 +0800 Subject: turn off flipping as it bothers some people too much Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 2 +- .../tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java | 6 +++++- .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 2 +- .../tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../machines/multi/GT_MetaTileEntity_HeatExchanger.java | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 76dbca86b1..5897de8f68 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -123,7 +123,7 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase f.isNotFlipped(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 4c294aadfe..5d363d9aa1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -322,8 +322,12 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu mDataAccessHatches.clear(); if (!checkPiece(STRUCTURE_PIECE_FIRST, 0, 1, 0)) return false; + return checkMachine(true) || checkMachine(false); + } + + private boolean checkMachine(boolean leftToRight) { for (int i = 1; i < 16; i++) { - if (!checkPiece(i == 1 ? STRUCTURE_PIECE_SECOND : STRUCTURE_PIECE_LATER, -i, 1, 0)) + if (!checkPiece(i == 1 ? STRUCTURE_PIECE_SECOND : STRUCTURE_PIECE_LATER, leftToRight ? -i : i, 1, 0)) return false; if (!mOutputBusses.isEmpty()) return !mEnergyHatches.isEmpty() && mMaintenanceHatches.size() == 1; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index ff7b801b15..ef77ab10c2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -200,7 +200,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan @Override protected IAlignmentLimits getInitialAlignmentLimits() { // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index f1bfbe80f0..676da3d7ac 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -350,7 +350,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En @Override protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 0579c4871b..c820731415 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -136,7 +136,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedM @Override protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> !r.isUpsideDown(); + return (d, r, f) -> !r.isUpsideDown() && f.isNotFlipped(); } @Override -- cgit From 5bd3126615e09906d4bf769c063cedea68e10d43 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 16 Jun 2021 18:00:35 +0800 Subject: Allow modifying alignment limits after instance initialization Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 5897de8f68..e4169c58be 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray; public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment, IConstructable { private static final AtomicReferenceArray tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length); private ExtendedFacing mExtendedFacing = ExtendedFacing.DEFAULT; - private final IAlignmentLimits mLimits = getInitialAlignmentLimits(); + private IAlignmentLimits mLimits = getInitialAlignmentLimits(); protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -94,6 +94,10 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase getStructureDefinition(); protected abstract GT_Multiblock_Tooltip_Builder createTooltip(); -- cgit From 0759229d6b533bd040da8abb3f1f036ef7f87e75 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 17 Jun 2021 18:41:40 +0800 Subject: open up some fields in EBF to make bartworks happy Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 22171e6e04..7c992e7c1e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -42,8 +42,8 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_AbstractMultiFurnace implements IConstructable { private int mHeatingCapacity = 0; - private final ArrayList mPollutionOutputHatches = new ArrayList<>(); - private final FluidStack[] pollutionFluidStacks = {Materials.CarbonDioxide.getGas(1000), + protected final ArrayList mPollutionOutputHatches = new ArrayList<>(); + protected final FluidStack[] pollutionFluidStacks = {Materials.CarbonDioxide.getGas(1000), Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000)}; private static final int CASING_INDEX = 11; -- cgit From bf056ef6a134d63de48642d5830da216babff9cc Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 17 Jun 2021 21:27:28 +0800 Subject: Fix coil structure checks Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_StructureUtility.java | 2 +- .../machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 2 +- .../tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 1db672245c..2670d9e684 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -122,7 +122,7 @@ public class GT_StructureUtility { return false; HeatingCoilLevel existingLevel = heatingCoilGetter.apply(t), newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); - if (existingLevel == null) { + if (existingLevel == null || existingLevel == HeatingCoilLevel.None) { return heatingCoilSetter.test(t, newLevel); } else { return newLevel == existingLevel; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 7c992e7c1e..7b31553253 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -265,7 +265,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false; - if (getCoilLevel() == null) + if (getCoilLevel() == HeatingCoilLevel.None) return false; if (mMaintenanceHatches.size() != 1) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 20ef0fa6e7..ba77716622 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -181,7 +181,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0)) return false; - if (getCoilLevel() == null) + if (getCoilLevel() == HeatingCoilLevel.None) return false; this.mLevel = getCoilLevel().getLevel(); -- cgit From 9a24e6a7d063149d3f2c4a2545c0e392ce25dbf8 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 17 Jun 2021 21:59:32 +0800 Subject: loosen access control even more to make bartworks happy Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../multi/GT_MetaTileEntity_DistillationTower.java | 16 ++++++++-------- .../multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index ef77ab10c2..64c7bd7535 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -35,7 +35,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_EnhancedMultiBlockBase { - private static final int CASING_INDEX = 49; + protected static final int CASING_INDEX = 49; protected static final String STRUCTURE_PIECE_BASE = "base"; protected static final String STRUCTURE_PIECE_LAYER = "layer"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() @@ -63,10 +63,10 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan isAir() )) .build(); - private final List> mOutputHatchesByLayer = new ArrayList<>(); - private int mHeight; - private int mCasing; - private boolean mTopLayerFound; + protected final List> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; public GT_MetaTileEntity_DistillationTower(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -178,16 +178,16 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan return false; } - private void onCasingFound() { + protected void onCasingFound() { mCasing++; } - private void onTopLayerFound() { + protected void onTopLayerFound() { mTopLayerFound = true; onCasingFound(); } - private boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) return false; while (mOutputHatchesByLayer.size() < mHeight + 1) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 7b31553253..23c6685d8a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -46,8 +46,8 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab protected final FluidStack[] pollutionFluidStacks = {Materials.CarbonDioxide.getGas(1000), Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000)}; - private static final int CASING_INDEX = 11; - private static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final int CASING_INDEX = 11; + protected static final String STRUCTURE_PIECE_MAIN = "main"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ {"ttt", "tmt", "ttt"}, -- cgit From d80698def4c2c6fe6ee7875e08836563c630271c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 17 Jun 2021 23:28:54 +0800 Subject: fix distillation tower not outputting bottom fluid Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 5 +++++ .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index e4169c58be..597a645699 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -98,6 +98,11 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase getStructureDefinition(); protected abstract GT_Multiblock_Tooltip_Builder createTooltip(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 64c7bd7535..11e7ec0d6d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -190,11 +190,11 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) return false; - while (mOutputHatchesByLayer.size() < mHeight + 1) + while (mOutputHatchesByLayer.size() < mHeight) mOutputHatchesByLayer.add(new ArrayList<>()); GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); tHatch.updateTexture(aBaseCasingIndex); - return mOutputHatchesByLayer.get(mHeight).add(tHatch); + return mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); } @Override -- cgit From 3d5ac0c8953df1249b964335452d45ffee75c8a7 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 18 Jun 2021 00:19:14 +0800 Subject: re-enable flipping, but add an option to render them not flipped Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/GT_Mod.java | 1 + .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 2 +- src/main/java/gregtech/common/GT_Proxy.java | 5 +++++ src/main/java/gregtech/common/render/GT_RenderedTexture.java | 12 ++++++------ .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 2 +- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../machines/multi/GT_MetaTileEntity_HeatExchanger.java | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 278908b9a0..590f01292e 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -329,6 +329,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.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/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 597a645699..a9b50e6662 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -132,7 +132,7 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase f.isNotFlipped(); + return (d, r, f) -> !f.isVerticallyFliped(); } @Override diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index e35661a617..82dd4e3ba2 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -252,6 +252,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { */ public boolean mRenderGlowTextures = true; + /** + * Render flipped textures + */ + public boolean mRenderFlippedMachinesFlipped = 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/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index e35e2dbb6b..f456b563b5 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -226,7 +226,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : new GT_IconFlipped(icon, !stdOrient, false)); aRenderer.uvRotateBottom = 0; } @@ -251,7 +251,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateTop = 0; } @@ -277,7 +277,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateEast = 0; aRenderer.field_152631_f = false; } @@ -303,7 +303,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateWest = 0; } @@ -328,7 +328,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateNorth = 0; } @@ -354,7 +354,7 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { } Flip aFlip = extendedFacing.getFlip(); - aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); + aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateSouth = 0; aRenderer.field_152631_f = false; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 11e7ec0d6d..73bbfe056a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -200,7 +200,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan @Override protected IAlignmentLimits getInitialAlignmentLimits() { // don't rotate a freaking tower, it won't work - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 676da3d7ac..9bd2a66250 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -350,7 +350,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En @Override protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index c820731415..392726e13a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -136,7 +136,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedM @Override protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> !r.isUpsideDown() && f.isNotFlipped(); + return (d, r, f) -> !r.isUpsideDown() && !f.isVerticallyFliped(); } @Override -- cgit From 66e64ee13acd8ce0f4570c9ce73c849e125c67b9 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 17:32:39 +0800 Subject: fix turbine casing dynamic texture Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/common/blocks/GT_Block_Casings4.java | 440 ++++----------------- .../gregtech/common/blocks/GT_Item_Machines.java | 4 +- .../multi/GT_MetaTileEntity_LargeTurbine.java | 10 +- 3 files changed, 83 insertions(+), 371 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 6fb40784c1..809c76d720 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -4,7 +4,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; @@ -15,12 +14,20 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { + private static int[][] mapping = new int[][]{ + {7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7}, + {7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7}, + {7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 7, 1, 1, 1, 0, 8, 11, 2, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 9, 10, 4, 0, 3, 5, 6, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7}, + }; public static boolean mConnectedMachineTextures = true; public GT_Block_Casings4() { super(GT_Item_Casings4.class, "gt.blockcasings4", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[0][(i + 48)] = TextureFactory.of(this, i); + Textures.BlockIcons.casingTexturePages[0][i + 48] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); @@ -59,18 +66,21 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: + case 12: return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 1: + case 10: return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 2: + case 11: return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 3: return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 4: - //Do not overwrite! + //Do not overwrite! return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW.getIcon(); case 5: - //Do not overwrite! + //Do not overwrite! return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS.getIcon(); case 6: return Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); @@ -80,12 +90,6 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { return Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); case 9: return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); - case 10: - return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); - case 11: - return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 12: - return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 13: return Textures.BlockIcons.MACHINE_CASING_ENGINE_INTAKE.getIcon(); case 14: @@ -98,8 +102,6 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { public IIcon getTurbineCasing(int meta, int iconIndex, boolean active) { switch (meta) { - case 9: - return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() : Textures.BlockIcons.TURBINE[iconIndex].getIcon(); case 10: return active ? Textures.BlockIcons.TURBINE_ACTIVE1[iconIndex].getIcon() : Textures.BlockIcons.TURBINE1[iconIndex].getIcon(); case 11: @@ -111,121 +113,63 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { } } + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine && tTile.getFrontFacing() == aSide) + return tTile.isActive() ? 1 : 2; + return 0; + } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if ((tMeta != 6) && (tMeta != 8) && (tMeta != 9) && (tMeta != 10) && (tMeta != 11) && (tMeta != 12) || (!mConnectedMachineTextures)) { + if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 || !mConnectedMachineTextures) { return getIcon(aSide, tMeta); } - int tStartIndex = tMeta == 6 ? 1 : 13; - if ((tMeta == 9) || (tMeta == 10) || (tMeta == 11) || (tMeta == 12)) { - if ((aSide == 2) || (aSide == 3)) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 0, true); - } - return getTurbineCasing(tMeta, 0, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 3, true); - } - return getTurbineCasing(tMeta, 3, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 6, true); - } - return getTurbineCasing(tMeta, 6, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 1, true); - } - return getTurbineCasing(tMeta, 1, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 7, true); - } - return getTurbineCasing(tMeta, 7, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 8, true); - } - return getTurbineCasing(tMeta, 8, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 5, true); - } - return getTurbineCasing(tMeta, 5, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 2, true); - } - return getTurbineCasing(tMeta, 2, false); - } - } else if ((aSide == 4) || (aSide == 5)) { - TileEntity tTileEntity; - Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 0, true); - } - return getTurbineCasing(tMeta, 0, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 3, true); - } - return getTurbineCasing(tMeta, 3, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 6, true); - } - return getTurbineCasing(tMeta, 6, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 1, true); - } - return getTurbineCasing(tMeta, 1, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 7, true); - } - return getTurbineCasing(tMeta, 7, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 8, true); - } - return getTurbineCasing(tMeta, 8, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 5, true); - } - return getTurbineCasing(tMeta, 5, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 2, true); - } - return getTurbineCasing(tMeta, 2, false); - } + if (tMeta > 8 && tMeta < 13) { + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 2) { + case 0: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide)) != 0) { + return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1); + } + } + } + break; + case 1: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide)) != 0) { + return getTurbineCasing(tMeta, 4 + i * 3 - j * tInvertLeftRightMod, tState == 1); + } + } + } + break; + case 2: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide)) != 0) { + return getTurbineCasing(tMeta, 4 + i * 3 + j * tInvertLeftRightMod, tState == 1); + } + } + } + break; } switch (tMeta) { - case 9: - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); case 10: return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 11: @@ -236,250 +180,18 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); } } - boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; - switch (aSide) { - case 0: - if (tConnectedSides[0]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 1: - if (tConnectedSides[1]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 2: - if (tConnectedSides[5]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 3: - if (tConnectedSides[3]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 4: - if (tConnectedSides[4]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - case 5: - if (tConnectedSides[2]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - break; - } - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + int tStartIndex = tMeta == 6 ? 1 : 13; + int tIndexIntoMapping = 0; + if (isSameBlock(aWorld, xCoord, yCoord - 1, zCoord, tMeta)) tIndexIntoMapping |= 1; + if (isSameBlock(aWorld, xCoord, yCoord + 1, zCoord, tMeta)) tIndexIntoMapping |= 1 << 1; + if (isSameBlock(aWorld, xCoord + 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 2; + if (isSameBlock(aWorld, xCoord, yCoord, zCoord + 1, tMeta)) tIndexIntoMapping |= 1 << 3; + if (isSameBlock(aWorld, xCoord - 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 4; + if (isSameBlock(aWorld, xCoord, yCoord, zCoord - 1, tMeta)) tIndexIntoMapping |= 1 << 5; + return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[aSide][tIndexIntoMapping]].getIcon(); + } + + private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { + return aWorld.getBlock(aX, aY, aZ) == this && aWorld.getBlockMetadata(aX, aY, aZ) == aMeta; } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 39eecdd5e4..c8e77f9b0a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -55,8 +55,8 @@ public class GT_Item_Machines extends ItemBlock { if(tDescription.contains("%%%")){ String[] tString = tDescription.split("%%%"); if(tString.length>=2){ - StringBuffer tBuffer = new StringBuffer(); - Object tRep[] = new String[tString.length / 2]; + StringBuilder tBuffer = new StringBuilder(); + String[] tRep = new String[tString.length / 2]; for (int j = 0; j < tString.length; j++) if (j % 2 == 0) tBuffer.append(tString[j]); else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index 55c22900bd..8cede375dc 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -32,11 +32,11 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E private static final String STRUCTURE_PIECE_MAIN = "main"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {" ", " xxx ", " ", " ", " ",}, - {" --- ", "xcccx", " chc ", " chc ", " ccc ",}, - {" --- ", "xc~cx", " h-h ", " h-h ", " cdc ",}, - {" --- ", "xcccx", " chc ", " chc ", " ccc ",}, - {" ", " xxx ", " ", " ", " ",}, + {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, + {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, + {" --- ", "xc~cx", "xh-hx", "xh-hx", "xcdcx",}, + {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, + {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, })) .addElement('c', defer(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) .addElement('d', defer(t -> ofHatchAdder(GT_MetaTileEntity_LargeTurbine::addDynamoToMachineList, t.getCasingTextureIndex(), 0))) -- cgit From e5a6de86d47d12130afe179303d7de5b78c85bff Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 20:54:11 +0800 Subject: general bugfix & tweaking pass for multis 1. stupid typo in EBF preventing it from working at all. 2. All multis now require exactly one maintenance hatch to form. 3. All multis now use the unified overclocking mechanism if possible. 4. All multis that emits pollution now require at least one muffler hatch to form. 5. Coil structure element slightly tweaked. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../java/gregtech/api/enums/HeatingCoilLevel.java | 10 ++++++-- .../gregtech/api/util/GT_StructureUtility.java | 30 ++++++++-------------- .../gregtech/common/blocks/GT_Block_Casings5.java | 29 +++++++++++++++++++++ .../multi/GT_MetaTileEntity_AssemblyLine.java | 26 +++++++------------ .../multi/GT_MetaTileEntity_DistillationTower.java | 19 ++++++++++---- .../multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 1 + .../multi/GT_MetaTileEntity_LargeTurbine.java | 2 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 3 +++ .../multi/GT_MetaTileEntity_OilCracker.java | 29 ++++++++++++--------- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 3 ++- 11 files changed, 96 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java index d4446e31d0..c2e3ff075a 100644 --- a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java +++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java @@ -23,6 +23,8 @@ public enum HeatingCoilLevel { MAX, ; + private static final HeatingCoilLevel[] VALUES = values(); + /** * @return the Coils Tier Name */ @@ -61,9 +63,13 @@ public enum HeatingCoilLevel { } public static HeatingCoilLevel getFromTier(byte tier){ - if (tier < 0 || tier > HeatingCoilLevel.values().length -1) + if (tier < 0 || tier > VALUES.length -1) return HeatingCoilLevel.None; - return HeatingCoilLevel.values()[tier+2]; + return VALUES[tier+2]; + } + + public static int size() { + return VALUES.length; } } diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 2670d9e684..5067c698ab 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -7,6 +7,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.common.blocks.GT_Block_Casings5; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -19,8 +20,6 @@ import java.util.function.Function; import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11; public class GT_StructureUtility { - public static final int HINT_COIL_DEFAULT_DOTS = HINT_BLOCK_META_GENERIC_11; - private GT_StructureUtility() { throw new AssertionError("Not instantiable"); } @@ -81,22 +80,14 @@ public class GT_StructureUtility { } /** - * Assume a default of LV coil. Assume all coils accepted. Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots. - * @see #ofCoil(BiPredicate, Function, int, Block, int) + * Assume all coils accepted. + * @see #ofCoil(BiPredicate, Function) */ public static IStructureElement ofCoil(BiConsumer heatingCoilSetter, Function heatingCoilGetter) { return ofCoil((t, l) -> { heatingCoilSetter.accept(t, l); return true; - }, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, GregTech_API.sBlockCasings5, 0); - } - - /** - * Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots - * @see #ofCoil(BiPredicate, Function, int, Block, int) - */ - public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, Block defaultCoil, int defaultMeta) { - return ofCoil(heatingCoilSetter, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, defaultCoil, defaultMeta); + }, heatingCoilGetter); } /** @@ -106,11 +97,8 @@ public class GT_StructureUtility { * Might be called less times if structure test fails. * If the setter returns false then it assumes the coil is rejected. * @param heatingCoilGetter Get the current heating level. Null means no coil recorded yet. - * @param dots The hinting dots - * @param defaultCoil The block to place when auto constructing - * @param defaultMeta The block meta to place when auto constructing */ - public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, int dots, Block defaultCoil, int defaultMeta) { + public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter) { if (heatingCoilSetter == null || heatingCoilGetter == null) { throw new IllegalArgumentException(); } @@ -131,13 +119,17 @@ public class GT_StructureUtility { @Override public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), dots); + StructureLibAPI.hintParticle(world, x, y, z, GregTech_API.sBlockCasings5, getMeta(trigger)); return true; } + private int getMeta(ItemStack trigger) { + return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.size(), Math.max(0, trigger.stackSize)))); + } + @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return world.setBlock(x, y, z, defaultCoil, defaultMeta, 3); + return world.setBlock(x, y, z, GregTech_API.sBlockCasings5, getMeta(trigger), 3); } }; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index 296bf765b0..63645f3c3f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -108,6 +108,35 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHea } } + public static int getMetaFromCoilHeat(HeatingCoilLevel level) { + switch (level) { + case LV: + return 0; + case MV: + return 1; + case HV: + return 2; + case EV: + return 3; + case IV: + return 4; + case ZPM: + return 5; + case UV: + return 6; + case UEV: + return 7; + case UIV: + return 8; + case LuV: + return 9; + case UHV: + return 10; + default: + return 0; + } + } + @Override public HeatingCoilLevel getCoilHeat(int meta) { getOnCoilCheck().accept(this); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 5d363d9aa1..dd10b2465d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -242,13 +242,19 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu if (!tTag.hasKey("time")) continue; - mMaxProgresstime = tTag.getInteger("time"); - if (mMaxProgresstime <= 0) + int tMaxProgressTime = tTag.getInteger("time"); + if (tMaxProgressTime <= 0) continue; if (!tTag.hasKey("eu")) continue; - mEUt = tTag.getInteger("eu"); + + calculateOverclockedNessMulti(tTag.getInteger("eu"), tMaxProgressTime, 1, getMaxInputVoltage()); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + if (GT_Values.D1) GT_FML_LOGGER.info("Recipe too OP"); + continue; + } if (GT_Values.D1) GT_FML_LOGGER.info("Find avaiable recipe"); findRecipe = true; @@ -274,22 +280,8 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu } if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - if (mEUt <= 16) { - this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); updateSlots(); if (GT_Values.D1) GT_FML_LOGGER.info("Recipe sucessfull"); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 73bbfe056a..bbbaed929a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -59,7 +59,11 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('c', ofChain( - onElementPass(GT_MetaTileEntity_DistillationTower::onTopLayerFound, ofBlock(GregTech_API.sBlockCasings4, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addInputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(true), ofBlock(GregTech_API.sBlockCasings4, 1)), isAir() )) .build(); @@ -96,7 +100,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan .addMaintenanceHatch("Any casing") .addInputHatch("Any bottom layer casing") .addOutputBus("Any bottom layer casing") - .addOutputHatch("2-11x Output Hatches (One per layer except bottom layer)") + .addOutputHatch("2-11x Output Hatches (At least one per layer except bottom layer)") .toolTipFinisher("Gregtech"); return tt; } @@ -182,9 +186,10 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan mCasing++; } - protected void onTopLayerFound() { + protected void onTopLayerFound(boolean aIsCasing) { mTopLayerFound = true; - onCasingFound(); + if (aIsCasing) + onCasingFound(); } protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -220,9 +225,13 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan return false; // check each layer - while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) + while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) + // layer without output hatch + return false; // not top mHeight++; + } // validate final invariants... return mCasing >= 7 * mHeight - 5 && mHeight >= 2 && mTopLayerFound && mMaintenanceHatches.size() == 1; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 9bd2a66250..0ea04f1cfa 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -361,7 +361,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { updateCoordinates(); - return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier(); + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier() && mMaintenanceHatches.size() == 1; } private void updateCoordinates() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 23c6685d8a..c7a3c3490d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -269,6 +269,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab return false; if (mMaintenanceHatches.size() != 1) + return false; this.mHeatingCapacity = (int) getCoilLevel().getHeat() + 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index 8cede375dc..fd3117e451 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -79,7 +79,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1); + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) && mMaintenanceHatches.size() == 1 && mMufflerHatches.isEmpty() == (getPollutionPerTick(null) == 0); } public abstract Block getCasingBlock(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index ba77716622..edfce02aad 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -184,6 +184,9 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu if (getCoilLevel() == HeatingCoilLevel.None) return false; + if (mMaintenanceHatches.size() != 1) + return false; + this.mLevel = getCoilLevel().getLevel(); this.mCostDiscount = getCoilLevel().getCostDiscount(); return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index e4f96db248..8a257db8ee 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -49,11 +49,11 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addElement('c', ofCoil(GT_MetaTileEntity_OilCracker::setCoilLevel, GT_MetaTileEntity_OilCracker::getCoilLevel)) .addElement('l', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addLeftHatchToMachineList, CASING_INDEX, 2), - onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 2)) + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('r', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 2), - onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 3)) + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('m', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addMiddleInputToMachineList, CASING_INDEX, 1), @@ -90,10 +90,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addController("Front center") .addCasingInfo("Clean Stainless Steel Machine Casing", 18) .addOtherStructurePart("2 Rings of 8 Coils", "Each side of the controller") - .addInfo("Gets 5% energy cost reduction per coil tier") + .addInfo("Gets 5% EU/t reduction per coil tier") .addEnergyHatch("Any casing") .addMaintenanceHatch("Any casing") - .addInputHatch("Steam/Hydrogen, Any middle ring casing") + .addInputHatch("Steam/Hydrogen ONLY, Any middle ring casing") .addInputHatch("Any left/right side casing") .addOutputHatch("Any left/right side casing") .addStructureInfo("Input/Output Hatches must be on opposite sides!") @@ -119,6 +119,11 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OilCrackingUnit.png"); } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCrakingRecipes; + } + @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredFluids(); @@ -126,7 +131,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe( + GT_Recipe tRecipe = getRecipeMap().findRecipe( getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], @@ -140,12 +145,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult if (tRecipe.isRecipeInputEqual(true, tFluidInputs, mInventory[1])) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } + calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; this.mEUt *= Math.pow(0.95D, this.heatLevel.getTier()); @@ -248,7 +251,9 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult mInputOnSide = -1; mOutputOnSide = -1; replaceDeprecatedCoils(aBaseMetaTileEntity); - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18; + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && + mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18 && + mMaintenanceHatches.size() == 1 && !mMiddleInputHatches.isEmpty(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 9ad84d061a..76bdb8423a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -188,7 +188,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu coilHeat = HeatingCoilLevel.None; mCasingAmount = 0; replaceDeprecatedCoils(aBaseMetaTileEntity); - return checkPiece("main", 2, 3, 0) && mCasingAmount >= 60; + return checkPiece("main", 2, 3, 0) && mCasingAmount >= 60 && + mMaintenanceHatches.size() == 1 && !mMufflerHatches.isEmpty(); } @Override -- cgit From 1dab17bc98123337e80e6a766cdfeeadbded698b Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:47:39 +0800 Subject: fix distillation tower structure Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- build.properties | 2 +- .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index e4f67386b8..c9a1e92d05 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 gt.version=5.09.37.02 -structurelib.version=1.0.2 +structurelib.version=1.0.4 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index bbbaed929a..b35d6e3c56 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -59,9 +59,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('c', ofChain( - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1)), onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1)), - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addInputToMachineList, CASING_INDEX, 1)), onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1)), onElementPass(t -> t.onTopLayerFound(true), ofBlock(GregTech_API.sBlockCasings4, 1)), isAir() -- cgit From bbaa5a3837c2e1999a09abdedf55293095000185 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 23:21:38 +0800 Subject: make rotation marker a bit fancier, fix fusion texture Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 52 +++++++++++++++------- .../multi/GT_MetaTileEntity_FusionComputer1.java | 5 +-- .../multi/GT_MetaTileEntity_FusionComputer2.java | 4 +- .../multi/GT_MetaTileEntity_FusionComputer3.java | 5 +-- 4 files changed, 43 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 3578af5756..5c2fc3c4d9 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -286,22 +286,24 @@ public class GT_Client extends GT_Proxy if (tAlignment != null) { ForgeDirection direction = tAlignment.getDirection(); if (direction.ordinal() == tSideHit) - drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking); + drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking, false); else if (direction.getOpposite().ordinal() == tSideHit) { for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { - drawExtendedRotationMarker(t, aIsSneaking); + drawExtendedRotationMarker(t, aIsSneaking, true); } } else { - drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]], aIsSneaking); + drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]], aIsSneaking, true); } } } GL11.glPopMatrix(); // get back to player center } - private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking) { + private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) { if (sneaking) drawFlipMarker(transform); + else if (small) + drawRotationMarkerSmall(transform); else drawRotationMarker(transform); } @@ -311,17 +313,37 @@ public class GT_Client extends GT_Proxy transform.glApply(); Tessellator t = Tessellator.instance; t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.4d, 0d, -0.4d); - t.addVertex(-0.4d, 0d, 0.4d); - t.addVertex(0.4d, 0d, 0.4d); - t.addVertex(0.4d, 0d, -0.325d); - t.addVertex(0.45d, 0d, -0.325d); - t.addVertex(0.35d, 0d, -0.425d); - t.addVertex(0.25d, 0d, -0.325d); - t.addVertex(0.3d, 0d, -0.325d); - t.addVertex(0.3d, 0d, 0.3d); - t.addVertex(-0.3d, 0d, 0.3d); - t.addVertex(-0.3d, 0d, -0.4d); + t.addVertex(-0.3000d, 0d, -0.3000d); + t.addVertex(-0.3000d, 0d, +0.3000d); + t.addVertex(+0.3000d, 0d, +0.3000d); + t.addVertex(+0.3000d, 0d, -0.1750d); + t.addVertex(+0.3600d, 0d, -0.1750d); + t.addVertex(+0.2500d, 0d, -0.3000d); + t.addVertex(+0.1400d, 0d, -0.1750d); + t.addVertex(+0.2000d, 0d, -0.1750d); + t.addVertex(+0.2000d, 0d, +0.2000d); + t.addVertex(-0.2000d, 0d, +0.2000d); + t.addVertex(-0.2000d, 0d, -0.3000d); + t.draw(); + GL11.glPopMatrix(); + } + + private static void drawRotationMarkerSmall(Transformation transform) { + GL11.glPushMatrix(); + transform.glApply(); + Tessellator t = Tessellator.instance; + t.startDrawing(GL11.GL_LINE_LOOP); + t.addVertex(-0.3500d, 0d, -0.3500d); + t.addVertex(-0.3500d, 0d, +0.3500d); + t.addVertex(+0.3500d, 0d, +0.3500d); + t.addVertex(+0.3500d, 0d, -0.2000d); + t.addVertex(+0.4500d, 0d, -0.2000d); + t.addVertex(+0.3000d, 0d, -0.3500d); + t.addVertex(+0.1500d, 0d, -0.2000d); + t.addVertex(+0.2500d, 0d, -0.2000d); + t.addVertex(+0.2500d, 0d, +0.2500d); + t.addVertex(-0.2500d, 0d, +0.2500d); + t.addVertex(-0.2500d, 0d, -0.3500d); t.draw(); GL11.glPopMatrix(); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java index fd55bf715b..2901a9e4f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -7,7 +7,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1_GLOW; @@ -15,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1_GLOW; public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION1), - TextureFactory.builder().addIcon(OVERLAY_FUSION1_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION1).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION1_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer1(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java index 890b43cc7a..6cefdc6812 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -14,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION2_GLOW; public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION2), - TextureFactory.builder().addIcon(OVERLAY_FUSION2_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION2).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION2_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer2(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java index 0a3bc89d20..b879c7923b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -7,7 +7,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3_GLOW; @@ -15,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3_GLOW; public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION3), - TextureFactory.builder().addIcon(OVERLAY_FUSION3_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION3).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION3_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer3(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); -- cgit From 580a6a0c09844941fc74ed4cc867a78ae70cb257 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 26 Jun 2021 21:11:47 +0800 Subject: make rotation marker a lot more fancier Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 125 ++++++++++++++------------- 1 file changed, 65 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 5c2fc3c4d9..674719eab5 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -46,6 +46,7 @@ import gregtech.common.render.GT_Renderer_Entity_Arrow; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -69,6 +70,8 @@ import java.util.List; import java.util.Map; import java.util.Scanner; +import static org.lwjgl.opengl.GL11.GL_LINE_LOOP; + // Referenced classes of package gregtech.common: // GT_Proxy @@ -110,6 +113,8 @@ public class GT_Client extends GT_Proxy new Scale(0.25).with(new Translation(0.375, 0, -0.375)).compile(), new Scale(0.25).with(new Translation(-0.375, 0, -0.375)).compile(), }; + private static int rotationMarkerDisplayList; + private static boolean rotationMarkerDisplayListCompiled = false; static { ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, @@ -148,6 +153,8 @@ public class GT_Client extends GT_Proxy private String mMessage; private GT_ClientPreference mPreference; private boolean mFirstTick = false; + public static final int ROTATION_MARKER_RESOLUTION = 120; + public GT_Client() { mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; @@ -222,7 +229,7 @@ public class GT_Client extends GT_Proxy tConnections = ((BaseMetaPipeEntity) tTile).mConnections; } - if (tConnections>0) { + if (tConnections > 0) { for (byte i = 0; i < 6; i++) { if ((tConnections & (1 << i)) != 0) { switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { @@ -302,50 +309,36 @@ public class GT_Client extends GT_Proxy private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) { if (sneaking) drawFlipMarker(transform); - else if (small) - drawRotationMarkerSmall(transform); else drawRotationMarker(transform); } private static void drawRotationMarker(Transformation transform) { + if (!rotationMarkerDisplayListCompiled) { + rotationMarkerDisplayList = GLAllocation.generateDisplayLists(1); + compileRotationMarkerDisplayList(rotationMarkerDisplayList); + rotationMarkerDisplayListCompiled = true; + } GL11.glPushMatrix(); transform.glApply(); - Tessellator t = Tessellator.instance; - t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.3000d, 0d, -0.3000d); - t.addVertex(-0.3000d, 0d, +0.3000d); - t.addVertex(+0.3000d, 0d, +0.3000d); - t.addVertex(+0.3000d, 0d, -0.1750d); - t.addVertex(+0.3600d, 0d, -0.1750d); - t.addVertex(+0.2500d, 0d, -0.3000d); - t.addVertex(+0.1400d, 0d, -0.1750d); - t.addVertex(+0.2000d, 0d, -0.1750d); - t.addVertex(+0.2000d, 0d, +0.2000d); - t.addVertex(-0.2000d, 0d, +0.2000d); - t.addVertex(-0.2000d, 0d, -0.3000d); - t.draw(); + GL11.glCallList(rotationMarkerDisplayList); GL11.glPopMatrix(); } - private static void drawRotationMarkerSmall(Transformation transform) { - GL11.glPushMatrix(); - transform.glApply(); - Tessellator t = Tessellator.instance; - t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.3500d, 0d, -0.3500d); - t.addVertex(-0.3500d, 0d, +0.3500d); - t.addVertex(+0.3500d, 0d, +0.3500d); - t.addVertex(+0.3500d, 0d, -0.2000d); - t.addVertex(+0.4500d, 0d, -0.2000d); - t.addVertex(+0.3000d, 0d, -0.3500d); - t.addVertex(+0.1500d, 0d, -0.2000d); - t.addVertex(+0.2500d, 0d, -0.2000d); - t.addVertex(+0.2500d, 0d, +0.2500d); - t.addVertex(-0.2500d, 0d, +0.2500d); - t.addVertex(-0.2500d, 0d, -0.3500d); - t.draw(); - GL11.glPopMatrix(); + private static void compileRotationMarkerDisplayList(int displayList) { + GL11.glNewList(displayList, GL11.GL_COMPILE); + GL11.glBegin(GL_LINE_LOOP); + for (int i = 0; i <= ROTATION_MARKER_RESOLUTION; i++) { + GL11.glVertex3d(Math.cos(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.4, 0, Math.sin(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.4); + } + for (int i = ROTATION_MARKER_RESOLUTION; i >=0; i--) { + GL11.glVertex3d(Math.cos(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.24, 0, Math.sin(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.24); + } + GL11.glVertex3d(0.141114561800, 0, 0); + GL11.glVertex3d(0.32, 0, -0.178885438199); + GL11.glVertex3d(0.498885438199, 0, 0); + GL11.glEnd(); + GL11.glEndList(); } private static void drawFlipMarker(Transformation transform) { @@ -469,7 +462,9 @@ public class GT_Client extends GT_Proxy } i++; } while (true); - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } // super.onPostLoad(); @@ -574,8 +569,21 @@ public class GT_Client extends GT_Proxy Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) - { + if (aBlock == Blocks.glass) { + GL11.glPushMatrix(); + GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); + GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); + int tSideHit = aEvent.target.sideHit; + Rotation.sideRotations[tSideHit].glApply(); + // draw grid + GL11.glTranslated(0.0D, -0.501D, 0.0D); + GL11.glLineWidth(2.0F); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + GL11.glPopMatrix(); + } + + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); return; @@ -585,17 +593,15 @@ public class GT_Client extends GT_Proxy return; if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) || - GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList) ) - { + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList)) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) drawGrid(aEvent, false, false, aEvent.player.isSneaking()); return; } if ((aEvent.currentItem == null && aEvent.player.isSneaking()) || - GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || - GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) - { + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) for (byte i = 0; i < 6; i++) if (((ICoverable) aTileEntity).getCoverIDAtSide(i) > 0) { @@ -605,8 +611,7 @@ public class GT_Client extends GT_Proxy return; } - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) - { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } @@ -776,13 +781,12 @@ public class GT_Client extends GT_Proxy tString = (new StringBuilder()).append(tString).append("wherearewenow").toString(); break; } - if (tString.startsWith("streaming.")){ + if (tString.startsWith("streaming.")) { new WorldSpawnedEventBuilder.RecordEffectEventBuilder() .setIdentifier(tString.substring(10)) .setPosition(aX, aY, aZ) .run(); - } - else{ + } else { new WorldSpawnedEventBuilder.SoundEventBuilder() .setVolume(3f) .setPitch(tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F) @@ -792,13 +796,14 @@ public class GT_Client extends GT_Proxy } } - public static int hideValue=0; + public static int hideValue = 0; - /**

Client tick counter that is set to 5 on hiding pipes and covers.

+ /** + *

Client tick counter that is set to 5 on hiding pipes and covers.

*

It triggers a texture update next client tick when reaching 4, with provision for 3 more update tasks, * spreading client change detection related work and network traffic on different ticks, until it reaches 0.

*/ - public static int changeDetected=0; + public static int changeDetected = 0; private static int shouldHeldItemHideThings() { try { @@ -815,17 +820,17 @@ public class GT_Client extends GT_Proxy } } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList) - || GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - hide |= 0x2; + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList) + || GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { + hide |= 0x2; } return hide; - }catch(Exception e){ + } catch (Exception e) { return 0; } } -- cgit From 8f5a4afac46140c9b93a0161feccd0b5a2eca07e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 27 Jun 2021 01:15:34 +0800 Subject: remove debug code Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 674719eab5..eeaf5a96ff 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -569,21 +569,8 @@ public class GT_Client extends GT_Proxy Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (aBlock == Blocks.glass) { - GL11.glPushMatrix(); - GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); - GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); - int tSideHit = aEvent.target.sideHit; - Rotation.sideRotations[tSideHit].glApply(); - // draw grid - GL11.glTranslated(0.0D, -0.501D, 0.0D); - GL11.glLineWidth(2.0F); - GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); - drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); - GL11.glPopMatrix(); - } - - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) + { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); return; -- cgit From 112f7809ecaa0ccb5e8060b70d7e437086ffa735 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 16 Jul 2021 19:49:22 +0800 Subject: Minor clean up in GT_Client ARR is taboo :kekw: Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index eeaf5a96ff..55efd20920 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -82,7 +82,7 @@ public class GT_Client extends GT_Proxy public static final String GT_CAPE_LIST_URL = "http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt"; private static final List ROTATABLE_VANILLA_BLOCKS; - private static final int[][] GRID_SWITCH_ARR = new int[][]{ + private static final int[][] GRID_SWITCH_TABLE = new int[][]{ {0, 5, 3, 1, 2, 4}, {5, 0, 1, 3, 2, 4}, {1, 3, 0, 5, 2, 4}, @@ -149,8 +149,6 @@ public class GT_Client extends GT_Proxy private int mLastUpdatedBlockX; private int mLastUpdatedBlockY; private int mLastUpdatedBlockZ; - private boolean isFirstClientPlayerTick; - private String mMessage; private GT_ClientPreference mPreference; private boolean mFirstTick = false; public static final int ROTATION_MARKER_RESOLUTION = 120; @@ -159,8 +157,6 @@ public class GT_Client extends GT_Proxy mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; mAnimationDirection = false; - isFirstClientPlayerTick = true; - mMessage = ""; mPosR = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); mPosG = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, @@ -232,7 +228,7 @@ public class GT_Client extends GT_Proxy if (tConnections > 0) { for (byte i = 0; i < 6; i++) { if ((tConnections & (1 << i)) != 0) { - switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { + switch (GRID_SWITCH_TABLE[aEvent.target.sideHit][i]) { case 0: GL11.glVertex3d(+.25D, .0D, +.25D); GL11.glVertex3d(-.25D, .0D, -.25D); -- cgit From 1cdefed2daf27b0a36032067f9af97962bf353fb Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 18 Jul 2021 08:20:13 +0800 Subject: Fix mod loading order problem This utility method could probably be extracted to upstream. Let's do it when the structurelib integration comes to the end of test phase. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/api/util/GT_StructureUtility.java | 37 ++++++++++++++++++++-- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 26 ++++++--------- 2 files changed, 45 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 5067c698ab..7e39a0d838 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -3,6 +3,7 @@ package gregtech.api.util; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.IHeatingCoil; @@ -12,13 +13,12 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import org.apache.commons.lang3.StringUtils; import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Function; -import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11; - public class GT_StructureUtility { private GT_StructureUtility() { throw new AssertionError("Not instantiable"); @@ -133,4 +133,37 @@ public class GT_StructureUtility { } }; } + + public static IStructureElement ofBlockUnlocalizedName(String modid, String unlocalizedName, int meta) { + if (StringUtils.isBlank(unlocalizedName)) throw new IllegalArgumentException(); + if (meta < 0) throw new IllegalArgumentException(); + if (meta > 15) throw new IllegalArgumentException(); + if (StringUtils.isBlank(modid)) throw new IllegalArgumentException(); + return new IStructureElement() { + private Block block; + + private Block getBlock() { + if (block == null) + block = GameRegistry.findBlock(modid, unlocalizedName); + return block; + } + + @Override + public boolean check(T t, World world, int x, int y, int z) { + return world.getBlock(x, y, z) != getBlock() && world.getBlockMetadata(x, y, z) == meta; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, getBlock(), meta); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + world.setBlock(x, y, z, getBlock(), meta, 2); + return true; + } + }; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 76bdb8423a..3db096eca3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -1,9 +1,9 @@ package gregtech.common.tileentities.machines.multi; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Textures; @@ -17,12 +17,10 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; @@ -32,6 +30,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofBlockUnlocalizedName; import static gregtech.api.util.GT_StructureUtility.ofCoil; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -43,16 +42,11 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu private static final IStructureDefinition STRUCTURE_DEFINITION = createStructureDefinition(); private static IStructureDefinition createStructureDefinition() { - Block casingBlock; - int casingMeta; - - if (Loader.isModLoaded("dreamcraft")) { - casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH"); - casingMeta = 2; - } else { - casingBlock = GregTech_API.sBlockCasings1; - casingMeta = 0; - } + IStructureElement tCasingElement = + Loader.isModLoaded("dreamcraft") ? + ofBlockUnlocalizedName("dreamcraft", "gt.blockcasingsNH", 2) : + ofBlock(GregTech_API.sBlockCasings1, 0); + return StructureDefinition.builder() .addShape("main", transpose(new String[][]{ {"ccccc", "ctttc", "ctttc", "ctttc", "ccccc"}, @@ -60,18 +54,18 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu {"ccccc", "c---c", "c---c", "c---c", "ccccc"}, {"bb~bb", "bCCCb", "bCCCb", "bCCCb", "bbbbb"}, })) - .addElement('c', onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta))) + .addElement('c', onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement)) .addElement('C', ofCoil(GT_MetaTileEntity_PyrolyseOven::setCoilLevel, GT_MetaTileEntity_PyrolyseOven::getCoilLevel)) .addElement('b', ofChain( ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMaintenanceToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addOutputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addEnergyInputToMachineList, CASING_INDEX, 1), - onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta)) + onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement) )) .addElement('t', ofChain( ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addInputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMufflerToMachineList, CASING_INDEX, 1), - onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, ofBlock(casingBlock, casingMeta)) + onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement) )) .build(); } -- cgit From bfe1836ddc069653d9af9d59008ec23f4dcb6c05 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 19 Jul 2021 15:51:27 +0800 Subject: Fixes related to coil hint blocks Also updates StructureLib to fix invisible block hint and pulled the utility methods up. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- build.properties | 2 +- .../java/gregtech/api/enums/HeatingCoilLevel.java | 6 +++- .../api/metatileentity/BaseMetaTileEntity.java | 11 ++++++- .../gregtech/api/util/GT_StructureUtility.java | 36 ++-------------------- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 2 +- 5 files changed, 19 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index c9a1e92d05..16566feedf 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 gt.version=5.09.37.02 -structurelib.version=1.0.4 +structurelib.version=1.0.5 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java index c2e3ff075a..06ceedff53 100644 --- a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java +++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java @@ -63,7 +63,7 @@ public enum HeatingCoilLevel { } public static HeatingCoilLevel getFromTier(byte tier){ - if (tier < 0 || tier > VALUES.length -1) + if (tier < 0 || tier > getMaxTier()) return HeatingCoilLevel.None; return VALUES[tier+2]; @@ -72,4 +72,8 @@ public enum HeatingCoilLevel { public static int size() { return VALUES.length; } + + public static int getMaxTier() { + return VALUES.length - 1 - 2; + } } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 6eb06d8fae..1adcb41259 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -11,6 +11,8 @@ import appeng.tile.events.TileEventType; import com.gtnewhorizon.structurelib.alignment.IAlignment; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructableProvider; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; @@ -54,6 +56,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; +import javax.annotation.Nullable; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; @@ -73,7 +76,7 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @Optional.InterfaceList(value = { @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) -public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider { +public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider, IConstructableProvider { private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; protected MetaTileEntity mMetaTileEntity; protected long mStoredEnergy = 0, mStoredSteam = 0; @@ -2374,6 +2377,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return getMetaTileEntity() instanceof IAlignmentProvider ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() : new BasicAlignment(); } + @Nullable + @Override + public IConstructable getConstructable() { + return getMetaTileEntity() instanceof IConstructable ? (IConstructable) getMetaTileEntity() : null; + } + private class BasicAlignment implements IAlignment { @Override diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 7e39a0d838..dc916f02e3 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -124,7 +124,8 @@ public class GT_StructureUtility { } private int getMeta(ItemStack trigger) { - return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.size(), Math.max(0, trigger.stackSize)))); + // -4 to skip unimplemented tiers + return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.getMaxTier() - 4, Math.max(0, trigger.stackSize)))); } @Override @@ -133,37 +134,4 @@ public class GT_StructureUtility { } }; } - - public static IStructureElement ofBlockUnlocalizedName(String modid, String unlocalizedName, int meta) { - if (StringUtils.isBlank(unlocalizedName)) throw new IllegalArgumentException(); - if (meta < 0) throw new IllegalArgumentException(); - if (meta > 15) throw new IllegalArgumentException(); - if (StringUtils.isBlank(modid)) throw new IllegalArgumentException(); - return new IStructureElement() { - private Block block; - - private Block getBlock() { - if (block == null) - block = GameRegistry.findBlock(modid, unlocalizedName); - return block; - } - - @Override - public boolean check(T t, World world, int x, int y, int z) { - return world.getBlock(x, y, z) != getBlock() && world.getBlockMetadata(x, y, z) == meta; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, getBlock(), meta); - return true; - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, getBlock(), meta, 2); - return true; - } - }; - } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 3db096eca3..7312e0d992 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -23,6 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockUnlocalizedName; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -30,7 +31,6 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_GLOW; -import static gregtech.api.util.GT_StructureUtility.ofBlockUnlocalizedName; import static gregtech.api.util.GT_StructureUtility.ofCoil; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -- cgit From 875ff766ce3801918c9d726a8a14a6710e655147 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 19 Jul 2021 19:25:36 +0800 Subject: Make block hint text more informative Also migrated from defer to lazy where possible Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 38 ++-- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 2 +- .../api/util/GT_Multiblock_Tooltip_Builder.java | 200 +++++++++++++++++++-- .../multi/GT_MetaTileEntity_AssemblyLine.java | 25 ++- .../GT_MetaTileEntity_ConcreteBackfillerBase.java | 10 +- .../multi/GT_MetaTileEntity_DieselEngine.java | 45 ++--- .../multi/GT_MetaTileEntity_DistillationTower.java | 18 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 51 +++--- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 14 +- .../GT_MetaTileEntity_ExtremeDieselEngine.java | 12 +- .../multi/GT_MetaTileEntity_FusionComputer.java | 129 ++++++------- .../multi/GT_MetaTileEntity_FusionComputer1.java | 6 +- .../multi/GT_MetaTileEntity_FusionComputer2.java | 6 +- .../multi/GT_MetaTileEntity_FusionComputer3.java | 6 +- .../multi/GT_MetaTileEntity_HeatExchanger.java | 11 +- .../GT_MetaTileEntity_ImplosionCompressor.java | 10 +- .../multi/GT_MetaTileEntity_LargeBoiler.java | 61 ++++--- .../GT_MetaTileEntity_LargeChemicalReactor.java | 22 +-- .../multi/GT_MetaTileEntity_LargeTurbine.java | 41 +++-- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 8 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 8 +- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 8 +- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 8 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 12 +- .../multi/GT_MetaTileEntity_OilCracker.java | 13 +- .../multi/GT_MetaTileEntity_OilDrillBase.java | 8 +- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 10 +- .../multi/GT_MetaTileEntity_ProcessingArray.java | 12 +- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 18 +- .../multi/GT_MetaTileEntity_VacuumFreezer.java | 8 +- src/main/resources/assets/gregtech/lang/en_US.lang | 20 +++ 31 files changed, 531 insertions(+), 309 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index c84ca61eec..5499e756ba 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -6,7 +6,7 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -16,7 +16,8 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere. * Controller will be placed in front center of the structure. *

- * Note: You cannot use different casing for the same Class. Make a new subclass for it. + * Note: You cannot use different casing for the same Class. Make a new subclass for it. You also should not change the casing + * dynamically, i.e. it should be a dumb method returning some sort of constant. *

* Implementation tips: * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole @@ -28,20 +29,25 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; */ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase { protected static final String STRUCTURE_PIECE_MAIN = "main"; - protected static final IStructureDefinition> STRUCTURE_DEFINITION = StructureDefinition.>builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {"hhh", "hhh", "hhh"}, - {"h-h", "hhh", "hhh"}, - {"hhh", "hhh", "hhh"}, - })) - .addElement('h', ofChain( - defer(t -> ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, t.getHatchTextureIndex(), 1)), - onElementPass( - GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, - defer(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement) - ) - )) - .build(); + protected static final ClassValue>> STRUCTURE_DEFINITION = new ClassValue>>() { + @Override + protected IStructureDefinition> computeValue(Class type) { + return StructureDefinition.>builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"hhh", "hhh", "hhh"}, + {"h-h", "hhh", "hhh"}, + {"hhh", "hhh", "hhh"}, + })) + .addElement('h', ofChain( + lazy(t -> ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, t.getHatchTextureIndex(), 1)), + onElementPass( + GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, + lazy(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement) + ) + )) + .build(); + } + }; private int mCasingAmount = 0; protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index a9b50e6662..cc2513f5c2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -128,7 +128,7 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase * Info section order should be:
@@ -32,12 +39,16 @@ import net.minecraft.util.StatCollector; public class GT_Multiblock_Tooltip_Builder { private static final String TAB = " "; private static final String COLON = ": "; - + private static final String SEPARATOR = ", "; + private final List iLines; private final List sLines; - + private final List hLines; + private final SetMultimap hBlocks; + private String[] iArray; private String[] sArray; + private String[] hArray; //Localized tooltips private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); @@ -58,11 +69,17 @@ public class GT_Multiblock_Tooltip_Builder { private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS"); private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold"); private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display"); + private static final String TT_structurehint = StatCollector.translateToLocal("GT5U.MBTT.StructureHint"); private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); + private static final String TT_air = StatCollector.translateToLocal("GT5U.MBTT.Air"); + private static final String[] TT_dots = IntStream.range(0, 16).mapToObj(i -> StatCollector.translateToLocal("GT5U.MBTT.Dots." + i)).toArray(String[]::new); public GT_Multiblock_Tooltip_Builder() { iLines = new LinkedList<>(); sLines = new LinkedList<>(); + hLines = new LinkedList<>(); + hBlocks = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new); + hBlocks.put(0, TT_air); } /** @@ -103,11 +120,10 @@ public class GT_Multiblock_Tooltip_Builder { } /** - * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.
- * Machine Type: machine + * Add a line telling how much this machine pollutes. * - * @param machine - * Name of the machine type + * @param pollution + * Amount of pollution per second when active * * @return Instance this method was called on. */ @@ -307,7 +323,136 @@ public class GT_Multiblock_Tooltip_Builder { sLines.add(TAB + TT_outputhatch + COLON + info); return this; } - + + /** + * Use this method to add a structural part that isn't covered by the other methods.
+ * (indent)name: info + * @param name + * Name of the hatch or other component. + * @param info + * Positional information. + * @param dots + * The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info, int... dots) { + sLines.add(TAB + name + COLON + info); + for (int dot : dots) hBlocks.put(dot, name); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Maintenance Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info, int... dots) { + sLines.add(TAB + TT_maintenancehatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_maintenancehatch); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Muffler Hatch: info + * + * @param info Location where the hatch goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info, int... dots) { + sLines.add(TAB + TT_mufflerhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_mufflerhatch); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Energy Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info, int... dots) { + sLines.add(TAB + TT_energyhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_energyhatch); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Dynamo Hatch: info + * + * @param info Positional information. + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info, int... dots) { + sLines.add(TAB + TT_dynamohatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_dynamohatch); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Input Bus: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputBus(String info, int... dots) { + sLines.add(TAB + TT_inputbus + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_inputbus); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Input Hatch: info + * + * @param info Location where the hatch goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputHatch(String info, int... dots) { + sLines.add(TAB + TT_inputhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_inputhatch); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Output Bus: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputBus(String info, int... dots) { + sLines.add(TAB + TT_outputbus + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_outputbus); + return this; + } + + /** + * Add a line of information about the structure:
+ * (indent)Output Hatch: info + * + * @param info Location where the bus goes + * @param dots The valid locations for this part when asked to display hints + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputHatch(String info, int... dots) { + sLines.add(TAB + TT_outputhatch + COLON + info); + for (int dot : dots) hBlocks.put(dot, TT_outputhatch); + return this; + } + /** * Use this method to add non-standard structural info.
* (indent)info @@ -319,6 +464,30 @@ public class GT_Multiblock_Tooltip_Builder { sLines.add(TAB + info); return this; } + + /** + * Use this method to add non-standard structural hint. This info will appear before the standard structural hint. + * @param info + * The line to be added. This should be an entry into minecraft's localization system. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureHint(String info) { + hLines.add(StatCollector.translateToLocal(info)); + return this; + } + + /** + * Use this method to add an entry to standard structural hint without creating a corresponding line in structure information + * @param name + * The name of block This should be an entry into minecraft's localization system. + * @param dots + * Possible locations of this block + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureHint(String name, int... dots) { + for (int dot : dots) hBlocks.put(dot, StatCollector.translateToLocal(name)); + return this; + } /** * Call at the very end.
@@ -331,10 +500,10 @@ public class GT_Multiblock_Tooltip_Builder { public void toolTipFinisher(String mod) { iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay); iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY); - iArray = new String[iLines.size()]; - sArray = new String[sLines.size()]; - iLines.toArray(iArray); - sLines.toArray(sArray); + hLines.add(TT_structurehint); + iArray = iLines.toArray(new String[0]); + sArray = sLines.toArray(new String[0]); + hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey()] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new); } public String[] getInformation() { @@ -345,4 +514,7 @@ public class GT_Multiblock_Tooltip_Builder { return sArray; } + public String[] getStructureHint() { + return hArray; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index dd10b2465d..60aa372d20 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -69,18 +69,18 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu .addElement('m', ofBlock(GregTech_API.sBlockCasings2, 5)) // assembling line casing .addElement('g', ofBlockAnyMeta(GameRegistry.findBlock("IC2", "blockAlloyGlass"))) .addElement('e', ofHatchAdderOptional(GT_MetaTileEntity_AssemblyLine::addEnergyInputToMachineList, 16, 1, GregTech_API.sBlockCasings2, 0)) - .addElement('d', ofHatchAdderOptional(GT_MetaTileEntity_AssemblyLine::addDataAccessToMachineList, 42, 1, GregTech_API.sBlockCasings3, 10)) + .addElement('d', ofHatchAdderOptional(GT_MetaTileEntity_AssemblyLine::addDataAccessToMachineList, 42, 2, GregTech_API.sBlockCasings3, 10)) .addElement('b', ofChain( - ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addMaintenanceToMachineList, 16, 2), - ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputHatchToMachineList, 16, 2), + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addMaintenanceToMachineList, 16, 3), + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputHatchToMachineList, 16, 3), ofBlock(GregTech_API.sBlockCasings2, 0) )) .addElement('I', ofChain( // all blocks nearby use solid steel casing, so let's use the texture of that - ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 2), - ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addOutputToMachineList, 16, 2) + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 4), + ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addOutputToMachineList, 16,4) )) - .addElement('i', ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 2)) + .addElement('i', ofHatchAdder(GT_MetaTileEntity_AssemblyLine::addInputToMachineList, 16, 5)) .build(); public GT_MetaTileEntity_AssemblyLine(int aID, String aName, String aNameRegional) { @@ -111,15 +111,14 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes, aside from the last") - .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller") - .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller")//TT .addController("Either Grate on layer 3 of the first slice") - .addEnergyHatch("Any layer 4 casing") - .addMaintenanceHatch("Any layer 1 casing") - .addInputBus("As specified on layer 1") - .addInputHatch("Any layer 1 casing") - .addOutputBus("Replaces Input Bus on final slice") + .addEnergyHatch("Any layer 4 casing", 1) + .addMaintenanceHatch("Any layer 1 casing", 3) + .addInputBus("As specified on layer 1", 4, 5) + .addInputHatch("Any layer 1 casing", 3) + .addOutputBus("Replaces Input Bus on final slice", 4) + .addOtherStructurePart("Data Access Hatch", "Optional, next to controller", 2) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index 2341452ebe..8c1f28dd1c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -39,11 +39,11 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi .addStructureInfo(casings + " form the 3x1x3 Base") .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") - .addMaintenanceHatch("Any base casing") - .addInputBus("Mining Pipes, optional, any base casing") - .addInputHatch("GT Concrete, any base casing") - .addOutputBus("Mining Pipes, optional, any base casing") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing", 1) + .addMaintenanceHatch("Any base casing", 1) + .addInputBus("Mining Pipes, optional, any base casing", 1) + .addInputHatch("GT Concrete, any base casing", 1) + .addOutputBus("Mining Pipes, optional, any base casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 567297648a..8dfc605d6b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -24,7 +24,7 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE; @@ -37,18 +37,23 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {"---", "iii", "chc", "chc", "ccc", }, - {"---", "i~i", "hgh", "hgh", "cdc", }, - {"---", "iii", "chc", "chc", "ccc", }, - })) - .addElement('i', defer(t -> ofBlock(t.getIntakeBlock(), t.getIntakeMeta()))) - .addElement('c', defer(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('g', defer(t -> ofBlock(t.getGearboxBlock(), t.getGearboxMeta()))) - .addElement('d', defer(t -> ofHatchAdder(GT_MetaTileEntity_DieselEngine::addDynamoToMachineList, t.getCasingTextureIndex(), 0))) - .addElement('h', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_DieselEngine::addToMachineList, t.getCasingTextureIndex(), 0, t.getCasingBlock(), t.getCasingMeta()))) - .build(); + private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"---", "iii", "chc", "chc", "ccc", }, + {"---", "i~i", "hgh", "hgh", "cdc", }, + {"---", "iii", "chc", "chc", "ccc", }, + })) + .addElement('i', lazy(t -> ofBlock(t.getIntakeBlock(), t.getIntakeMeta()))) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('g', lazy(t -> ofBlock(t.getGearboxBlock(), t.getGearboxMeta()))) + .addElement('d', lazy(t -> ofHatchAdder(GT_MetaTileEntity_DieselEngine::addDynamoToMachineList, t.getCasingTextureIndex(), 2))) + .addElement('h', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_DieselEngine::addToMachineList, t.getCasingTextureIndex(), 1, t.getCasingBlock(), t.getCasingMeta()))) + .build(); + } + }; protected int fuelConsumption = 0; protected int fuelValue = 0; protected int fuelRemaining = 0; @@ -80,12 +85,12 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu .addOtherStructurePart("Titanium Gear Box Machine Casing", "Inner 2 blocks") .addOtherStructurePart("Engine Intake Machine Casing", "8x, ring around controller") .addStructureInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") - .addDynamoHatch("Back center") - .addMaintenanceHatch("One of the casings next to a Gear Box") - .addMufflerHatch("Top middle back, above the rear Gear Box") - .addInputHatch("Diesel Fuel, next to a Gear Box") - .addInputHatch("Lubricant, next to a Gear Box") - .addInputHatch("Oxygen, optional, next to a Gear Box") + .addDynamoHatch("Back center", 2) + .addMaintenanceHatch("One of the casings next to a Gear Box", 1) + .addMufflerHatch("Top middle back, above the rear Gear Box", 1) + .addInputHatch("Diesel Fuel, next to a Gear Box", 1) + .addInputHatch("Lubricant, next to a Gear Box", 1) + .addInputHatch("Oxygen, optional, next to a Gear Box", 1) .toolTipFinisher("Gregtech"); return tt; } @@ -192,7 +197,7 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu @Override public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; + return STRUCTURE_DEFINITION.get(getClass()); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index b35d6e3c56..3710112c9b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -53,14 +53,14 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('l', ofChain( - ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 2), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addLayerOutputHatch, CASING_INDEX, 2), - ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 2), onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('c', ofChain( - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1)), - onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 3)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 3)), onElementPass(t -> t.onTopLayerFound(true), ofBlock(GregTech_API.sBlockCasings4, 1)), isAir() )) @@ -94,11 +94,11 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan .beginVariableStructureBlock(3, 3, 3, 12, 3, 3, true) .addController("Front bottom") .addOtherStructurePart("Clean Stainless Steel Machine Casing", "7 x h - 5 (minimum)") - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputHatch("Any bottom layer casing") - .addOutputBus("Any bottom layer casing") - .addOutputHatch("2-11x Output Hatches (At least one per layer except bottom layer)") + .addEnergyHatch("Any casing", 1, 2) + .addMaintenanceHatch("Any casing", 1, 2, 3) + .addInputHatch("Any bottom layer casing", 1) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("2-11x Output Hatches (At least one per layer except bottom layer)", 2, 3) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 0ea04f1cfa..a610a502f9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -30,7 +30,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; @@ -48,27 +48,32 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe); private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip); protected static final String STRUCTURE_PIECE_MAIN = "main"; - protected static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {" ", " f ", " "}, - {" ", " f ", " "}, - {" ", " f ", " "}, - {" f ", "fcf", " f "}, - {" f ", "fcf", " f "}, - {" f ", "fcf", " f "}, - {"b~b", "bbb", "bbb"}, - })) - .addElement('f', defer(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) - .addElement('c', defer(t -> ofBlock(t.casingBlock, t.casingMeta))) - .addElement('b', defer(t -> ofChain( - ofBlock(t.casingBlock, t.casingMeta), - ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), - ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), - ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), - ofHatchAdder(GT_MetaTileEntity_DrillerBase::addEnergyInputToMachineList, t.casingTextureIndex, 1), - ofHatchAdder(GT_MetaTileEntity_DrillerBase::addDataAccessToMachineList, t.casingTextureIndex, 1) - ))) - .build(); + protected static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {" ", " f ", " "}, + {" ", " f ", " "}, + {" ", " f ", " "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {"b~b", "bbb", "bbb"}, + })) + .addElement('f', lazy(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) + .addElement('c', lazy(t -> ofBlock(t.casingBlock, t.casingMeta))) + .addElement('b', lazy(t -> ofChain( + ofBlock(t.casingBlock, t.casingMeta), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addEnergyInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addDataAccessToMachineList, t.casingTextureIndex, 1) + ))) + .build(); + } + }; private Block casingBlock; private int casingMeta; @@ -355,7 +360,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En @Override public final IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; + return STRUCTURE_DEFINITION.get(getClass()); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index c7a3c3490d..d3c9e7176b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -90,13 +90,13 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab .addController("Front bottom") .addCasingInfo("Heat Proof Machine Casing", 0) .addOtherStructurePart("Heating Coils", "Two middle Layers") - .addEnergyHatch("Any bottom layer casing") - .addMaintenanceHatch("Any bottom layer casing") - .addMufflerHatch("Top middle") - .addInputBus("Any bottom layer casing") - .addInputHatch("Any bottom layer casing") - .addOutputBus("Any bottom layer casing") - .addOutputHatch("Gasses, Any top layer casing") + .addEnergyHatch("Any bottom layer casing", 3) + .addMaintenanceHatch("Any bottom layer casing", 3) + .addMufflerHatch("Top middle", 2) + .addInputBus("Any bottom layer casing", 3) + .addInputHatch("Any bottom layer casing", 3) + .addOutputBus("Any bottom layer casing", 3) + .addOutputHatch("Gasses, Any top layer casing", 1) .addStructureInfo("Recovery amount scales with Muffler Hatch tier") .addOutputHatch("Platline fluids, Any bottom layer casing") .toolTipFinisher("Gregtech"); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java index f85f27935e..1878f25a5f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java @@ -51,12 +51,12 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Die .addOtherStructurePart("Titanium Gear Box Machine Casing", "Inner 2 blocks") .addOtherStructurePart("Extreme Engine Intake Machine Casing", "8x, ring around controller") .addStructureInfo("Extreme Engine Intake Casings must not be obstructed in front (only air blocks)") - .addDynamoHatch("Back center") - .addMaintenanceHatch("One of the casings next to a Gear Box") - .addMufflerHatch("Top middle back, above the rear Gear Box") - .addInputHatch("HOG, next to a Gear Box") - .addInputHatch("Lubricant, next to a Gear Box") - .addInputHatch("Liquid Oxygen, optional, next to a Gear Box") + .addDynamoHatch("Back center", 2) + .addMaintenanceHatch("One of the casings next to a Gear Box", 1) + .addMufflerHatch("Top middle back, above the rear Gear Box", 1) + .addInputHatch("HOG, next to a Gear Box", 1) + .addInputHatch("Lubricant, next to a Gear Box", 1) + .addInputHatch("Liquid Oxygen, optional, next to a Gear Box", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index bf2aeadcf8..88604979d2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -29,7 +29,7 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS; @@ -39,66 +39,71 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity_EnhancedMultiBlockBase { public static final String STRUCTURE_PIECE_MAIN = "main"; - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - { - " ", - " ihi ", - " hh hh ", - " h h ", - " h h ", - " h h ", - " i i ", - " h h ", - " i i ", - " h h ", - " h h ", - " h h ", - " hh hh ", - " ihi ", - " ", - }, - { - " xhx ", - " hhccchh ", - " eccxhxcce ", - " eceh hece ", - " hce ech ", - " hch hch ", - "xcx xcx", - "hch hch", - "xcx xcx", - " hch hch ", - " hce ech ", - " eceh hece ", - " eccx~xcce ", - " hhccchh ", - " xhx ", - }, - { - " ", - " ihi ", - " hh hh ", - " h h ", - " h h ", - " h h ", - " i i ", - " h h ", - " i i ", - " h h ", - " h h ", - " h h ", - " hh hh ", - " ihi ", - " ", - } - })) - .addElement('c', defer(t -> ofBlock(t.getFusionCoil(), t.getFusionCoilMeta()))) - .addElement('h', defer(t -> ofBlock(t.getCasing(), t.getCasingMeta()))) - .addElement('i', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addInjector, 53, 1, t.getCasing(), t.getCasingMeta()))) - .addElement('e', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addEnergyInjector, 53, 1, t.getCasing(), t.getCasingMeta()))) - .addElement('x', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addExtractor, 53, 1, t.getCasing(), t.getCasingMeta()))) - .build(); + private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + { + " ", + " ihi ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " i i ", + " h h ", + " i i ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " ihi ", + " ", + }, + { + " xhx ", + " hhccchh ", + " eccxhxcce ", + " eceh hece ", + " hce ech ", + " hch hch ", + "xcx xcx", + "hch hch", + "xcx xcx", + " hch hch ", + " hce ech ", + " eceh hece ", + " eccx~xcce ", + " hhccchh ", + " xhx ", + }, + { + " ", + " ihi ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " i i ", + " h h ", + " i i ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " ihi ", + " ", + } + })) + .addElement('c', lazy(t -> ofBlock(t.getFusionCoil(), t.getFusionCoilMeta()))) + .addElement('h', lazy(t -> ofBlock(t.getCasing(), t.getCasingMeta()))) + .addElement('i', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addInjector, 53, 1, t.getCasing(), t.getCasingMeta()))) + .addElement('e', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addEnergyInjector, 53, 2, t.getCasing(), t.getCasingMeta()))) + .addElement('x', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_FusionComputer::addExtractor, 53, 3, t.getCasing(), t.getCasingMeta()))) + .build(); + } + }; public GT_Recipe mLastRecipe; public int mEUStore; @@ -154,7 +159,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity @Override public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; + return STRUCTURE_DEFINITION.get(getClass()); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java index 2901a9e4f1..dd942d2635 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -75,9 +75,9 @@ public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionC .addCasingInfo("LuV Machine Casing", 79) .addStructureInfo("Cover the coils with casing") .addOtherStructurePart("Superconducting Coil Block", "Center part of the ring") - .addEnergyHatch("1-16, Specified casings") - .addInputHatch("2-16, Specified casings") - .addOutputHatch("1-16, Specified casings") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) .addStructureInfo("ALL Hatches must be LuV or better") .toolTipFinisher("Gregtech"); return tt; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java index 6cefdc6812..de9d863529 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -75,9 +75,9 @@ public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionC .addCasingInfo("Fusion Machine Casing", 79) .addStructureInfo("Cover the coils with casing") .addOtherStructurePart("Fusion Coil Block", "Center part of the ring") - .addEnergyHatch("1-16, Specified casings") - .addInputHatch("2-16, Specified casings") - .addOutputHatch("1-16, Specified casings") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) .addStructureInfo("ALL Hatches must be ZPM or better") .toolTipFinisher("Gregtech"); return tt; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java index b879c7923b..4e5c6c3cad 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -75,9 +75,9 @@ public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionC .addCasingInfo("Fusion Machine Casing Mk II", 79) .addStructureInfo("Cover the coils with casing") .addOtherStructurePart("Fusion Coil Block", "Center part of the ring") - .addEnergyHatch("1-16, Specified casings") - .addInputHatch("2-16, Specified casings") - .addOutputHatch("1-16, Specified casings") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) .addStructureInfo("ALL Hatches must be UV or better") .toolTipFinisher("Gregtech"); return tt; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 392726e13a..e8beb270e0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -52,7 +52,6 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedM ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addInputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addOutputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addEnergyInputToMachineList, CASING_INDEX, 1), onElementPass(GT_MetaTileEntity_HeatExchanger::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, (byte) 2)) )) .build(); @@ -87,11 +86,11 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedM .addController("Front bottom") .addCasingInfo("Stable Titanium Machine Casing", 20) .addOtherStructurePart("Titanium Pipe Casing", "Center 2 blocks") - .addMaintenanceHatch("Any casing") - .addInputHatch("Hot fluid, bottom center") - .addInputHatch("Distilled water, any casing") - .addOutputHatch("Cold fluid, top center") - .addOutputHatch("Steam/SH Steam, any casing") + .addMaintenanceHatch("Any casing", 1) + .addInputHatch("Hot fluid, bottom center", 2) + .addInputHatch("Distilled water, any casing", 1) + .addOutputHatch("Cold fluid, top center", 3) + .addOutputHatch("Steam/SH Steam, any casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index 41b40f56fa..17417a09c8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -51,11 +51,11 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Cub .addController("Front center") .addCasingInfo("Solid Steel Machine Casing", 16) .addStructureInfo("Casings can be replaced with Explosion Warning Signs") - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addMufflerHatch("Any casing") - .addInputBus("Any casing") - .addOutputBus("Any casing") + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index 7f409f38f4..8565ae8774 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -26,7 +26,7 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; @@ -40,26 +40,31 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {"ccc", "ccc", "ccc"}, - {"ccc", "cPc", "ccc"}, - {"ccc", "cPc", "ccc"}, - {"ccc", "cPc", "ccc"}, - {"f~f", "fff", "fff"}, - })) - .addElement('P', defer(t -> ofBlock(t.getPipeBlock(), t.getPipeMeta()))) - .addElement('c', defer(t -> ofChain( - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addOutputToMachineList, t.getCasingTextureIndex(), 2), - onElementPass(GT_MetaTileEntity_LargeBoiler::onCasingAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) - ))) - .addElement('f', defer(t -> ofChain( - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getCasingTextureIndex(), 1), - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getCasingTextureIndex(), 1), - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getCasingTextureIndex(), 1), - onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) - ))) - .build(); + private static final ClassValue> STRUCTURE_DEFINITION =new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "ccc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"f~f", "fff", "fff"}, + })) + .addElement('P', lazy(t -> ofBlock(t.getPipeBlock(), t.getPipeMeta()))) + .addElement('c', lazy(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addOutputToMachineList, t.getCasingTextureIndex(), 2), + onElementPass(GT_MetaTileEntity_LargeBoiler::onCasingAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .addElement('f', lazy(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getCasingTextureIndex(), 1), + onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .build(); + } + }; private boolean firstRun = true; private int mSuperEfficencyIncrease = 0; private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config @@ -92,13 +97,13 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_En .addCasingInfo(getCasingMaterial() + " " + getCasingBlockType() + " Casing", 24)//? .addOtherStructurePart(getCasingMaterial() + " Fire Boxes", "Bottom layer, 3 minimum") .addOtherStructurePart(getCasingMaterial() + " Pipe Casing Blocks", "Inner 3 blocks") - .addMaintenanceHatch("Any firebox") - .addMufflerHatch("Any firebox") - .addInputBus("Solid fuel, Any firebox") - .addInputHatch("Liquid fuel, Any firebox") + .addMaintenanceHatch("Any firebox", 1) + .addMufflerHatch("Any firebox", 1) + .addInputBus("Solid fuel, Any firebox", 1) + .addInputHatch("Liquid fuel, Any firebox", 1) .addStructureInfo("You can use either, or both") - .addInputHatch("Water, Any firebox") - .addOutputHatch("Steam, any casing") + .addInputHatch("Water, Any firebox", 1) + .addOutputHatch("Steam, any casing", 2) .toolTipFinisher("Gregtech"); return tt; } @@ -271,7 +276,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_En @Override public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; + return STRUCTURE_DEFINITION.get(getClass()); } private void onCasingAdded() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index 072f54e4af..63b536fc72 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -47,10 +47,10 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_En onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) )) .addElement('x', ofChain( - ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 2), onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCoilAdded, ofBlock(GregTech_API.sBlockCasings5, 0)), onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) )) @@ -84,13 +84,13 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_En .addController("Front center") .addCasingInfo("Chemically Inert Machine Casing", 8) .addOtherStructurePart("PTFE Pipe Machine Casing", "Center") - .addOtherStructurePart("Cupronickel Coil Block", "Adjacent to the PTFE Pipe Machine Casing") - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputBus("Any casing") - .addInputHatch("Any casing") - .addOutputBus("Any casing") - .addOutputHatch("Any casing") + .addOtherStructurePart("Cupronickel Coil Block", "Adjacent to the PTFE Pipe Machine Casing", 1) + .addEnergyHatch("Any casing", 1, 2) + .addMaintenanceHatch("Any casing", 1, 2) + .addInputBus("Any casing", 1, 2) + .addInputHatch("Any casing", 1, 2) + .addOutputBus("Any casing", 1, 2) + .addOutputHatch("Any casing", 1, 2) .addStructureInfo("You can have multiple hatches/busses") .toolTipFinisher("Gregtech"); return tt; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index fd3117e451..f0a5abbe62 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -22,7 +22,7 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -30,22 +30,27 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, - {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, - {" --- ", "xc~cx", "xh-hx", "xh-hx", "xcdcx",}, - {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, - {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, - })) - .addElement('c', defer(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('d', defer(t -> ofHatchAdder(GT_MetaTileEntity_LargeTurbine::addDynamoToMachineList, t.getCasingTextureIndex(), 0))) - .addElement('h', defer(t -> ofHatchAdderOptional(GT_MetaTileEntity_LargeTurbine::addToMachineList, t.getCasingTextureIndex(), 0, t.getCasingBlock(), t.getCasingMeta()))) - .addElement('x', (IStructureElementCheckOnly) (aContext, aWorld, aX, aY, aZ) -> { - TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); - return !(tTile instanceof IGregTechTileEntity) || !(((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine); - }) - .build(); + private static final ClassValue> STRUCTURE_DEFINITION = new ClassValue>() { + @Override + protected IStructureDefinition computeValue(Class type) { + return StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, + {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, + {" --- ", "xc~cx", "xh-hx", "xh-hx", "xcdcx",}, + {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, + {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, + })) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement('d', lazy(t -> ofHatchAdder(GT_MetaTileEntity_LargeTurbine::addDynamoToMachineList, t.getCasingTextureIndex(), 1))) + .addElement('h', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_LargeTurbine::addToMachineList, t.getCasingTextureIndex(), 2, t.getCasingBlock(), t.getCasingMeta()))) + .addElement('x', (IStructureElementCheckOnly) (aContext, aWorld, aX, aY, aZ) -> { + TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); + return !(tTile instanceof IGregTechTileEntity) || !(((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine); + }) + .build(); + } + }; protected int baseEff = 0; protected int optFlow = 0; @@ -74,7 +79,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E @Override public IStructureDefinition getStructureDefinition() { - return STRUCTURE_DEFINITION; + return STRUCTURE_DEFINITION.get(getClass()); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 27e4bf7084..20f795572e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -46,10 +46,10 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT .beginStructureBlock(3, 3, 4, true) .addController("Front center") .addCasingInfo("Stainless Steel Turbine Casing", 24) - .addDynamoHatch("Back center") - .addMaintenanceHatch("Side centered") - .addMufflerHatch("Side centered") - .addInputHatch("Gas Fuel, Side centered") + .addDynamoHatch("Back center", 1) + .addMaintenanceHatch("Side centered", 2) + .addMufflerHatch("Side centered", 2) + .addInputHatch("Gas Fuel, Side centered", 2) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index 0d22271a34..2c803712f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -54,10 +54,10 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La .beginStructureBlock(3, 3, 4, true) .addController("Front center") .addCasingInfo("Titanium Turbine Casing", 24) - .addDynamoHatch("Back center") - .addMaintenanceHatch("Side centered") - .addInputHatch("Superheated Steam, Side centered") - .addOutputHatch("Steam, Side centered") + .addDynamoHatch("Back center", 1) + .addMaintenanceHatch("Side centered", 2) + .addInputHatch("Superheated Steam, Side centered", 2) + .addOutputHatch("Steam, Side centered", 2) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index d1bf1e7c0b..c34f190242 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -53,10 +53,10 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar .beginStructureBlock(3, 3, 4, true) .addController("Front center") .addCasingInfo("Tungstensteel Turbine Casing", 24) - .addDynamoHatch("Back center") - .addMaintenanceHatch("Side centered") - .addInputHatch("Plasma Fluid, Side centered") - .addOutputHatch("Molten Fluid, optional, Side centered") + .addDynamoHatch("Back center", 1) + .addMaintenanceHatch("Side centered", 2) + .addInputHatch("Plasma Fluid, Side centered", 2) + .addOutputHatch("Molten Fluid, optional, Side centered", 2) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 8990ad3324..356dda9183 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -57,10 +57,10 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg .beginStructureBlock(3, 3, 4, true) .addController("Front center") .addCasingInfo("Turbine Casing", 24) - .addDynamoHatch("Back center") - .addMaintenanceHatch("Side centered") - .addInputHatch("Steam, Side centered") - .addOutputHatch("Distilled Water, Side centered") + .addDynamoHatch("Back center", 1) + .addMaintenanceHatch("Side centered", 2) + .addInputHatch("Steam, Side centered", 2) + .addOutputHatch("Distilled Water, Side centered", 2) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index edfce02aad..907de38f6b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -51,7 +51,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu .addElement('c', ofBlock(GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_MetaTileEntity_MultiFurnace::addMufflerToMachineList, CASING_INDEX, 2)) .addElement('C', GT_StructureUtility.ofCoil(GT_MetaTileEntity_MultiFurnace::setCoilLevel, GT_MetaTileEntity_MultiFurnace::getCoilLevel)) - .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_MultiFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) + .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_MultiFurnace::addBottomHatch, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) .build(); public GT_MetaTileEntity_MultiFurnace(int aID, String aName, String aNameRegional) { @@ -80,11 +80,11 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu .addController("Front bottom") .addCasingInfo("Heat Proof Machine Casing", 8) .addOtherStructurePart("Heating Coils", "Middle layer") - .addEnergyHatch("Any bottom casing") - .addMaintenanceHatch("Any bottom casing") - .addMufflerHatch("Top Middle") - .addInputBus("Any bottom casing") - .addOutputBus("Any bottom casing") + .addEnergyHatch("Any bottom casing", 1) + .addMaintenanceHatch("Any bottom casing", 1) + .addMufflerHatch("Top Middle", 2) + .addInputBus("Any bottom casing", 1) + .addOutputBus("Any bottom casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 8a257db8ee..c8dbe2321a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -52,7 +52,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('r', ofChain( - ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 3), onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('m', ofChain( @@ -91,12 +91,13 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addCasingInfo("Clean Stainless Steel Machine Casing", 18) .addOtherStructurePart("2 Rings of 8 Coils", "Each side of the controller") .addInfo("Gets 5% EU/t reduction per coil tier") - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputHatch("Steam/Hydrogen ONLY, Any middle ring casing") - .addInputHatch("Any left/right side casing") - .addOutputHatch("Any left/right side casing") + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addInputHatch("Steam/Hydrogen ONLY, Any middle ring casing", 1) + .addInputHatch("Any left/right side casing",2, 3) + .addOutputHatch("Any right/left side casing", 2, 3) .addStructureInfo("Input/Output Hatches must be on opposite sides!") + .addStructureHint("GT5U.cracker.io_side") .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 554e5dfd63..76231980ec 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -92,10 +92,10 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D .addStructureInfo(casings + " form the 3x1x3 Base") .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") - .addMaintenanceHatch("Any base casing") - .addInputBus("Mining Pipes or Circuits, optional, any base casing") - .addOutputHatch("Any base casing") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing", 1) + .addMaintenanceHatch("Any base casing", 1) + .addInputBus("Mining Pipes or Circuits, optional, any base casing", 1) + .addOutputHatch("Any base casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 5b4444cec3..b168e44c41 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -350,11 +350,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile .addStructureInfo(casings + " form the 3x1x3 Base") .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") - .addMaintenanceHatch("Any base casing") - .addInputBus("Mining Pipes, optional, any base casing") - .addInputHatch("Drilling Fluid, any base casing") - .addOutputBus("Any base casing") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing", 1) + .addMaintenanceHatch("Any base casing", 1) + .addInputBus("Mining Pipes, optional, any base casing", 1) + .addInputHatch("Drilling Fluid, any base casing", 1) + .addOutputBus("Any base casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index 0a46c47f7c..ea56266b41 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -76,12 +76,12 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu .beginStructureBlock(3, 3, 3, true) .addController("Front center") .addCasingInfo("Robust Tungstensteel Machine Casing", 14) - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputBus("Any casing") - .addInputHatch("Any casing") - .addOutputBus("Any casing") - .addOutputHatch("Any casing") + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addInputBus("Any casing", 1) + .addInputHatch("Any casing", 1) + .addOutputBus("Any casing", 1) + .addOutputHatch("Any casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 7312e0d992..48da2c5dce 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -63,8 +63,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement) )) .addElement('t', ofChain( - ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMufflerToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addInputToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_PyrolyseOven::addMufflerToMachineList, CASING_INDEX, 2), onElementPass(GT_MetaTileEntity_PyrolyseOven::onCasingAdded, tCasingElement) )) .build(); @@ -95,13 +95,13 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu .addController("Front center") .addCasingInfo("Pyrolyse Oven Casing", 60) .addOtherStructurePart("Heating Coils", "Center 3x1x3 of the bottom layer") - .addEnergyHatch("Any bottom layer casing") - .addMaintenanceHatch("Any bottom layer casing") - .addMufflerHatch("Center 3x1x3 area in top layer") - .addInputBus("Center 3x1x3 area in top layer") - .addInputHatch("Center 3x1x3 area in top layer") - .addOutputBus("Any bottom layer casing") - .addOutputHatch("Any bottom layer casing") + .addEnergyHatch("Any bottom layer casing", 1) + .addMaintenanceHatch("Any bottom layer casing", 1) + .addMufflerHatch("Center 3x1x3 area in top layer", 2) + .addInputBus("Center 3x1x3 area in top layer", 2) + .addInputHatch("Center 3x1x3 area in top layer", 2) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("Any bottom layer casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java index bef433e626..b7f24f7e7a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -47,10 +47,10 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMult .beginStructureBlock(3, 3, 3, true) .addController("Front center") .addCasingInfo("Frost Proof Machine Casing", 16) - .addEnergyHatch("Any casing") - .addMaintenanceHatch("Any casing") - .addInputBus("Any casing") - .addOutputBus("Any casing") + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) .toolTipFinisher("Gregtech"); return tt; } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index b0d0018312..ce60b8d70e 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -18,7 +18,27 @@ GT5U.MBTT.Causes=Causes GT5U.MBTT.PPS=pollution per second GT5U.MBTT.Hold=Hold GT5U.MBTT.Display=to display structure guidelines +GT5U.MBTT.StructureHint=Some blocks have multiple candidates or can use any tier GT5U.MBTT.Mod=Added by +GT5U.MBTT.Air=Mandatory Air +GT5U.MBTT.Dots.0=No Dot +GT5U.MBTT.Dots.1=Dot 1 +GT5U.MBTT.Dots.2=Dot 2 +GT5U.MBTT.Dots.3=Dot 3 +GT5U.MBTT.Dots.4=Dot 4 +GT5U.MBTT.Dots.5=Dot 5 +GT5U.MBTT.Dots.6=Dot 6 +GT5U.MBTT.Dots.7=Dot 7 +GT5U.MBTT.Dots.8=Dot 8 +GT5U.MBTT.Dots.9=Dot 9 +GT5U.MBTT.Dots.10=Dot 10 +GT5U.MBTT.Dots.11=Dot 11 +GT5U.MBTT.Dots.12=Dot 12 +GT5U.MBTT.Dots.13=Dot 13 +GT5U.MBTT.Dots.14=Dot 14 +GT5U.MBTT.Dots.15=Dot 15 + +GT5U.cracker.io_side=Input/Output Hatches must be on opposite sides! GT5U.turbine.running.true=Turbine running GT5U.turbine.running.false=Turbine stopped -- cgit From 48a5ee9d53f9b77dd8fabcdefebf3fe465b28b35 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:28:30 +0800 Subject: Make variable size multi's hint length depend on item in hand Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java | 6 +++--- .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 60aa372d20..e9608fce29 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -401,9 +401,9 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_FIRST, stackSize, hintsOnly, 0, 1, 0); - buildPiece(STRUCTURE_PIECE_SECOND, stackSize, hintsOnly, -1, 1, 0); - for (int i = 2; i < 16; i++) { - buildPiece(STRUCTURE_PIECE_LATER, stackSize, hintsOnly, -i, 1, 0); + int tLength = Math.min(stackSize.stackSize + 1, 16); + for (int i = 1; i < tLength; i++) { + buildPiece(i == 1 ? STRUCTURE_PIECE_SECOND : STRUCTURE_PIECE_LATER, stackSize, hintsOnly, -i, 1, 0); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 3710112c9b..5e98943aec 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -267,7 +267,8 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - for (int i = 1; i < 12; i++) { + int tLength = Math.max(12, stackSize.stackSize + 1); + for (int i = 1; i < tLength; i++) { buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 1, i, 0); } } -- cgit From 77f1cb5502d0efad3b76453b2b577d0105e5fd11 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 21 Jul 2021 18:58:04 +0800 Subject: Fix ClassCastException in GT_MetaTileEntity_CubicMultiBlockBase Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_CubicMultiBlockBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index 5499e756ba..b9a3df5e73 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -66,7 +66,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase getStructureDefinition() { - return (IStructureDefinition) STRUCTURE_DEFINITION; + return (IStructureDefinition) STRUCTURE_DEFINITION.get(getClass()); } @Override -- cgit From 5a01df12f0a87fd7d14fe9517247395582472264 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 21 Jul 2021 19:05:49 +0800 Subject: Fix coil hint block usage Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_StructureUtility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index dc916f02e3..2d15f568ab 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -125,7 +125,7 @@ public class GT_StructureUtility { private int getMeta(ItemStack trigger) { // -4 to skip unimplemented tiers - return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.getMaxTier() - 4, Math.max(0, trigger.stackSize)))); + return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.getMaxTier() - 4, Math.max(0, trigger.stackSize - 1)))); } @Override -- cgit From 9267016bf3a3e0ae90c89f3bfc61058f1275207d Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 21 Jul 2021 22:41:53 +0800 Subject: Use upstream existing localization instead of creating our own Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/api/util/GT_Multiblock_Tooltip_Builder.java | 5 +++-- src/main/resources/assets/gregtech/lang/en_US.lang | 16 ---------------- 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java index 84d4bbbd48..9afb9e58c1 100644 --- a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -2,6 +2,7 @@ package gregtech.api.util; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; +import com.gtnewhorizon.structurelib.StructureLibAPI; import gregtech.api.enums.Materials; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -72,14 +73,14 @@ public class GT_Multiblock_Tooltip_Builder { private static final String TT_structurehint = StatCollector.translateToLocal("GT5U.MBTT.StructureHint"); private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); private static final String TT_air = StatCollector.translateToLocal("GT5U.MBTT.Air"); - private static final String[] TT_dots = IntStream.range(0, 16).mapToObj(i -> StatCollector.translateToLocal("GT5U.MBTT.Dots." + i)).toArray(String[]::new); + private static final String[] TT_dots = IntStream.range(0, 16).mapToObj(i -> StatCollector.translateToLocal("structurelib.blockhint." + i + ".name")).toArray(String[]::new); public GT_Multiblock_Tooltip_Builder() { iLines = new LinkedList<>(); sLines = new LinkedList<>(); hLines = new LinkedList<>(); hBlocks = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new); - hBlocks.put(0, TT_air); + hBlocks.put(StructureLibAPI.HINT_BLOCK_META_AIR, TT_air); } /** diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index ce60b8d70e..e173f9cfea 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -21,22 +21,6 @@ GT5U.MBTT.Display=to display structure guidelines GT5U.MBTT.StructureHint=Some blocks have multiple candidates or can use any tier GT5U.MBTT.Mod=Added by GT5U.MBTT.Air=Mandatory Air -GT5U.MBTT.Dots.0=No Dot -GT5U.MBTT.Dots.1=Dot 1 -GT5U.MBTT.Dots.2=Dot 2 -GT5U.MBTT.Dots.3=Dot 3 -GT5U.MBTT.Dots.4=Dot 4 -GT5U.MBTT.Dots.5=Dot 5 -GT5U.MBTT.Dots.6=Dot 6 -GT5U.MBTT.Dots.7=Dot 7 -GT5U.MBTT.Dots.8=Dot 8 -GT5U.MBTT.Dots.9=Dot 9 -GT5U.MBTT.Dots.10=Dot 10 -GT5U.MBTT.Dots.11=Dot 11 -GT5U.MBTT.Dots.12=Dot 12 -GT5U.MBTT.Dots.13=Dot 13 -GT5U.MBTT.Dots.14=Dot 14 -GT5U.MBTT.Dots.15=Dot 15 GT5U.cracker.io_side=Input/Output Hatches must be on opposite sides! -- cgit From f4495a61bd5d20f5784856227a567d03f275b554 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 22 Jul 2021 18:21:24 +0800 Subject: Fix frame box hint & placement Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/api/util/GT_StructureUtility.java | 92 ++++++++++++++++------ .../multi/GT_MetaTileEntity_DrillerBase.java | 7 +- 2 files changed, 73 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 2d15f568ab..a627da4fd6 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -3,18 +3,24 @@ package gregtech.api.util; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; import gregtech.common.blocks.GT_Block_Casings5; import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Function; @@ -24,35 +30,75 @@ public class GT_StructureUtility { throw new AssertionError("Not instantiable"); } - public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots) { - return ofHatchAdder(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1); + public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder aHatchAdder, int aTextureIndex, int aDots) { + return ofHatchAdder(aHatchAdder, aTextureIndex, StructureLibAPI.getBlockHint(), aDots - 1); } - public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta) { - if (IGT_HatchAdder == null || hintBlock == null) { + public static IStructureElement ofFrame(Materials aFrameMaterial) { + if (aFrameMaterial == null) throw new IllegalArgumentException(); + return new IStructureElement() { + + private IIcon[] mIcons; + + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tBase = world.getTileEntity(x, y, z); + if (tBase instanceof BaseMetaPipeEntity) { + BaseMetaPipeEntity tPipeBase = (BaseMetaPipeEntity) tBase; + if (tPipeBase.isInvalidTileEntity()) return false; + if (tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame) + return aFrameMaterial == ((GT_MetaPipeEntity_Frame) tPipeBase.getMetaTileEntity()).mMaterial; + } + return false; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + if (mIcons == null) { + mIcons = new IIcon[6]; + Arrays.fill(mIcons, aFrameMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon()); + } + StructureLibAPI.hintParticleTinted(world, x, y, z, mIcons, aFrameMaterial.mRGBa); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + ItemStack tFrameStack = GT_OreDictUnificator.get(OrePrefixes.frameGt, aFrameMaterial, 1); + if (tFrameStack.getItem() instanceof ItemBlock) { + ItemBlock tFrameStackItem = (ItemBlock) tFrameStack.getItem(); + return tFrameStackItem.placeBlockAt(tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); + } + return false; + } + }; + } + + public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta) { + if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement() { @Override public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); + return tileEntity instanceof IGregTechTileEntity && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); } @Override public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta); + StructureLibAPI.hintParticle(world, x, y, z, aHintBlock, aHintMeta); return true; } }; } - public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { - return ofHatchAdderOptional(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); + public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder aHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + return ofHatchAdderOptional(aHatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); } - public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { - if (IGT_HatchAdder == null || hintBlock == null) { + public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder aHatchAdder, int aTextureIndex, Block aHintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement() { @@ -61,13 +107,13 @@ public class GT_StructureUtility { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); return (tileEntity instanceof IGregTechTileEntity && - IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex)) || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta); + StructureLibAPI.hintParticle(world, x, y, z, aHintBlock, hintMeta); return true; } @@ -83,23 +129,23 @@ public class GT_StructureUtility { * Assume all coils accepted. * @see #ofCoil(BiPredicate, Function) */ - public static IStructureElement ofCoil(BiConsumer heatingCoilSetter, Function heatingCoilGetter) { + public static IStructureElement ofCoil(BiConsumer aHeatingCoilSetter, Function aHeatingCoilGetter) { return ofCoil((t, l) -> { - heatingCoilSetter.accept(t, l); + aHeatingCoilSetter.accept(t, l); return true; - }, heatingCoilGetter); + }, aHeatingCoilGetter); } /** * Heating coil structure element. - * @param heatingCoilSetter Notify the controller of this new coil. + * @param aHeatingCoilSetter Notify the controller of this new coil. * Got called exactly once per coil. * Might be called less times if structure test fails. * If the setter returns false then it assumes the coil is rejected. - * @param heatingCoilGetter Get the current heating level. Null means no coil recorded yet. + * @param aHeatingCoilGetter Get the current heating level. Null means no coil recorded yet. */ - public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter) { - if (heatingCoilSetter == null || heatingCoilGetter == null) { + public static IStructureElement ofCoil(BiPredicate aHeatingCoilSetter, Function aHeatingCoilGetter) { + if (aHeatingCoilSetter == null || aHeatingCoilGetter == null) { throw new IllegalArgumentException(); } return new IStructureElement() { @@ -108,10 +154,10 @@ public class GT_StructureUtility { Block block = world.getBlock(x, y, z); if (!(block instanceof IHeatingCoil)) return false; - HeatingCoilLevel existingLevel = heatingCoilGetter.apply(t), + HeatingCoilLevel existingLevel = aHeatingCoilGetter.apply(t), newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); if (existingLevel == null || existingLevel == HeatingCoilLevel.None) { - return heatingCoilSetter.test(t, newLevel); + return aHeatingCoilSetter.test(t, newLevel); } else { return newLevel == existingLevel; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index a610a502f9..010d1558be 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -40,6 +40,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACT import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_GLOW; import static gregtech.api.enums.Textures.BlockIcons.getCasingTextureForId; +import static gregtech.api.util.GT_StructureUtility.ofFrame; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_EnhancedMultiBlockBase implements IChunkLoader { @@ -61,10 +62,10 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En {" f ", "fcf", " f "}, {"b~b", "bbb", "bbb"}, })) - .addElement('f', lazy(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) - .addElement('c', lazy(t -> ofBlock(t.casingBlock, t.casingMeta))) + .addElement('f', lazy(t -> ofFrame(t.getFrameMaterial()))) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlockItem().getBlock(), t.getCasingBlockItem().get(0).getItemDamage()))) .addElement('b', lazy(t -> ofChain( - ofBlock(t.casingBlock, t.casingMeta), + ofBlock(t.getCasingBlockItem().getBlock(), t.getCasingBlockItem().get(0).getItemDamage()), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), -- cgit From 9166ef000df99c4d5a350abc6a85c798dc17c598 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 22 Jul 2021 19:38:27 +0800 Subject: Fix class loading problem Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/render/GT_RenderedTexture.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index f456b563b5..08ce2125f2 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -15,6 +15,7 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -361,7 +362,9 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { private ExtendedFacing getExtendedFacing(int x, int y, int z) { if (stdOrient) return ExtendedFacing.DEFAULT; - World w = Minecraft.getMinecraft().theWorld; + EntityPlayer player = GT_Mod.gregtechproxy.getThePlayer(); + if (player == null) return ExtendedFacing.DEFAULT; + World w = player.getEntityWorld(); if (w == null) return ExtendedFacing.DEFAULT; TileEntity te = w.getTileEntity(x, y, z); if (te instanceof IGregTechTileEntity) { -- cgit From b7257bb6f7f19400dfdf00c858b1377b32c4dffe Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 22 Jul 2021 20:35:16 +0800 Subject: Fix typo in cubic base structure definition Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../implementations/GT_MetaTileEntity_CubicMultiBlockBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index b9a3df5e73..fa7bb739a9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -35,7 +35,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase>builder() .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ {"hhh", "hhh", "hhh"}, - {"h-h", "hhh", "hhh"}, + {"h~h", "h-h", "hhh"}, {"hhh", "hhh", "hhh"}, })) .addElement('h', ofChain( -- cgit From ebffdd2dfabce1685a9c6245f816dc50a1d488a8 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 27 Jul 2021 02:12:12 +0800 Subject: Fix typo in implosion compressor. fixed DT hint Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../multi/GT_MetaTileEntity_DistillationTower.java | 15 ++++++++++++--- .../multi/GT_MetaTileEntity_ImplosionCompressor.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index 5e98943aec..e7634c6b62 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -38,6 +38,8 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan protected static final int CASING_INDEX = 49; protected static final String STRUCTURE_PIECE_BASE = "base"; protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ {"b~b", "bbb", "bbb"}, @@ -45,6 +47,12 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ {"lll", "lcl", "lll"} })) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][]{ + {"lll", "l-l", "lll"} + })) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][]{ + {"lll", "lll", "lll"} + })) .addElement('b', ofChain( ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1), @@ -267,9 +275,10 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tLength = Math.max(12, stackSize.stackSize + 1); - for (int i = 1; i < tLength; i++) { - buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 1, i, 0); + int tTotalHeight = Math.max(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index 17417a09c8..86792ac81d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -144,7 +144,7 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Cub @Override protected int getHatchTextureIndex() { - return 17; + return 16; } @Override -- cgit From 1f862e953334cee47a942df3847dcab13ffcc54c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:59:31 +0800 Subject: Add documentation for CTM mapping array --- src/main/java/gregtech/common/blocks/GT_Block_Casings4.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 809c76d720..d217064d30 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -14,7 +14,14 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { - private static int[][] mapping = new int[][]{ + /** + * This mapping is used to look up which texture should be used to render the connected texture for fusion casings. + * + * This mapping is computed from that giant if ladder from #getIcon in commit da3421547afadc49938b5b6a7f9a9679afa1d570 + * The exact meaning of these numbers are like black magic. Read the original getIcon implementation to understand why + * it is 0, 1, etc, if that if ladder is even intelligible. + */ + private static final int[][] mapping = new int[][]{ {7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7}, {7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7}, {7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, -- cgit From ea5c515f4769fa83f4eb6268f0b8048f76fbb0ac Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:34:20 +0800 Subject: Make GT_MetaTileEntity_CubicMultiBlockBase easier to use --- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 55 ++++++++++++++++++++-- .../GT_MetaTileEntity_ImplosionCompressor.java | 5 ++ 2 files changed, 55 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index fa7bb739a9..de36b845b2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -13,19 +13,56 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; /** - * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere. + * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing, accepts hatches everywhere. + * * Controller will be placed in front center of the structure. *

* Note: You cannot use different casing for the same Class. Make a new subclass for it. You also should not change the casing * dynamically, i.e. it should be a dumb method returning some sort of constant. *

* Implementation tips: - * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole + *

    + *
  • To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole * {@link #getStructureDefinition()} or change {@link #checkHatches(IGregTechTileEntity, ItemStack)}. The former is a total overkill, while the later cannot * stop the structure check early. - * 2. To limit rotation, override {@link #getInitialAlignmentLimits()} - * - * @param + * Example 1: Require ULV input only: + *
    + * {@code
    + * @Override
    + * public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
    + *     if (aTileEntity == null) return false;
    + *     IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
    + *     if (aMetaTileEntity == null) return false;
    + *     if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
    + *         if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
    + *         ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
    + *         ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
    + *         return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
    + *     }
    + *     if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
    + *         if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
    + *         ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
    + *         ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
    + *         return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
    + *     }
    + *     return false;
    + * }
    + * }
    + * Example 2: Allow dynamo, muffler and prevent energy hatch + *
    + * {@code
    + * @Override
    + * public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
    + *     return addInputToMachineList(aTileEntity, aBaseCasingIndex) ||
    + *         addOutputToMachineList(aTileEntity, aBaseCasingIndex) ||
    + *         addDynamoToMachineList(aTileEntity, aBaseCasingIndex) ||
    + *         addMufflerToMachineList(aTileEntity, aBaseCasingIndex) ||
    + *         addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex);
    + * }
    + * }
  • + *
  • To limit rotation, override {@link #getInitialAlignmentLimits()}
  • + *
+ * @param this */ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase { protected static final String STRUCTURE_PIECE_MAIN = "main"; @@ -58,6 +95,14 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java index 86792ac81d..b71d01ec07 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -60,6 +60,11 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Cub return tt; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + return super.addToMachineList(aTileEntity, aBaseCasingIndex) || addMufflerToMachineList(aTileEntity, aBaseCasingIndex); + } + @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { -- cgit From 99f8c40f2b37b72dea22fba9f05f74253a11dffb Mon Sep 17 00:00:00 2001 From: DreamMasterXXL Date: Fri, 30 Jul 2021 12:09:29 +0200 Subject: fix (GT) build on jenkins --- src/main/java/gregtech/api/util/GT_Utility.java | 54 +++---------------------- 1 file changed, 6 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index bb2c644f95..12ec2427ce 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -10,24 +10,13 @@ import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; import gregtech.api.enchants.Enchantment_Radioactivity; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; -import gregtech.api.enums.Textures; -import gregtech.api.enums.ToolDictNames; +import gregtech.api.enums.*; import gregtech.api.events.BlockScanningEvent; import gregtech.api.interfaces.IBlockContainer; import gregtech.api.interfaces.IDebugableBlock; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IBasicEnergyContainer; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IMachineProgress; -import gregtech.api.interfaces.tileentity.IUpgradableMachine; +import gregtech.api.interfaces.tileentity.*; import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; import gregtech.api.items.GT_MetaGenerated_Tool; @@ -43,11 +32,7 @@ import ic2.api.recipe.RecipeOutput; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.*; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -83,16 +68,9 @@ import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.world.BlockEvent; -import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidContainerItem; -import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.lang.reflect.Constructor; @@ -101,31 +79,11 @@ import java.lang.reflect.Method; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Optional; -import java.util.UUID; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.GT_Values.DW; -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.L; -import static gregtech.api.enums.GT_Values.M; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; +import static gregtech.api.enums.GT_Values.*; import static gregtech.common.GT_Proxy.GTPOLLUTION; import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; -- cgit From 1e7829f1c1c494bc84ff51d38ea6d194a5f423de Mon Sep 17 00:00:00 2001 From: Sphyix Date: Fri, 30 Jul 2021 21:22:13 +0200 Subject: changed rods to work with gt_utility hazmat check --- src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java index e24ed04539..7950672ec2 100644 --- a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java +++ b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java @@ -2,6 +2,7 @@ package gregtech.api.items; import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Utility; import ic2.api.reactor.IReactor; import ic2.api.reactor.IReactorComponent; import ic2.core.IC2Potion; @@ -153,7 +154,7 @@ public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implement public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) { if (this.sRadiation > 0 && (entity instanceof EntityLivingBase)) { EntityLivingBase entityLiving = (EntityLivingBase) entity; - if (!GregTech_API.mIC2Classic&&!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { + if (!GregTech_API.mIC2Classic&&!GT_Utility.isWearingFullRadioHazmat(entityLiving)) { IC2Potion.radiation.applyTo(entityLiving, sRadiation * 20, sRadiation * 10); } } -- cgit From 796e2fa54d29be497ce19f1271262087a27e6e14 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 31 Jul 2021 06:02:40 +0800 Subject: Fix large boiler copy paste error --- .../machines/multi/GT_MetaTileEntity_LargeBoiler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index 8565ae8774..2599d238a9 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -57,10 +57,10 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_En onElementPass(GT_MetaTileEntity_LargeBoiler::onCasingAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) ))) .addElement('f', lazy(t -> ofChain( - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getCasingTextureIndex(), 1), - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getCasingTextureIndex(), 1), - ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getCasingTextureIndex(), 1), - onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getFireboxTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getFireboxTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getFireboxTextureIndex(), 1), + onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getFireboxBlock(), t.getFireboxMeta())) ))) .build(); } -- cgit From c881c22bb0909246a58b2e6ebbb3930a3cfb9b11 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Fri, 30 Jul 2021 23:23:04 -0600 Subject: Change hard dep on IguanaTweaks to soft dep --- src/main/java/gregtech/common/GT_Proxy.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index ec2781c82f..23203dd956 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -559,12 +559,14 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_OreDictUnificator.registerOre("cropTea", GT_ModHandler.getModItem("ganyssurface", "teaLeaves", 1L, 0)); // Clay buckets, which don't get registered until Iguana Tweaks pre-init - OrePrefixes.bucketClay.mContainerItem = GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0); - GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Empty, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); - GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); - FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.Milk.getFluid(1000L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Milk, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L))); + if (Loader.isModLoaded("IguanaTweaksTConstruct")) { + OrePrefixes.bucketClay.mContainerItem = GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Empty, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketFired", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); + GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); + FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.Milk.getFluid(1000L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Milk, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L))); + } // IC2 Hazmat addFullHazmatToIC2Item("hazmatHelmet"); -- cgit From fa473668b9157bd1cd3ec800eb20d40118350845 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Fri, 30 Jul 2021 23:27:18 -0600 Subject: Format long line --- src/main/java/gregtech/common/GT_Proxy.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 23203dd956..de4ceaa05e 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -565,7 +565,12 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Water, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketWater", 1L, 0)); GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Lava, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketLava", 1L, 0)); GT_OreDictUnificator.set(OrePrefixes.bucketClay, Materials.Milk, GT_ModHandler.getModItem("IguanaTweaksTConstruct", "clayBucketMilk", 1L, 0)); - FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(Materials.Milk.getFluid(1000L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Milk, 1L), GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L))); + + FluidContainerRegistry.registerFluidContainer( + new FluidContainerRegistry.FluidContainerData( + Materials.Milk.getFluid(1000L), + GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Milk, 1L), + GT_OreDictUnificator.get(OrePrefixes.bucketClay, Materials.Empty, 1L))); } // IC2 Hazmat -- cgit From 6f3bddfb296a249040835e5f90bc45f5f7c8b024 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 31 Jul 2021 02:16:02 -0600 Subject: Fix iteration over invalid slots --- build.properties | 2 +- .../implementations/GT_MetaTileEntity_Buffer.java | 14 ++++++++++++-- .../automation/GT_MetaTileEntity_ChestBuffer.java | 4 ++-- .../automation/GT_MetaTileEntity_ItemDistributor.java | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 4ffc037d75..3845374b12 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.03 +gt.version=5.09.37.04 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 7f9e21ff65..faea347c67 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -330,10 +330,20 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM protected void fillStacksIntoFirstSlots() { if (bSortStacks) { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) + for (int i = 0; i < mInventory.length - 1; i++) { + if (!isValidSlot(i)) { + continue; + } + + for (int j = i + 1; j < mInventory.length; j++) { + if (!isValidSlot(j)) { + continue; + } + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } } } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index 3830cd3497..ddcea0267e 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -125,9 +125,9 @@ public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { protected void fillStacksIntoFirstSlots() { sortStacks(); // Merge small stacks together - for (int i = 0; i < this.mInventory.length-1;) { + for (int i = 0; i < this.mInventory.length - 2;) { //GT_FML_LOGGER.info( (this.mInventory[i] == null) ? "Slot empty " + i : "Slot " + i + " holds " + this.mInventory[i].getDisplayName()); - for (int j = i + 1; j < this.mInventory.length; j++) { + for (int j = i + 1; j < this.mInventory.length - 1; j++) { if ((this.mInventory[j] != null) && ((GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); //GT_FML_LOGGER.info( "Moving slot " + j + " into slot " + i ); diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index d3b124b79f..af6bda03a3 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -51,7 +51,7 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer @Override protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < this.mInventory.length - 1; i++) { + for (int i = 0; i < this.mInventory.length - 2; i++) { for (int j = i + 1; j < this.mInventory.length - 1; j++) { if ((this.mInventory[j] != null) && ((this.mInventory[i] == null) || (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { -- cgit From 2e47483ecf90b8bb6e12aaa8849980bde597a1d4 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 31 Jul 2021 03:52:44 -0600 Subject: Add comments --- .../common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java | 2 ++ .../tileentities/automation/GT_MetaTileEntity_ItemDistributor.java | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index ddcea0267e..9da0eace39 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -125,6 +125,8 @@ public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { protected void fillStacksIntoFirstSlots() { sortStacks(); // Merge small stacks together + // The last slot of mInventory is invalid, so we need to avoid iterating over it. + // Thus all max indices are reduced by 1 here. for (int i = 0; i < this.mInventory.length - 2;) { //GT_FML_LOGGER.info( (this.mInventory[i] == null) ? "Slot empty " + i : "Slot " + i + " holds " + this.mInventory[i].getDisplayName()); for (int j = i + 1; j < this.mInventory.length - 1; j++) { diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index af6bda03a3..3cf5adff99 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -51,6 +51,8 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer @Override protected void fillStacksIntoFirstSlots() { + // The last slot of mInventory is invalid, so we need to avoid iterating over it. + // Thus all max indices are reduced by 1 here. for (int i = 0; i < this.mInventory.length - 2; i++) { for (int j = i + 1; j < this.mInventory.length - 1; j++) { if ((this.mInventory[j] != null) -- cgit From 290e3d4ddf85fa6f912f5c81028a3032fb6ca1c7 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 1 Aug 2021 02:59:57 +0800 Subject: Fix off by one in cubic multi base and tooltip builder Also added a command to toggle structure lib debug print. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 57 +++------------------- .../api/util/GT_Multiblock_Tooltip_Builder.java | 3 +- src/main/java/gregtech/common/misc/GT_Command.java | 9 +++- 3 files changed, 16 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index de36b845b2..3854a96cda 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -13,56 +13,19 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; /** - * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing, accepts hatches everywhere. - * + * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere. * Controller will be placed in front center of the structure. *

* Note: You cannot use different casing for the same Class. Make a new subclass for it. You also should not change the casing * dynamically, i.e. it should be a dumb method returning some sort of constant. *

* Implementation tips: - *

    - *
  • To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole + * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole * {@link #getStructureDefinition()} or change {@link #checkHatches(IGregTechTileEntity, ItemStack)}. The former is a total overkill, while the later cannot * stop the structure check early. - * Example 1: Require ULV input only: - *
    - * {@code
    - * @Override
    - * public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
    - *     if (aTileEntity == null) return false;
    - *     IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
    - *     if (aMetaTileEntity == null) return false;
    - *     if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
    - *         if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
    - *         ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
    - *         ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
    - *         return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
    - *     }
    - *     if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
    - *         if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
    - *         ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
    - *         ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
    - *         return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
    - *     }
    - *     return false;
    - * }
    - * }
    - * Example 2: Allow dynamo, muffler and prevent energy hatch - *
    - * {@code
    - * @Override
    - * public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
    - *     return addInputToMachineList(aTileEntity, aBaseCasingIndex) ||
    - *         addOutputToMachineList(aTileEntity, aBaseCasingIndex) ||
    - *         addDynamoToMachineList(aTileEntity, aBaseCasingIndex) ||
    - *         addMufflerToMachineList(aTileEntity, aBaseCasingIndex) ||
    - *         addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex);
    - * }
    - * }
  • - *
  • To limit rotation, override {@link #getInitialAlignmentLimits()}
  • - *
- * @param this + * 2. To limit rotation, override {@link #getInitialAlignmentLimits()} + * + * @param */ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase { protected static final String STRUCTURE_PIECE_MAIN = "main"; @@ -95,14 +58,6 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase @@ -123,7 +78,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase getRequiredCasingCount() && + mCasingAmount >= getRequiredCasingCount() && checkHatches(aBaseMetaTileEntity, aStack); } diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java index 9afb9e58c1..3071cb95a3 100644 --- a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -504,7 +504,8 @@ public class GT_Multiblock_Tooltip_Builder { hLines.add(TT_structurehint); iArray = iLines.toArray(new String[0]); sArray = sLines.toArray(new String[0]); - hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey()] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new); + // e.getKey() - 1 because 1 dot is meta 0. + hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey() - 1] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new); } public String[] getInformation() { diff --git a/src/main/java/gregtech/common/misc/GT_Command.java b/src/main/java/gregtech/common/misc/GT_Command.java index a4b46b8cee..13e26353d8 100644 --- a/src/main/java/gregtech/common/misc/GT_Command.java +++ b/src/main/java/gregtech/common/misc/GT_Command.java @@ -1,5 +1,6 @@ package gregtech.common.misc; +import com.gtnewhorizon.structurelib.StructureLib; import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; import gregtech.api.objects.GT_ChunkManager; @@ -40,6 +41,7 @@ public final class GT_Command extends CommandBase { sender.addChatMessage(new ChatComponentText("\"toggle debugSmallOres\" - toggles worldgen small vein debug")); sender.addChatMessage(new ChatComponentText("\"toggle debugStones\" - toggles worldgen stones debug")); sender.addChatMessage(new ChatComponentText("\"toggle debugChunkloaders\" - toggles chunkloaders debug")); + sender.addChatMessage(new ChatComponentText("\"toggle debugMulti\" - toggles structurelib debug")); sender.addChatMessage(new ChatComponentText("\"chunks\" - print a list of the force loaded chunks")); sender.addChatMessage(new ChatComponentText( "\"pollution \" - adds the of the pollution to the current chunk, " + @@ -59,7 +61,7 @@ public final class GT_Command extends CommandBase { } else if (test.equals("toggle")) { String test1 = ss[1].trim(); Stream.of("D1", "D2", "debugCleanroom", "debugDriller", "debugBlockPump", "debugBlockMiner", "debugWorldGen", "debugEntityCramming", - "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders") + "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders", "debugMulti") .filter(s -> test1.isEmpty() || s.startsWith(test1)) .forEach(l::add); @@ -79,6 +81,11 @@ public final class GT_Command extends CommandBase { printHelp(sender); return; } + if ("debugMulti".equals(strings[1])) { + StructureLib.DEBUG_MODE = !StructureLib.DEBUG_MODE; + sender.addChatMessage(new ChatComponentText(strings[1] + " = " + (StructureLib.DEBUG_MODE ? "true" : "false"))); + return; + } try { Field field = GT_Values.class.getDeclaredField(strings[1]); if (field.getType() != boolean.class) { -- cgit From 2eb1d311be0fab6bcf9772fe59afe149d9305f58 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 02:17:27 +0300 Subject: Improved readability of BaseMetaTileEntity receiveClientEvent --- .../api/metatileentity/BaseMetaTileEntity.java | 84 ++++++++++++---------- 1 file changed, 47 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 6c43799638..12d61a43ab 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -25,11 +25,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import gregtech.common.GT_Client; import gregtech.common.GT_Pollution; import ic2.api.Direction; @@ -71,8 +67,8 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; * This is the main TileEntity for EVERYTHING. */ @Optional.InterfaceList(value = { - @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), - @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) + @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), + @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable { private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; protected MetaTileEntity mMetaTileEntity; @@ -80,11 +76,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; protected long[] mAverageEUInput = new long[]{0, 0, 0, 0, 0}, mAverageEUOutput = new long[]{0, 0, 0, 0, 0}; - private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; + private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}; + private final boolean[] mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + private int[] mCoverData = new int[]{0, 0, 0, 0, 0, 0}; + private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false; - private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private short mID = 0; public long mTickTimer = 0; @@ -486,7 +485,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { if (getRandomNumber(10) == 0) { try{ - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); }catch(Exception e){ } @@ -502,9 +501,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return; } if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { - try{ - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - }catch(Exception e){ + try { + GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + }catch(Exception e){ } GT_Log.exp.println("Machine at: "+ this.getXCoord()+" | "+ this.getYCoord()+" | "+ this.getZCoord()+" DIMID: " +this.worldObj.provider.dimensionId + " explosion due to Thunderstorm!"); @@ -670,11 +669,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - receiveClientEvent(0, aTextureData); - receiveClientEvent(1, aUpdateData & 0x7F); - receiveClientEvent(1, aTexturePage | 0x80); - receiveClientEvent(2, aColorData); - receiveClientEvent(3, aRedstoneData); + receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aUpdateData & 0x7F); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aTexturePage | 0x80); + receiveClientEvent(ClientEvents.CHANGE_COLOR, aColorData); + receiveClientEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, aRedstoneData); } @Deprecated @@ -694,11 +693,22 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - receiveClientEvent(0, aTextureData); - receiveClientEvent(1, aUpdateData & 0x7F); - receiveClientEvent(1, 0x80); - receiveClientEvent(2, aColorData); - receiveClientEvent(3, aRedstoneData); + receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aUpdateData & 0x7F); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, 0x80); + receiveClientEvent(ClientEvents.CHANGE_COLOR, aColorData); + receiveClientEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, aRedstoneData); + } + + public static class ClientEvents { + public static final int CHANGE_COMMON_DATA = 0; + public static final int CHANGE_CUSTOM_VALUE = 1; + public static final int CHANGE_COLOR = 2; + public static final int CHANGE_REDSTONE_OUTPUT = 3; + public static final int DO_SOUND = 4; + public static final int START_SOUND_LOOP = 5; + public static final int STOP_SOUND_LOOP = 6; + public static final int CHANGE_LIGHT = 7; } @Override @@ -717,14 +727,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (isClientSide()) { issueTextureUpdate(); switch (aEventID) { - case 0: + case ClientEvents.CHANGE_COMMON_DATA: mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); //mLockUpgrade = ((aValue&32) != 0); mWorks = ((aValue & 64) != 0); break; - case 1: + case ClientEvents.CHANGE_CUSTOM_VALUE: if (hasValidMetaTileEntity()) { if ((aValue & 0x80) == 0) //Is texture index mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); @@ -732,11 +742,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); } break; - case 2: + case ClientEvents.CHANGE_COLOR: if (aValue > 16 || aValue < 0) aValue = 0; mColor = (byte) aValue; break; - case 3: + case ClientEvents.CHANGE_REDSTONE_OUTPUT: mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); @@ -744,19 +754,19 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); break; - case 4: + case ClientEvents.DO_SOUND: if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.doSound((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); break; - case 5: + case ClientEvents.START_SOUND_LOOP: if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.startSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); break; - case 6: + case ClientEvents.STOP_SOUND_LOOP: if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.stopSoundLoop((byte) aValue, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); break; - case 7: + case ClientEvents.CHANGE_LIGHT: mLightValue = (byte) aValue; break; } @@ -1007,7 +1017,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public boolean increaseProgress(int aProgressAmountInTicks) { - return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false; + return canAccessData() && mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks; } @Override @@ -1307,8 +1317,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if ((mOwnerName.length() == 0) && isServerSide()) { setOwnerName(aPlayer.getDisplayName()); setOwnerUuid(aPlayer.getUniqueID()); - } else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) - return false; + } else + return !privateAccess() || aPlayer.getDisplayName().equals("Player") || mOwnerName.equals("Player") || mOwnerName.equals(aPlayer.getDisplayName()); return true; } @@ -1319,10 +1329,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public void doEnergyExplosion() { if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) { - GT_Log.exp.println("Energy Explosion, injected "+getUniversalEnergyStored()+"EU >= "+Double.toString((getUniversalEnergyCapacity() / 5D))+"Capacity of the Machine!"); + GT_Log.exp.println("Energy Explosion, injected " + getUniversalEnergyStored() + "EU >= " + getUniversalEnergyCapacity() / 5D + "Capacity of the Machine!"); doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1)); - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); + GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); } } -- cgit From 025130d2188837b1bc7b2da43f79af8e7d8af20f Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 02:35:03 +0300 Subject: Improved readability of setBlockEvent --- .../api/metatileentity/BaseMetaPipeEntity.java | 57 ++++++++++------------ .../api/metatileentity/BaseMetaTileEntity.java | 44 +++++++++-------- .../api/metatileentity/MetaPipeEntity.java | 23 ++++----- .../api/metatileentity/MetaTileEntity.java | 16 +++--- 4 files changed, 68 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 7f8efed8ce..c2465c1a53 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -1,13 +1,5 @@ package gregtech.api.metatileentity; -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.NW; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; @@ -19,13 +11,10 @@ import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity.ClientEvents; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Fluidfilter; import net.minecraft.block.Block; @@ -41,11 +30,15 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.NW; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -57,9 +50,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE public byte mConnections = IConnectable.NO_CONNECTION; protected MetaPipeEntity mMetaTileEntity; private byte[] mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + private int[] mCoverData = new int[]{0, 0, 0, 0, 0, 0}; + private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false; - private boolean mCheckConnections = false; + private final boolean mCheckConnections = false; private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; private short mID = 0; @@ -331,12 +326,15 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } if (mTickTimer > 10) { - if (mConnections != oTextureData) sendBlockEvent((byte) 0, oTextureData = mConnections); + if (mConnections != oTextureData) + sendBlockEvent(ClientEvents.CHANGE_COMMON_DATA, oTextureData = mConnections); byte tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); - if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); + if (tData != oUpdateData) + sendBlockEvent(ClientEvents.CHANGE_CUSTOM_DATA, oUpdateData = tData); + if (mColor != oColor) sendBlockEvent(ClientEvents.CHANGE_COLOR, oColor = mColor); tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); + if (tData != oRedstoneData) + sendBlockEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, oRedstoneData = tData); } if (mNeedsBlockUpdate) { @@ -654,7 +652,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public boolean increaseProgress(int aProgressAmountInTicks) { - return canAccessData() ? mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks : false; + return canAccessData() && mMetaTileEntity.increaseProgress(aProgressAmountInTicks) != aProgressAmountInTicks; } @Override @@ -1325,15 +1323,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal())) return false; - if(isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + if (isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)) return true; - if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()),aFluid, this)) - return true; - - return false; + return !isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 12d61a43ab..9e26ab648d 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -596,17 +596,21 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (mTickTimer > 10) { byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)| (mWorks ? 64 : 0)); - if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); + if (tData != oTextureData) + sendBlockEvent(ClientEvents.CHANGE_COMMON_DATA, oTextureData = tData); tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); - if(mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + if (tData != oUpdateData) + sendBlockEvent(ClientEvents.CHANGE_CUSTOM_DATA, oUpdateData = tData); + if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { tData = ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage(); - if (tData != oTexturePage) sendBlockEvent((byte) 1, (byte)((oTexturePage = tData)|0x80));//set last bit as a flag for page + if (tData != oTexturePage) + sendBlockEvent(ClientEvents.CHANGE_CUSTOM_DATA, (byte) ((oTexturePage = tData) | 0x80));//set last bit as a flag for page } - if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); + if (mColor != oColor) sendBlockEvent(ClientEvents.CHANGE_COLOR, oColor = mColor); tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); + if (tData != oRedstoneData) + sendBlockEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, oRedstoneData = tData); if (mLightValue != oLightValue) { worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); @@ -617,7 +621,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); issueTextureUpdate(); - sendBlockEvent((byte) 7, oLightValue = mLightValue); + sendBlockEvent(ClientEvents.CHANGE_LIGHT, oLightValue = mLightValue); } } @@ -670,8 +674,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData); - receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aUpdateData & 0x7F); - receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aTexturePage | 0x80); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, aUpdateData & 0x7F); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, aTexturePage | 0x80); receiveClientEvent(ClientEvents.CHANGE_COLOR, aColorData); receiveClientEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, aRedstoneData); } @@ -694,21 +698,21 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); receiveClientEvent(ClientEvents.CHANGE_COMMON_DATA, aTextureData); - receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, aUpdateData & 0x7F); - receiveClientEvent(ClientEvents.CHANGE_CUSTOM_VALUE, 0x80); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, aUpdateData & 0x7F); + receiveClientEvent(ClientEvents.CHANGE_CUSTOM_DATA, 0x80); receiveClientEvent(ClientEvents.CHANGE_COLOR, aColorData); receiveClientEvent(ClientEvents.CHANGE_REDSTONE_OUTPUT, aRedstoneData); } public static class ClientEvents { - public static final int CHANGE_COMMON_DATA = 0; - public static final int CHANGE_CUSTOM_VALUE = 1; - public static final int CHANGE_COLOR = 2; - public static final int CHANGE_REDSTONE_OUTPUT = 3; - public static final int DO_SOUND = 4; - public static final int START_SOUND_LOOP = 5; - public static final int STOP_SOUND_LOOP = 6; - public static final int CHANGE_LIGHT = 7; + public static final byte CHANGE_COMMON_DATA = 0; + public static final byte CHANGE_CUSTOM_DATA = 1; + public static final byte CHANGE_COLOR = 2; + public static final byte CHANGE_REDSTONE_OUTPUT = 3; + public static final byte DO_SOUND = 4; + public static final byte START_SOUND_LOOP = 5; + public static final byte STOP_SOUND_LOOP = 6; + public static final byte CHANGE_LIGHT = 7; } @Override @@ -734,7 +738,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE //mLockUpgrade = ((aValue&32) != 0); mWorks = ((aValue & 64) != 0); break; - case ClientEvents.CHANGE_CUSTOM_VALUE: + case ClientEvents.CHANGE_CUSTOM_DATA: if (hasValidMetaTileEntity()) { if ((aValue & 0x80) == 0) //Is texture index mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 1070c97364..99e018ecdf 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -8,12 +8,9 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity.ClientEvents; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_CoverBehavior; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.api.util.*; import gregtech.common.GT_Client; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -181,10 +178,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { if (difference > 1.05 && difference < 1.4) { aSide = 5; } - boolean tCovered = false; - if (aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0) { - tCovered = true; - } + boolean tCovered = aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0; if(isConnectedAtSide(aSide)){ tCovered = true; } @@ -305,17 +299,20 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public final void sendSound(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.DO_SOUND, aIndex); } @Override public final void sendLoopStart(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.START_SOUND_LOOP, aIndex); } @Override public final void sendLoopEnd(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.STOP_SOUND_LOOP, aIndex); } @Override @@ -769,7 +766,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { if (tTileEntity instanceof IColoredTileEntity) { if (getBaseMetaTileEntity().getColorization() >= 0) { byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) return false; + return tColor < 0 || tColor == getBaseMetaTileEntity().getColorization(); } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index d9f90b06b7..e1a8d65149 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -8,13 +8,10 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity.ClientEvents; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.*; import gregtech.common.GT_Client; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -276,18 +273,21 @@ public abstract class MetaTileEntity implements IMetaTileEntity { @Override public final void sendSound(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 4, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.DO_SOUND, aIndex); } @Override public final void sendLoopStart(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 5, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.START_SOUND_LOOP, aIndex); mSoundRequests++; } @Override public final void sendLoopEnd(byte aIndex) { - if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte) 6, aIndex); + if (!getBaseMetaTileEntity().hasMufflerUpgrade()) + getBaseMetaTileEntity().sendBlockEvent(ClientEvents.STOP_SOUND_LOOP, aIndex); } /** -- cgit From 5f3b8de9a3b0086488ba04d1c74d0edc57f3b7fa Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 02:48:07 +0300 Subject: Improved readability of GT_MetaTileEntity_Boiler#doSound --- .../common/tileentities/boilers/GT_MetaTileEntity_Boiler.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index 7cef8278be..603d438768 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -8,7 +8,10 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -28,6 +31,8 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public boolean mHadNoWater = false; private int mExcessWater = 0; + public static final int SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; + public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); } @@ -329,13 +334,13 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa @Override public void doSound(byte aIndex, double aX, double aY, double aZ) { - if (aIndex == 1) { + if (aIndex == GT_MetaTileEntity_Boiler.SOUND_EVENT_LET_OFF_EXCESS_STEAM) { GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 2, 1.0F, aX, aY, aZ); new WorldSpawnedEventBuilder.ParticleEventBuilder() .setIdentifier("largesmoke") .setWorld(getBaseMetaTileEntity().getWorld()) - .setMotion(0D,0D,0D) + .setMotion(0D, 0D, 0D) .times(8, x -> x .setPosition( aX - 0.5D + XSTR_INSTANCE.nextFloat(), -- cgit From 78122fa488ac0136c769ebed094cea261cf3d034 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Sun, 1 Aug 2021 16:26:18 +0800 Subject: increase the generator's eu capacity --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 63151bde59..48d1bd8a18 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 @@ -152,7 +152,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 40L + getMinimumStoredEU()); + return Math.max(getEUVar(), V[mTier] * 80L + getMinimumStoredEU()); } @Override -- cgit From 8f03656f3fa8794a4051de499d45a48392c76853 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 1 Aug 2021 03:22:45 -0600 Subject: Fix molten cells for some fluids --- build.properties | 2 +- src/main/java/gregtech/api/enums/Materials.java | 2 +- .../gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 3845374b12..6f7b5408b8 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.04 +gt.version=5.09.37.05 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 905e08a434..9075a0a013 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -2068,7 +2068,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { //SuperconductorUV .add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); SuperconductorUHV.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); - Blaze.add(SubTag.MAGICAL, SubTag.NO_SMELTING, SubTag.SMELTING_TO_FLUID, SubTag.MORTAR_GRINDABLE, SubTag.UNBURNABLE, SubTag.BURNING); + Blaze.add(SubTag.MAGICAL, SubTag.SMELTING_TO_FLUID, SubTag.MORTAR_GRINDABLE, SubTag.UNBURNABLE, SubTag.BURNING); FierySteel.add(SubTag.MAGICAL, SubTag.UNBURNABLE, SubTag.BURNING); // ElvenElementium .add(SubTag.MAGICAL); DarkThaumium.add(SubTag.MAGICAL); diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index c50ca5a047..4fbc25f226 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -540,10 +540,10 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { Materials.Water.mSolid = Materials.Ice.mSolid; - GT_Mod.gregtechproxy.addFluid("molten.glass", "Molten Glass", Materials.Glass, 4, 1500); - GT_Mod.gregtechproxy.addFluid("molten.redstone", "Molten Redstone", Materials.Redstone, 4, 500); - GT_Mod.gregtechproxy.addFluid("molten.blaze", "Molten Blaze", Materials.Blaze, 4, 6400); - GT_Mod.gregtechproxy.addFluid("wet.concrete", "Wet Concrete", Materials.Concrete, 4, 300); + GT_Mod.gregtechproxy.addFluid("molten.glass", "Molten Glass", Materials.Glass, 4, 1500, GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Glass, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 144); + GT_Mod.gregtechproxy.addFluid("molten.redstone", "Molten Redstone", Materials.Redstone, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Redstone, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 144); + GT_Mod.gregtechproxy.addFluid("molten.blaze", "Molten Blaze", Materials.Blaze, 4, 6400, GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Blaze, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 144); + GT_Mod.gregtechproxy.addFluid("wet.concrete", "Wet Concrete", Materials.Concrete, 4, 300, GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Concrete, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 144); for (Materials tMaterial : Materials.values()) { if ((tMaterial.mStandardMoltenFluid == null) && (tMaterial.contains(SubTag.SMELTING_TO_FLUID)) && (!tMaterial.contains(SubTag.NO_SMELTING))) { -- cgit From f1fb6fbfd7dd1a59e0105693c5f8f5ce6bfd343f Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 1 Aug 2021 04:08:15 -0600 Subject: Delete no longer needed recipes --- .../java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index b0293cde7b..f1039b7159 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -266,16 +266,6 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addFluidCannerRecipe(ItemList.Battery_Hull_HV.get(1L), ItemList.Battery_SU_HV_SulfuricAcid.getWithCharge(1L, Integer.MAX_VALUE), Materials.SulfuricAcid.getFluid(16000L), GT_Values.NF); GT_Values.RA.addFluidCannerRecipe(ItemList.TF_Vial_FieryTears.get(1L), ItemList.Bottle_Empty.get(1L), GT_Values.NF, Materials.FierySteel.getFluid(250L)); - GT_Values.RA.addFluidCannerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Concrete, 1L), ItemList.Cell_Empty.get(1L), GT_Values.NF, Materials.Concrete.getMolten(144L)); - GT_Values.RA.addFluidCannerRecipe(ItemList.Cell_Empty.get(1L), (GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Concrete, 1L)), Materials.Concrete.getMolten(144L), GT_Values.NF); - - GT_Values.RA.addFluidCannerRecipe(ItemList.Cell_Empty.get(1L), (GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Redstone, 1L)), Materials.Redstone.getMolten(144L), GT_Values.NF); - GT_Values.RA.addFluidCannerRecipe(ItemList.Cell_Empty.get(1L), (GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Glass, 1L)), Materials.Glass.getMolten(144L), GT_Values.NF); - GT_Values.RA.addFluidCannerRecipe(ItemList.Cell_Empty.get(1L), (GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Blaze, 1L)), Materials.Blaze.getMolten(144L), GT_Values.NF); - GT_Values.RA.addFluidCannerRecipe(GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Redstone, 1L), ItemList.Cell_Empty.get(1L), GT_Values.NF, Materials.Redstone.getMolten(144L)); - GT_Values.RA.addFluidCannerRecipe(GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Glass, 1L), ItemList.Cell_Empty.get(1L), GT_Values.NF, Materials.Glass.getMolten(144L)); - GT_Values.RA.addFluidCannerRecipe(GT_OreDictUnificator.get(OrePrefixes.cellMolten, Materials.Blaze, 1L), ItemList.Cell_Empty.get(1L), GT_Values.NF, Materials.Blaze.getMolten(144L)); - Materials tMaterial = Materials.Iron; if (tMaterial.mStandardMoltenFluid != null) { GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Casing.get(0L), tMaterial.getMolten(72L), ItemList.IC2_Item_Casing_Iron.get(1L), 16, 8); -- cgit From 352e16cceb3e419f1ea63af2384b0aced76f9451 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 13:36:40 +0300 Subject: GT_MetaTileEntity_Boiler: Forgot to replace sendSound --- .../common/tileentities/boilers/GT_MetaTileEntity_Boiler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index 603d438768..35a5b7bb03 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -31,7 +31,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public boolean mHadNoWater = false; private int mExcessWater = 0; - public static final int SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; + public static final byte SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); @@ -262,7 +262,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa private void ventSteamIfTankIsFull() { if ((this.mSteam != null) && (this.mSteam.amount > getCapacity())) { - sendSound((byte) 1); + sendSound(SOUND_EVENT_LET_OFF_EXCESS_STEAM); this.mSteam.amount = getCapacity() * 3 / 4; } } -- cgit From 2b52e1fd7ea79887742c41dcea702b1373455932 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 13:44:54 +0300 Subject: Manual merging --- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index e4b7a8e84c..397d03e0df 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -73,8 +73,9 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; *

* This is the main TileEntity for EVERYTHING. */ - @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), - @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) +@Optional.InterfaceList(value = { + @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true), + @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)}) public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider, IConstructableProvider { private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; protected MetaTileEntity mMetaTileEntity; -- cgit From 706c61328fec8d6b4fcbfcd1d6fb1088c1a3422a Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 13:50:26 +0300 Subject: Visibility changes & new methods in GT_MetaTileEntity_Boiler for using them in GTPP --- .../tileentities/boilers/GT_MetaTileEntity_Boiler.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index 35a5b7bb03..5f84e9748c 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -248,7 +248,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa } private void calculateHeatUp(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((this.mTemperature < getMaxTemperature()) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { + if ((this.mTemperature < getMaxTemperature()) && (this.mProcessingEnergy > 0) && (aTick % getHeatUpRate() == 0L)) { this.mProcessingEnergy -= getEnergyConsumption(); this.mTemperature += getHeatUpAmount(); } @@ -277,8 +277,8 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa this.mHadNoWater = true; } else { if (this.mHadNoWater) { - GT_Log.exp.println("Boiler "+this.mName+" had no Water!"); - aBaseMetaTileEntity.doExplosion(2048L); + GT_Log.exp.println("Boiler " + this.mName + " had no Water!"); + onDangerousWaterLack(aBaseMetaTileEntity, aTick); return true; } produceSteam(getProductionPerSecond() / 2); @@ -289,6 +289,10 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa return false; } + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { + tile.doExplosion(2048L); + } + protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, int aSide) { IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide((byte) aSide); if (tTileEntity == null) @@ -375,6 +379,10 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa protected abstract int getCooldownInterval(); + protected int getHeatUpRate() { + return 12; + } + protected int getHeatUpAmount() { return 1; } -- cgit From df4d20faf156f598713e41cbbb2a8f9f34f0d792 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 1 Aug 2021 05:36:53 -0600 Subject: Delete dead code --- src/main/java/gregtech/common/GT_Proxy.java | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index de4ceaa05e..51aadf574e 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1774,11 +1774,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { aMaterial.mMoltenRGBa, 4, aMaterial.mMeltingPoint <= 0 ? 1000 : aMaterial.mMeltingPoint, GT_OreDictUnificator.get(OrePrefixes.cellMolten, aMaterial, 1L), ItemList.Cell_Empty.get(1L), 144); } - public Fluid addAutogeneratedWetFluid(Materials aMaterial) { - return addFluid("wet." + aMaterial.mName.toLowerCase(Locale.ENGLISH), "wet.autogenerated", "Wet " + aMaterial.mDefaultLocalName, aMaterial, - aMaterial.mMoltenRGBa, 4, aMaterial.mMeltingPoint <= 0 ? 1000 : aMaterial.mMeltingPoint, GT_OreDictUnificator.get(OrePrefixes.cell, aMaterial, 1L), ItemList.Cell_Empty.get(1L), 144); - } - public Fluid addAutogeneratedPlasmaFluid(Materials aMaterial) { return addFluid("plasma." + aMaterial.mName.toLowerCase(Locale.ENGLISH), "plasma.autogenerated", aMaterial.mDefaultLocalName + " Plasma", aMaterial, aMaterial.mMoltenRGBa, 3, 10000, GT_OreDictUnificator.get(OrePrefixes.cellPlasma, aMaterial, 1L), ItemList.Cell_Empty.get(1L), 1000); -- cgit From 7b9fe5ad03a9bbf79c249956828d3c54d6d04220 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Sun, 1 Aug 2021 16:29:31 +0300 Subject: Boiler: when filled with bucket being in creative mode, it doesn't transform water bucket back to empty bucket. --- .../common/tileentities/boilers/GT_MetaTileEntity_Boiler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index 35a5b7bb03..d2784e649f 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -111,7 +111,10 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa if (aPlayer != null) { if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) { fill(Materials.Water.getFluid(1000L * (long) aPlayer.getCurrentEquippedItem().stackSize), true); - aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); + + if (!aPlayer.capabilities.isCreativeMode) { + aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); + } } else { aBaseMetaTileEntity.openGUI(aPlayer); } -- cgit From c9911352154acaa7c3544c3ef8e4a212bb103e20 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 1 Aug 2021 22:11:30 +0800 Subject: Make gtpp happy Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../machines/multi/GT_MetaTileEntity_FusionComputer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 88604979d2..7084111000 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -16,6 +16,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_GUIContainer_FusionReactor; @@ -162,6 +163,19 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity return STRUCTURE_DEFINITION.get(getClass()); } + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addController("Fusion Reactor") + .addInfo("Some kind of fusion reactor, maybe") + .addSeparator() + .addInfo("Some kind of fusion reactor, maybe") + .addStructureInfo("Should probably be built similar to other fusions") + .addStructureInfo("See controller tooltip for details") + .toolTipFinisher("Gregtech"); + return tt; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { if (checkPiece(STRUCTURE_PIECE_MAIN, 7, 1, 12) && mInputHatches.size() > 1 && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty()) { -- cgit From 3e59d9f8f2db7d56d9b1431b1e3b93c97752e20a Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 1 Aug 2021 16:29:52 -0600 Subject: Add cracked fluid cells --- build.properties | 2 +- src/main/java/gregtech/api/enums/OrePrefixes.java | 30 ++++- .../GT_MetaTileEntity_BasicGenerator.java | 21 +-- src/main/java/gregtech/api/util/GT_ModHandler.java | 17 ++- src/main/java/gregtech/common/GT_Proxy.java | 28 ++-- .../common/items/GT_MetaGenerated_Item_04.java | 146 +++++++++++++++++++++ .../preload/GT_Loader_Item_Block_And_Fluid.java | 1 + 7 files changed, 222 insertions(+), 23 deletions(-) create mode 100644 src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java (limited to 'src') diff --git a/build.properties b/build.properties index 6f7b5408b8..9c6f282480 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.05 +gt.version=5.09.37.06 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 3aaea29f28..77b6ee9426 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -1,6 +1,7 @@ package gregtech.api.enums; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.interfaces.ICondition; @@ -319,8 +320,27 @@ public enum OrePrefixes { bars("Bars", "", "", false, false, false, false, false, false, false, false, false, false, 0, -1, 64, -1), bar("Bars", "", "", false, false, false, false, false, false, false, false, false, false, 0, -1, 64, -1), toolHeadMallet("Mallet Heads", "", " Mallet Head", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 127), // Reverse Head consisting out of 6 Ingots. - handleMallet("Mallet Handle", "", " Handle", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 126); // Reverse Stick made of half an Ingot. Introduced by Eloraam - + handleMallet("Mallet Handle", "", " Handle", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 126), // Reverse Stick made of half an Ingot. Introduced by Eloraam + + // Cracked fluids + cellHydroCracked1("Cells", "Lightly Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellHydroCracked2("Cells", "Moderately Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellHydroCracked3("Cells", "Severely Hydro-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked1("Cells", "Lightly Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked2("Cells", "Moderately Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30), + cellSteamCracked3("Cells", "Severely Steam-Cracked ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 30); + + public static final ImmutableList CELL_TYPES = + ImmutableList.of( + cell, cellMolten, cellPlasma, + cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, + cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); + + public static final ImmutableList CRACKED_CELL_TYPES = + ImmutableList.of( + cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, + cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); + public static volatile int VERSION = 509; static { @@ -531,6 +551,12 @@ public enum OrePrefixes { cell.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellPlasma.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); cellMolten.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellHydroCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + cellSteamCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); oreRedgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteRed, dust.mMaterialAmount); oreBlackgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteBlack, dust.mMaterialAmount); oreNetherrack.mSecondaryMaterial = new MaterialStack(Materials.Netherrack, dust.mMaterialAmount); 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 48d1bd8a18..57f7073e24 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 @@ -245,16 +245,17 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public boolean solidFuelOverride(ItemStack stack) { //this could be used for a coal generator for example aswell... ItemData association = GT_OreDictUnificator.getAssociation(stack); - //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK, cell, motlen cell or plasma cell, else do vanilla checks - return association != null ? !OrePrefixes.cell.equals(association.mPrefix) && - !OrePrefixes.cellMolten.equals(association.mPrefix) && - !OrePrefixes.cellPlasma.equals(association.mPrefix) && - !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true) : - stack != null && //when the stack is null its not a solid - stack.getItem() != null && //when the item in the stack is null its not a solid - !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... - !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... - !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK or any type of cell, else do vanilla checks + if (association != null) { + return !OrePrefixes.CELL_TYPES.contains(association.mPrefix) && + !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true); + } else { + return stack != null && //when the stack is null its not a solid + stack.getItem() != null && //when the item in the stack is null its not a solid + !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... + !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... + !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + } } public abstract int getPollution(); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index ac9f7bd3d4..a910723069 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -2008,7 +2008,22 @@ public class GT_ModHandler { public static int getCapsuleCellContainerCount(ItemStack aStack) { if (aStack == null) return 0; - return GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(aStack, true), ItemList.Cell_Empty.get(1)) || OrePrefixes.cell.contains(aStack) || OrePrefixes.cellMolten.contains(aStack) || OrePrefixes.cellPlasma.contains(aStack) || GT_Utility.areStacksEqual(aStack, getIC2Item("waterCell", 1, W)) ? 1 : 0; + + if (GT_Utility.areStacksEqual(GT_Utility.getContainerForFilledItem(aStack, true), ItemList.Cell_Empty.get(1))) { + return 1; + } + + if (GT_Utility.areStacksEqual(aStack, getIC2Item("waterCell", 1, W))) { + return 1; + } + + for (OrePrefixes cellType : OrePrefixes.CELL_TYPES) { + if (cellType.contains(aStack)) { + return 1; + } + } + + return 0; } public static class RecipeBits { diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 51aadf574e..3e76335410 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1781,8 +1781,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public void addAutoGeneratedHydroCrackedFluids(Materials aMaterial){ Fluid[] crackedFluids = new Fluid[3]; - String[] prefixes = {"lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked."}; - String[] localPrefixes = {"Lightly Hydro-Cracked ", "Moderately Hydro-Cracked ", "Severely Hydro-Cracked "}; + String[] namePrefixes = { "lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked." }; + OrePrefixes[] orePrefixes = { OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3 }; GT_Fluid uncrackedFluid = null; if (aMaterial.mFluid != null) { uncrackedFluid = (GT_Fluid) aMaterial.mFluid; @@ -1790,8 +1790,13 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { uncrackedFluid = (GT_Fluid) aMaterial.mGas; } for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid(prefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, - localPrefixes[i] + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, null, null, 0); + crackedFluids[i] = addFluid( + namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, + orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, + null, aMaterial.mRGBa, 2, 775, + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), + ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + int hydrogenAmount = 2 * i + 2; GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), Materials.Hydrogen.getGas(hydrogenAmount * 1000), new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 120 + 60 * i); @@ -1805,8 +1810,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public void addAutoGeneratedSteamCrackedFluids(Materials aMaterial){ Fluid[] crackedFluids = new Fluid[3]; - String[] prefixes = {"lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked."}; - String[] localPrefixes = {"Lightly Steam-Cracked ", "Moderately Steam-Cracked ", "Severely Steam-Cracked "}; + String[] namePrefixes = { "lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked." }; + OrePrefixes[] orePrefixes = { OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3 }; GT_Fluid uncrackedFluid = null; if (aMaterial.mFluid != null) { uncrackedFluid = (GT_Fluid) aMaterial.mFluid; @@ -1814,9 +1819,14 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { uncrackedFluid = (GT_Fluid) aMaterial.mGas; } for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid(prefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, - localPrefixes[i] + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, null, null, 0); - GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), + crackedFluids[i] = addFluid( + namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, + orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, + null, aMaterial.mRGBa, 2, 775, + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), + ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + + GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); GT_Values.RA.addChemicalRecipe(GT_ModHandler.getIC2Item("steamCell", 1L), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java new file mode 100644 index 0000000000..728128ac39 --- /dev/null +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java @@ -0,0 +1,146 @@ +package gregtech.common.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.BitSet; +import java.util.List; + +import static gregtech.api.enums.GT_Values.M; + +/** Generates cells for cracked fluids. */ +public class GT_MetaGenerated_Item_04 extends GT_MetaGenerated_Item { + public static GT_MetaGenerated_Item_04 INSTANCE; + + private static final int NUM_CRACKED_CELL_TYPES = OrePrefixes.CRACKED_CELL_TYPES.size(); + + private BitSet enabled = new BitSet(); + + public GT_MetaGenerated_Item_04() { + super("metaitem.04", (short) (NUM_CRACKED_CELL_TYPES * 1000), (short) 0); + INSTANCE = this; + + for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { + if (tMaterial == null || !tMaterial.canBeCracked() || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1000) { + continue; + } + register(tMaterial, tMaterial.mMetaItemSubID); + } + + // We're not going to use these BitSets, so clear them to save memory. + mEnabledItems.clear(); + mVisibleItems.clear(); + } + + private void register(Materials tMaterial, int i) { + int currIndex = NUM_CRACKED_CELL_TYPES * i; + for (OrePrefixes type : OrePrefixes.CRACKED_CELL_TYPES) { + ItemStack tStack = new ItemStack(this, 1, currIndex); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", type.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(type.mMaterialAmount / M)); + + if (type.mIsUnificatable) { + GT_OreDictUnificator.set(type, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(type.get(tMaterial), tStack); + } + + enabled.set(currIndex); + currIndex++; + } + } + + private int getMaterialIndex(int damage) { + return damage / NUM_CRACKED_CELL_TYPES; + } + + /** Returns null for item damage out of bounds. */ + private OrePrefixes getOrePrefix(int damage) { + if (damage < 0 || damage >= NUM_CRACKED_CELL_TYPES * 1000) { + return null; + } + return OrePrefixes.CRACKED_CELL_TYPES.get(damage % NUM_CRACKED_CELL_TYPES); + } + + @Override + public short[] getRGBa(ItemStack aStack) { + Materials tMaterial = GregTech_API.sGeneratedMaterials[getMaterialIndex(aStack.getItemDamage())]; + return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + + int index = getMaterialIndex(aStack.getItemDamage()); + if (index >= 0 && index < 1000) { + return Materials.getLocalizedNameForItem(aName, index); + } + + return aName; + } + + @Override + public ItemStack getContainerItem(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mContainerItem; + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + enabled.stream() + .mapToObj(i -> new ItemStack(this, 1, i)) + .forEach(aList::add); + } + + @Override + public final IIcon getIconFromDamage(int aMetaData) { + IIconContainer iconContainer = getIconContainer(aMetaData); + if (iconContainer != null) { + return iconContainer.getIcon(); + } + return null; + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + int index = getMaterialIndex(aMetaData); + if (index < 0 || index >= 1000) { + return null; + } + + Materials material = GregTech_API.sGeneratedMaterials[index]; + OrePrefixes prefix = getOrePrefix(aMetaData); + if (material != null && prefix != null) { + return material.mIconSet.mTextures[prefix.mTextureIndex]; + } + + return null; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mDefaultStackSize; + } else { + // If we're here, then something went wrong. Use cell.mDefaultStackSize as a fallback. + return OrePrefixes.cell.mDefaultStackSize; + } + } +} diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index 4fbc25f226..77b65e5b18 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -71,6 +71,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { new GT_MetaGenerated_Item_01(); new GT_MetaGenerated_Item_02(); new GT_MetaGenerated_Item_03(); + new GT_MetaGenerated_Item_04(); new GT_MetaGenerated_Item_99(); new GT_MetaGenerated_Tool_01(); new GT_FluidDisplayItem(); -- cgit From c1784444456a9716f739de628ff5877bd0e8dee8 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Mon, 2 Aug 2021 18:31:50 +0800 Subject: add integrated circuit for coolant --- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index f1039b7159..5695180528 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -145,8 +145,8 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.LightFuel, 5L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(5), Materials.HeavyFuel.getFluid(1000L), Materials.Fuel.getFluid(6000L), Materials.Empty.getCells(5), 16, 120); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.HeavyFuel, 1L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(6), Materials.LightFuel.getFluid(5000L), Materials.Fuel.getFluid(6000L), Materials.Empty.getCells(1), 16, 120); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Water, 5L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L), GT_Values.NI, GT_Values.NI, Materials.Lubricant.getFluid(20), new FluidStack(ItemList.sDrillingFluid, 5000), Materials.Empty.getCells(5), 64, 16); - GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Water.getFluid(125), FluidRegistry.getFluidStack("ic2coolant", 125), GT_Values.NI, 256, 48); - GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Values.NI, GT_Values.NI, GT_Values.NI, GT_ModHandler.getDistilledWater(1000), FluidRegistry.getFluidStack("ic2coolant", 1000), GT_Values.NI, 256, 48); + GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(1), GT_Values.NI, GT_Values.NI, Materials.Water.getFluid(125), FluidRegistry.getFluidStack("ic2coolant", 125), GT_Values.NI, 256, 48); + GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(1), GT_Values.NI, GT_Values.NI, GT_ModHandler.getDistilledWater(1000), FluidRegistry.getFluidStack("ic2coolant", 1000), GT_Values.NI, 256, 48); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 4L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(1), Materials.Creosote.getFluid(1000), null, ItemList.SFMixture.get(8), 1600, 16); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 4L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(1), Materials.Creosote.getFluid(1000), null, ItemList.SFMixture.get(8), 1600, 16); @@ -3624,5 +3624,3 @@ public class GT_MachineRecipeLoader implements Runnable { } } } - - -- cgit From c5696af87dd08b75cf1a3e7d738f82acd060680f Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Mon, 2 Aug 2021 22:04:38 +0300 Subject: Added some constructors to Hatch Buses to remove some GTPP ASM --- .../GT_MetaTileEntity_Hatch_InputBus.java | 32 ++++++++++++---------- .../GT_MetaTileEntity_Hatch_OutputBus.java | 29 ++++++++++++-------- .../java/gregtech/api/util/extensions/Arrays.java | 32 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 src/main/java/gregtech/api/util/extensions/Arrays.java (limited to 'src') 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 ebda3cccbc..7d9cd4f780 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 @@ -1,14 +1,7 @@ package gregtech.api.metatileentity.implementations; import gregtech.GT_Mod; -import gregtech.api.gui.GT_Container_1by1; -import gregtech.api.gui.GT_Container_2by2; -import gregtech.api.gui.GT_Container_3by3; -import gregtech.api.gui.GT_Container_4by4; -import gregtech.api.gui.GT_GUIContainer_1by1; -import gregtech.api.gui.GT_GUIContainer_2by2; -import gregtech.api.gui.GT_GUIContainer_3by3; -import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -17,6 +10,7 @@ import gregtech.api.util.GT_ClientPreference; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.Arrays; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -30,19 +24,29 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public boolean disableSort; public boolean disableFilter = false; - public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ + public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier) { + this(id, name, nameRegional, tier, getSlots(tier)); + } + + public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots) { + super(id, name, nameRegional, tier, slots, Arrays.of( "Item Input for Multiblocks", "Shift + right click with screwdriver to turn Sort mode on/off", - "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")}); + "Capacity: " + slots + " stack" + (slots >= 2 ? "s" : ""))); } + @Deprecated + // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_InputBus(String, int, String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + this(aName, aTier, Arrays.of(aDescription), aTextures); } public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + this(aName, aTier, getSlots(aTier), aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, int aSlots, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aSlots, aDescription, aTextures); } @Override @@ -176,7 +180,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled"))); } else { disableFilter = !disableFilter; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter."+disableFilter)); + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + disableFilter)); } } 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 a46157fb36..86e95b2234 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,18 +1,12 @@ package gregtech.api.metatileentity.implementations; -import gregtech.api.gui.GT_Container_1by1; -import gregtech.api.gui.GT_Container_2by2; -import gregtech.api.gui.GT_Container_3by3; -import gregtech.api.gui.GT_Container_4by4; -import gregtech.api.gui.GT_GUIContainer_1by1; -import gregtech.api.gui.GT_GUIContainer_2by2; -import gregtech.api.gui.GT_GUIContainer_3by3; -import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.Arrays; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -23,8 +17,13 @@ import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Output for Multiblocks", - "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")}); + this(aID, aName, aNameRegional, aTier, getSlots(aTier)); + } + + public GT_MetaTileEntity_Hatch_OutputBus(int id, String name, String nameRegional, int tier, int slots) { + super(id, name, nameRegional, tier, slots, Arrays.of( + "Item Output for Multiblocks", + "Capacity: " + getSlots(tier) + " stack" + (getSlots(tier) >= 2 ? "s" : ""))); } public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { @@ -35,18 +34,24 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { super(aID, aName, aNameRegional, aTier, inventorySize, aDescription); } + @Deprecated + // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_OutputBus(String, int, String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + this(aName, aTier, getSlots(aTier), Arrays.of(aDescription), aTextures); } public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + super(aName, aTier, getSlots(aTier), aDescription, aTextures); } public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String[] aDescription, int inventorySize, ITexture[][][] aTextures) { super(aName, aTier, inventorySize, aDescription, aTextures); } + public GT_MetaTileEntity_Hatch_OutputBus(String name, int tier, int slots, String[] description, ITexture[][][] textures) { + super(name, tier, slots, description, textures); + } + @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; diff --git a/src/main/java/gregtech/api/util/extensions/Arrays.java b/src/main/java/gregtech/api/util/extensions/Arrays.java new file mode 100644 index 0000000000..41efec5587 --- /dev/null +++ b/src/main/java/gregtech/api/util/extensions/Arrays.java @@ -0,0 +1,32 @@ +package gregtech.api.util.extensions; + +public class Arrays { + public static int[] of(int... objects) { + return objects; + } + + public static float[] of(float... objects) { + return objects; + } + + public static double[] of(double... objects) { + return objects; + } + + public static char[] of(char... objects) { + return objects; + } + + public static byte[] of(byte... objects) { + return objects; + } + + public static long[] of(long... objects) { + return objects; + } + + @SafeVarargs + public static T[] of(T... objects) { + return objects; + } +} -- cgit From 93d5b74820925ecbc8b105d7c1c42be1f2c9d217 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 3 Aug 2021 14:58:32 +0300 Subject: OutputBus: removed excess constructor with the same parameters --- .../implementations/GT_MetaTileEntity_Hatch_OutputBus.java | 4 ---- .../tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'src') 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 86e95b2234..7f5970d184 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 @@ -44,10 +44,6 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { super(aName, aTier, getSlots(aTier), aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String[] aDescription, int inventorySize, ITexture[][][] aTextures) { - super(aName, aTier, inventorySize, aDescription, aTextures); - } - public GT_MetaTileEntity_Hatch_OutputBus(String name, int tier, int slots, String[] description, ITexture[][][] textures) { super(name, tier, slots, description, textures); } diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index 4b6ce12e65..6b1ee8c941 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -2,7 +2,6 @@ package gregtech.common.tileentities.machines; import appeng.api.AEApi; import appeng.api.networking.GridFlags; -import appeng.api.networking.energy.IEnergySource; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.MachineSource; @@ -22,7 +21,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; @@ -45,7 +43,7 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc } public GT_MetaTileEntity_Hatch_OutputBus_ME(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, 0, aTextures); + super(aName, aTier, 0, aDescription, aTextures); } @Override -- cgit From 878b9ac656aa21727bcd42e4835d0e7f067983ea Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 3 Aug 2021 21:03:45 +0300 Subject: Well, the name 'Arrays' seems to be not so good, since it collides with java.util.Arrays --- .../GT_MetaTileEntity_Hatch_InputBus.java | 6 +-- .../GT_MetaTileEntity_Hatch_OutputBus.java | 6 +-- .../gregtech/api/util/extensions/ArrayExt.java | 59 ++++++++++++++++++++++ .../java/gregtech/api/util/extensions/Arrays.java | 32 ------------ 4 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 src/main/java/gregtech/api/util/extensions/ArrayExt.java delete mode 100644 src/main/java/gregtech/api/util/extensions/Arrays.java (limited to 'src') 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 7d9cd4f780..cfb4d33150 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 @@ -10,7 +10,7 @@ import gregtech.api.util.GT_ClientPreference; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; -import gregtech.api.util.extensions.Arrays; +import gregtech.api.util.extensions.ArrayExt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -29,7 +29,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { } public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots) { - super(id, name, nameRegional, tier, slots, Arrays.of( + super(id, name, nameRegional, tier, slots, ArrayExt.of( "Item Input for Multiblocks", "Shift + right click with screwdriver to turn Sort mode on/off", "Capacity: " + slots + " stack" + (slots >= 2 ? "s" : ""))); @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Deprecated // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_InputBus(String, int, String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - this(aName, aTier, Arrays.of(aDescription), aTextures); + this(aName, aTier, ArrayExt.of(aDescription), aTextures); } public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { 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 7f5970d184..f997f5f489 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 @@ -6,7 +6,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; -import gregtech.api.util.extensions.Arrays; +import gregtech.api.util.extensions.ArrayExt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -21,7 +21,7 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { } public GT_MetaTileEntity_Hatch_OutputBus(int id, String name, String nameRegional, int tier, int slots) { - super(id, name, nameRegional, tier, slots, Arrays.of( + super(id, name, nameRegional, tier, slots, ArrayExt.of( "Item Output for Multiblocks", "Capacity: " + getSlots(tier) + " stack" + (getSlots(tier) >= 2 ? "s" : ""))); } @@ -37,7 +37,7 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { @Deprecated // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_OutputBus(String, int, String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - this(aName, aTier, getSlots(aTier), Arrays.of(aDescription), aTextures); + this(aName, aTier, getSlots(aTier), ArrayExt.of(aDescription), aTextures); } public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/gregtech/api/util/extensions/ArrayExt.java b/src/main/java/gregtech/api/util/extensions/ArrayExt.java new file mode 100644 index 0000000000..faa01cb368 --- /dev/null +++ b/src/main/java/gregtech/api/util/extensions/ArrayExt.java @@ -0,0 +1,59 @@ +package gregtech.api.util.extensions; + +import java.util.function.IntFunction; + +public class ArrayExt { + public static int[] of(int... objects) { + return objects; + } + + public static float[] of(float... objects) { + return objects; + } + + public static double[] of(double... objects) { + return objects; + } + + public static char[] of(char... objects) { + return objects; + } + + public static byte[] of(byte... objects) { + return objects; + } + + public static long[] of(long... objects) { + return objects; + } + + @SafeVarargs + public static T[] of(T... objects) { + return objects; + } + + public static T[] withoutTrailingNulls(T[] array, IntFunction arrayFactory) { + int firstNull = -1; + for (int i = 0; i < array.length; i++) { + if (array[i] == null) { + if (firstNull == -1) { + firstNull = i; + } + } else { + firstNull = -1; + } + } + + if (firstNull == -1) { + T[] newArray = arrayFactory.apply(array.length); + System.arraycopy(array, 0, newArray, 0, array.length); + return newArray; + } else if (firstNull == 0) { + return arrayFactory.apply(0); + } else { + T[] newArray = arrayFactory.apply(firstNull); + System.arraycopy(array, 0, newArray, 0, firstNull); + return newArray; + } + } +} diff --git a/src/main/java/gregtech/api/util/extensions/Arrays.java b/src/main/java/gregtech/api/util/extensions/Arrays.java deleted file mode 100644 index 41efec5587..0000000000 --- a/src/main/java/gregtech/api/util/extensions/Arrays.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.api.util.extensions; - -public class Arrays { - public static int[] of(int... objects) { - return objects; - } - - public static float[] of(float... objects) { - return objects; - } - - public static double[] of(double... objects) { - return objects; - } - - public static char[] of(char... objects) { - return objects; - } - - public static byte[] of(byte... objects) { - return objects; - } - - public static long[] of(long... objects) { - return objects; - } - - @SafeVarargs - public static T[] of(T... objects) { - return objects; - } -} -- cgit From b9468785aa264ba0c1fcf295bb15260bb47c90c0 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 3 Aug 2021 22:34:50 +0300 Subject: GT_Recipe: speedup --- .../api/objects/iterators/ArrayIterator.java | 24 ++++++++++++++ .../api/objects/iterators/MergedIterator.java | 30 ++++++++++++++++++ .../api/objects/iterators/NonNullIterator.java | 36 +++++++++++++++++++++ src/main/java/gregtech/api/util/GT_Recipe.java | 37 +++++++++++----------- src/main/java/gregtech/api/util/GT_Utility.java | 8 +++++ .../gregtech/api/util/extensions/ArrayExt.java | 23 ++++++++++++++ .../gregtech/api/util/extensions/IteratorExt.java | 23 ++++++++++++++ .../basic/GT_MetaTileEntity_Disassembler.java | 11 ++----- 8 files changed, 166 insertions(+), 26 deletions(-) create mode 100644 src/main/java/gregtech/api/objects/iterators/ArrayIterator.java create mode 100644 src/main/java/gregtech/api/objects/iterators/MergedIterator.java create mode 100644 src/main/java/gregtech/api/objects/iterators/NonNullIterator.java create mode 100644 src/main/java/gregtech/api/util/extensions/IteratorExt.java (limited to 'src') diff --git a/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java b/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java new file mode 100644 index 0000000000..267a132ad5 --- /dev/null +++ b/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java @@ -0,0 +1,24 @@ +package gregtech.api.objects.iterators; + +import java.util.Iterator; + +public class ArrayIterator implements Iterator { + private final T[] arr; + private int offset; + + public ArrayIterator(T[] arr) { + this.arr = arr; + } + + @Override + public boolean hasNext() { + return offset != arr.length; + } + + @Override + public T next() { + T out = arr[offset]; + offset++; + return out; + } +} diff --git a/src/main/java/gregtech/api/objects/iterators/MergedIterator.java b/src/main/java/gregtech/api/objects/iterators/MergedIterator.java new file mode 100644 index 0000000000..77fac8d22f --- /dev/null +++ b/src/main/java/gregtech/api/objects/iterators/MergedIterator.java @@ -0,0 +1,30 @@ +package gregtech.api.objects.iterators; + +import java.util.Iterator; + +public class MergedIterator implements Iterator { + private final Iterator[] inners; + private int current; + + @SafeVarargs + public MergedIterator(Iterator... iterators) { + inners = iterators; + current = 0; + } + + public boolean hasNext() { + while (current < inners.length && !inners[current].hasNext()) { + current++; + } + + return current < inners.length; + } + + public T next() { + while (current < inners.length && !inners[current].hasNext()) { + current++; + } + + return inners[current].next(); + } +} diff --git a/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java b/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java new file mode 100644 index 0000000000..22dd33ba2b --- /dev/null +++ b/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java @@ -0,0 +1,36 @@ +package gregtech.api.objects.iterators; + +import java.util.Iterator; + +public class NonNullIterator implements Iterator { + private final Iterator internal; + private T last = null; + + public NonNullIterator(Iterator in) { + this.internal = in; + } + + @Override + public boolean hasNext() { + while (last == null) { + if (internal.hasNext()) { + last = internal.next(); + } else { + return false; + } + } + + return true; + } + + @Override + public T next() { + while (last == null) { + last = internal.next(); + } + + T temp = last; + last = null; + return temp; + } +} diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 19f46dfd15..98a2d9635d 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -9,6 +9,7 @@ import gregtech.api.objects.GT_FluidStack; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; +import gregtech.api.util.extensions.ArrayExt; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Replicator; import gregtech.nei.GT_NEI_DefaultHandler.FixedPositionedStack; import ic2.core.Ic2Items; @@ -23,7 +24,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static gregtech.api.enums.GT_Values.*; @@ -97,7 +97,8 @@ public class GT_Recipe implements Comparable { mEnabled = aRecipe.mEnabled; mHidden = aRecipe.mHidden; } - protected GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + + public GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { if (aInputs == null) aInputs = new ItemStack[0]; if (aOutputs == null) @@ -111,10 +112,10 @@ public class GT_Recipe implements Comparable { if (aChances.length < aOutputs.length) aChances = Arrays.copyOf(aChances, aOutputs.length); - aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]); - aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]); - aFluidInputs = GT_Utility.getArrayListWithoutNulls(aFluidInputs).toArray(new FluidStack[0]); - aFluidOutputs = GT_Utility.getArrayListWithoutNulls(aFluidOutputs).toArray(new FluidStack[0]); + aInputs = ArrayExt.withoutTrailingNulls(aInputs, ItemStack[]::new); + aOutputs = ArrayExt.withoutTrailingNulls(aOutputs, ItemStack[]::new); + aFluidInputs = ArrayExt.withoutNulls(aFluidInputs, FluidStack[]::new); + aFluidOutputs = ArrayExt.withoutNulls(aFluidOutputs, FluidStack[]::new); GT_OreDictUnificator.setStackArray(true, aInputs); GT_OreDictUnificator.setStackArray(true, aOutputs); @@ -1627,12 +1628,12 @@ public class GT_Recipe implements Comparable { } } - - public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map{ - private static int TOTAL_INPUT_COUNT = 6; - private static int OUTPUT_COUNT = 2; - private static int FLUID_OUTPUT_COUNT = 4; - + + public static class GT_Recipe_Map_LargeChemicalReactor extends GT_Recipe_Map { + private static final int TOTAL_INPUT_COUNT = 6; + private static final int OUTPUT_COUNT = 2; + private static final int FLUID_OUTPUT_COUNT = 4; + public GT_Recipe_Map_LargeChemicalReactor() { super(new HashSet<>(1000), "gt.recipe.largechemicalreactor", "Large Chemical Reactor", null, RES_PATH_GUI + "basicmachines/Default", 2, OUTPUT_COUNT, 0, 0, 1, E, 1, E, true, true); } @@ -1648,7 +1649,7 @@ public class GT_Recipe implements Comparable { if (aInputs == null) { aInputs = new ItemStack[0]; } else { - aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]); + aInputs = ArrayExt.withoutTrailingNulls(aInputs, ItemStack[]::new); } for (ItemStack input : aInputs) { @@ -1688,7 +1689,7 @@ public class GT_Recipe implements Comparable { if (aOutputs == null) { aOutputs = new ItemStack[0]; } else { - aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]); + aOutputs = ArrayExt.withoutTrailingNulls(aOutputs, ItemStack[]::new); } for (ItemStack output : aOutputs) { @@ -1734,9 +1735,9 @@ public class GT_Recipe implements Comparable { for (int i = 0; i < itemLimit; i++, j++) { if (this.mInputs == null || (this.mInputs[i] == null && (i == 0 && itemLimit == 1))) { if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null) - GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!"); + GT_Log.out.println("recipe " + this + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!"); else - GT_Log.out.println("recipe " + this.toString() + " has errored!"); + GT_Log.out.println("recipe " + this + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } @@ -1751,9 +1752,9 @@ public class GT_Recipe implements Comparable { for (int i = 0; i < fluidLimit; i++, j++) { if (this.mFluidInputs == null || this.mFluidInputs[i] == null) { if (this.mOutputs != null && this.mOutputs.length > 0 && this.mOutputs[0] != null) - GT_Log.out.println("recipe " + this.toString() + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!"); + GT_Log.out.println("recipe " + this + " Output 0:" + this.mOutputs[0].getDisplayName() + " has errored!"); else - GT_Log.out.println("recipe " + this.toString() + " has errored!"); + GT_Log.out.println("recipe " + this + " has errored!"); new Exception("Recipe Fixme").printStackTrace(GT_Log.out); } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 12ec2427ce..94195d76ce 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -24,6 +24,7 @@ import gregtech.api.net.GT_Packet_Sound; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; +import gregtech.api.util.extensions.ArrayExt; import gregtech.common.GT_Proxy; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; @@ -81,6 +82,7 @@ import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.*; import java.util.Map.Entry; +import java.util.function.IntFunction; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.*; @@ -1236,6 +1238,9 @@ public class GT_Utility { return false; } + /** + * Note: use {@link ArrayExt#withoutNulls(Object[], IntFunction)} if you want an array as a result. + */ public static ArrayList getArrayListWithoutNulls(T... aArray) { if (aArray == null) return new ArrayList<>(); ArrayList rList = new ArrayList<>(Arrays.asList(aArray)); @@ -1243,6 +1248,9 @@ public class GT_Utility { return rList; } + /** + * Note: use {@link ArrayExt#withoutTrailingNulls(Object[], IntFunction)} if you want an array as a result. + */ public static ArrayList getArrayListWithoutTrailingNulls(T... aArray) { if (aArray == null) return new ArrayList<>(); ArrayList rList = new ArrayList<>(Arrays.asList(aArray)); diff --git a/src/main/java/gregtech/api/util/extensions/ArrayExt.java b/src/main/java/gregtech/api/util/extensions/ArrayExt.java index faa01cb368..9b39f74518 100644 --- a/src/main/java/gregtech/api/util/extensions/ArrayExt.java +++ b/src/main/java/gregtech/api/util/extensions/ArrayExt.java @@ -32,6 +32,29 @@ public class ArrayExt { return objects; } + @SuppressWarnings("ForLoopReplaceableByForEach") + public static T[] withoutNulls(T[] array, IntFunction arrayFactory) { + int count = 0; + for (int i = 0; i < array.length; i++) { + if (array[i] != null) { + count++; + } + } + + T[] newArr = arrayFactory.apply(count); + if (count == 0) return newArr; + + int j = 0; + for (int i = 0; i < array.length; i++) { + if (array[i] != null) { + newArr[j] = array[i]; + j++; + } + } + + return newArr; + } + public static T[] withoutTrailingNulls(T[] array, IntFunction arrayFactory) { int firstNull = -1; for (int i = 0; i < array.length; i++) { diff --git a/src/main/java/gregtech/api/util/extensions/IteratorExt.java b/src/main/java/gregtech/api/util/extensions/IteratorExt.java new file mode 100644 index 0000000000..1a29a7b41a --- /dev/null +++ b/src/main/java/gregtech/api/util/extensions/IteratorExt.java @@ -0,0 +1,23 @@ +package gregtech.api.util.extensions; + +import gregtech.api.objects.iterators.ArrayIterator; +import gregtech.api.objects.iterators.MergedIterator; +import gregtech.api.objects.iterators.NonNullIterator; + +import java.util.Iterator; + +public class IteratorExt { + @SafeVarargs + public static Iterator merge(Iterator... iterators) { + return new MergedIterator<>(iterators); + } + + public static Iterator withoutNulls(Iterator iterator) { + return new NonNullIterator<>(iterator); + } + + @SafeVarargs + public static ArrayIterator ofArray(T... items) { + return new ArrayIterator<>(items); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index b820dd44fd..02eb893ba0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -19,18 +19,13 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.ArrayExt; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -234,7 +229,7 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi if (GT_Utility.isStackInvalid(recipe.inputs[i]) || recipe.inputs[i].stackSize < 1) recipe.inputs[i] = null; - recipe.inputs = GT_Utility.getArrayListWithoutNulls(recipe.inputs).toArray(new ItemStack[0]); + recipe.inputs = ArrayExt.withoutNulls(recipe.inputs, ItemStack[]::new); } private int checkRecipeMap() { -- cgit From fa39d5af8adaf20adeba17bbf951111938f8218f Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 3 Aug 2021 22:54:08 +0300 Subject: Sped up ArrayExt#withoutTrailingNulls by iterating from the last element --- src/main/java/gregtech/api/util/extensions/ArrayExt.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/extensions/ArrayExt.java b/src/main/java/gregtech/api/util/extensions/ArrayExt.java index 9b39f74518..51486bc036 100644 --- a/src/main/java/gregtech/api/util/extensions/ArrayExt.java +++ b/src/main/java/gregtech/api/util/extensions/ArrayExt.java @@ -57,13 +57,11 @@ public class ArrayExt { public static T[] withoutTrailingNulls(T[] array, IntFunction arrayFactory) { int firstNull = -1; - for (int i = 0; i < array.length; i++) { + for (int i = array.length - 1; i >= 0; i--) { if (array[i] == null) { - if (firstNull == -1) { - firstNull = i; - } + firstNull = i; } else { - firstNull = -1; + break; } } -- cgit From 35937ca89911c2b29f0a6027963c7439762045e7 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 3 Aug 2021 23:13:02 +0300 Subject: Removed ArrayIterator and NonNullIterator, because they're redundant --- .../api/objects/iterators/ArrayIterator.java | 24 --------------- .../api/objects/iterators/NonNullIterator.java | 36 ---------------------- .../gregtech/api/util/extensions/IteratorExt.java | 11 ------- 3 files changed, 71 deletions(-) delete mode 100644 src/main/java/gregtech/api/objects/iterators/ArrayIterator.java delete mode 100644 src/main/java/gregtech/api/objects/iterators/NonNullIterator.java (limited to 'src') diff --git a/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java b/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java deleted file mode 100644 index 267a132ad5..0000000000 --- a/src/main/java/gregtech/api/objects/iterators/ArrayIterator.java +++ /dev/null @@ -1,24 +0,0 @@ -package gregtech.api.objects.iterators; - -import java.util.Iterator; - -public class ArrayIterator implements Iterator { - private final T[] arr; - private int offset; - - public ArrayIterator(T[] arr) { - this.arr = arr; - } - - @Override - public boolean hasNext() { - return offset != arr.length; - } - - @Override - public T next() { - T out = arr[offset]; - offset++; - return out; - } -} diff --git a/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java b/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java deleted file mode 100644 index 22dd33ba2b..0000000000 --- a/src/main/java/gregtech/api/objects/iterators/NonNullIterator.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.api.objects.iterators; - -import java.util.Iterator; - -public class NonNullIterator implements Iterator { - private final Iterator internal; - private T last = null; - - public NonNullIterator(Iterator in) { - this.internal = in; - } - - @Override - public boolean hasNext() { - while (last == null) { - if (internal.hasNext()) { - last = internal.next(); - } else { - return false; - } - } - - return true; - } - - @Override - public T next() { - while (last == null) { - last = internal.next(); - } - - T temp = last; - last = null; - return temp; - } -} diff --git a/src/main/java/gregtech/api/util/extensions/IteratorExt.java b/src/main/java/gregtech/api/util/extensions/IteratorExt.java index 1a29a7b41a..d59bb298a4 100644 --- a/src/main/java/gregtech/api/util/extensions/IteratorExt.java +++ b/src/main/java/gregtech/api/util/extensions/IteratorExt.java @@ -1,8 +1,6 @@ package gregtech.api.util.extensions; -import gregtech.api.objects.iterators.ArrayIterator; import gregtech.api.objects.iterators.MergedIterator; -import gregtech.api.objects.iterators.NonNullIterator; import java.util.Iterator; @@ -11,13 +9,4 @@ public class IteratorExt { public static Iterator merge(Iterator... iterators) { return new MergedIterator<>(iterators); } - - public static Iterator withoutNulls(Iterator iterator) { - return new NonNullIterator<>(iterator); - } - - @SafeVarargs - public static ArrayIterator ofArray(T... items) { - return new ArrayIterator<>(items); - } } -- cgit From 7494ea5645fb76aec16f9852ebf3454f1fd197c4 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Tue, 3 Aug 2021 20:44:17 -0600 Subject: Add disassembler restrictions bypass --- src/main/java/gregtech/api/util/GT_Recipe.java | 2 ++ .../basic/GT_MetaTileEntity_Disassembler.java | 29 +++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 19f46dfd15..e10d58cd75 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -572,6 +572,8 @@ public class GT_Recipe implements Comparable { public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); + + /** Set {@code aSpecialValue = -100} to bypass the disassembler tier check and default recipe duration. */ public static final GT_Recipe_Map sDisassemblerRecipes = new GT_Recipe_Map(new HashSet<>(250), "gt.recipe.disassembler", "Disassembler", null, RES_PATH_GUI + "basicmachines/Disassembler", 1, 9, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<>(200), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index b820dd44fd..13eefcd7a6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -172,9 +172,6 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi ) return DID_NOT_FIND_RECIPE; - if (checkTier(is)) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - Integer handleHardOverride = handleHardOverride(is); if (handleHardOverride != null) return handleHardOverride; @@ -241,17 +238,31 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe(this.getBaseMetaTileEntity(), true, this.maxEUInput(), null, this.getAllInputs()); if (gt_recipe == null) return DID_NOT_FIND_RECIPE; - if (gt_recipe.isRecipeInputEqual(false, null, this.getAllInputs())) - return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize) - ? FOUND_AND_SUCCESSFULLY_USED_RECIPE - : FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (gt_recipe.isRecipeInputEqual(false, null, this.getAllInputs())) { + if (gt_recipe.mSpecialValue == -100) { + // Bypass standard disassembler restrictions. + this.getInputAt(0).stackSize -= gt_recipe.mInputs[0].stackSize; + System.arraycopy(gt_recipe.mOutputs, 0, this.mOutputItems, 0, gt_recipe.mOutputs.length); + + this.calculateOverclockedNess(gt_recipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } else { + return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize) + ? FOUND_AND_SUCCESSFULLY_USED_RECIPE + : FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + } return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize){ - if (this.getInputAt(0).stackSize >= stackSize) - this.getInputAt(0).stackSize -= stackSize; + ItemStack machineInput = this.getInputAt(0); + if (checkTier(machineInput)) + return false; + + if (machineInput.stackSize >= stackSize) + machineInput.stackSize -= stackSize; else return false; -- cgit From 2b698673853da3c2ef05954a884f08be3434315e Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:27:44 -0600 Subject: Use MetaGenerated_Item_99 --- src/main/java/gregtech/api/enums/OrePrefixes.java | 5 - .../common/items/GT_MetaGenerated_Item_04.java | 146 --------------- .../common/items/GT_MetaGenerated_Item_99.java | 200 ++++++++++++--------- .../preload/GT_Loader_Item_Block_And_Fluid.java | 1 - 4 files changed, 115 insertions(+), 237 deletions(-) delete mode 100644 src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java (limited to 'src') diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 77b6ee9426..cf8c776469 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -336,11 +336,6 @@ public enum OrePrefixes { cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); - public static final ImmutableList CRACKED_CELL_TYPES = - ImmutableList.of( - cellHydroCracked1, cellHydroCracked2, cellHydroCracked3, - cellSteamCracked1, cellSteamCracked2, cellSteamCracked3); - public static volatile int VERSION = 509; static { diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java deleted file mode 100644 index 728128ac39..0000000000 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_04.java +++ /dev/null @@ -1,146 +0,0 @@ -package gregtech.common.items; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.items.GT_MetaGenerated_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import java.util.BitSet; -import java.util.List; - -import static gregtech.api.enums.GT_Values.M; - -/** Generates cells for cracked fluids. */ -public class GT_MetaGenerated_Item_04 extends GT_MetaGenerated_Item { - public static GT_MetaGenerated_Item_04 INSTANCE; - - private static final int NUM_CRACKED_CELL_TYPES = OrePrefixes.CRACKED_CELL_TYPES.size(); - - private BitSet enabled = new BitSet(); - - public GT_MetaGenerated_Item_04() { - super("metaitem.04", (short) (NUM_CRACKED_CELL_TYPES * 1000), (short) 0); - INSTANCE = this; - - for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { - if (tMaterial == null || !tMaterial.canBeCracked() || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1000) { - continue; - } - register(tMaterial, tMaterial.mMetaItemSubID); - } - - // We're not going to use these BitSets, so clear them to save memory. - mEnabledItems.clear(); - mVisibleItems.clear(); - } - - private void register(Materials tMaterial, int i) { - int currIndex = NUM_CRACKED_CELL_TYPES * i; - for (OrePrefixes type : OrePrefixes.CRACKED_CELL_TYPES) { - ItemStack tStack = new ItemStack(this, 1, currIndex); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", type.getDefaultLocalNameFormatForItem(tMaterial)); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(type.mMaterialAmount / M)); - - if (type.mIsUnificatable) { - GT_OreDictUnificator.set(type, tMaterial, tStack); - } else { - GT_OreDictUnificator.registerOre(type.get(tMaterial), tStack); - } - - enabled.set(currIndex); - currIndex++; - } - } - - private int getMaterialIndex(int damage) { - return damage / NUM_CRACKED_CELL_TYPES; - } - - /** Returns null for item damage out of bounds. */ - private OrePrefixes getOrePrefix(int damage) { - if (damage < 0 || damage >= NUM_CRACKED_CELL_TYPES * 1000) { - return null; - } - return OrePrefixes.CRACKED_CELL_TYPES.get(damage % NUM_CRACKED_CELL_TYPES); - } - - @Override - public short[] getRGBa(ItemStack aStack) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[getMaterialIndex(aStack.getItemDamage())]; - return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - - int index = getMaterialIndex(aStack.getItemDamage()); - if (index >= 0 && index < 1000) { - return Materials.getLocalizedNameForItem(aName, index); - } - - return aName; - } - - @Override - public ItemStack getContainerItem(ItemStack aStack) { - OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); - if (prefix != null) { - return prefix.mContainerItem; - } - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - enabled.stream() - .mapToObj(i -> new ItemStack(this, 1, i)) - .forEach(aList::add); - } - - @Override - public final IIcon getIconFromDamage(int aMetaData) { - IIconContainer iconContainer = getIconContainer(aMetaData); - if (iconContainer != null) { - return iconContainer.getIcon(); - } - return null; - } - - @Override - public IIconContainer getIconContainer(int aMetaData) { - int index = getMaterialIndex(aMetaData); - if (index < 0 || index >= 1000) { - return null; - } - - Materials material = GregTech_API.sGeneratedMaterials[index]; - OrePrefixes prefix = getOrePrefix(aMetaData); - if (material != null && prefix != null) { - return material.mIconSet.mTextures[prefix.mTextureIndex]; - } - - return null; - } - - @Override - public int getItemStackLimit(ItemStack aStack) { - OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); - if (prefix != null) { - return prefix.mDefaultStackSize; - } else { - // If we're here, then something went wrong. Use cell.mDefaultStackSize as a fallback. - return OrePrefixes.cell.mDefaultStackSize; - } - } -} diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java index 2b94d96cb0..1c27310d99 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_99.java @@ -1,5 +1,6 @@ package gregtech.common.items; +import com.google.common.collect.ImmutableList; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -24,145 +25,174 @@ import static gregtech.api.enums.OrePrefixes.cellMolten; public class GT_MetaGenerated_Item_99 extends GT_MetaGenerated_Item { public static GT_MetaGenerated_Item_99 INSTANCE; - private BitSet enabled=new BitSet(); + /** + * Ore prefixes appear in this list in the order in which they will be assigned ID blocks. + * + *

In order to avoid breaking existing worlds, the entries in this list must not be re-ordered! The only safe + * modification that can be made to this list is adding new entries to the end. + */ + private static final ImmutableList CRACKED_CELL_TYPES = + ImmutableList.of( + OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3, + OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3); + private static final int NUM_CRACKED_CELL_TYPES = CRACKED_CELL_TYPES.size(); - private void register(Materials tMaterial,int i){ - ItemStack tStack = new ItemStack(this, 1, i); - enabled.set(i); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalizationFormat(cellMolten, tMaterial, i)); - GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(cellMolten.mMaterialAmount / M)); - if (cellMolten.mIsUnificatable) { - GT_OreDictUnificator.set(cellMolten, tMaterial, tStack); - } else { - GT_OreDictUnificator.registerOre(cellMolten.get(tMaterial), tStack); - } - } - //x32 + /** + * Assignment of metadata IDs: + * 0 - 999: Molten cells + * 10_000 - 15_999: Cracked fluid cells (# IDs used is NUM_CRACKED_CELL_TYPES * 1_000; update this if you add any) + */ + private BitSet enabled = new BitSet(); public GT_MetaGenerated_Item_99() { - super("metaitem.99", (short) 1000, (short) 0); + super("metaitem.99", (short) (10_000 + NUM_CRACKED_CELL_TYPES * 1_000), (short) 0); INSTANCE = this; - for (Materials tMaterial:GregTech_API.sGeneratedMaterials) { - if (tMaterial == null || tMaterial.mMetaItemSubID<0 || tMaterial.mMetaItemSubID>=1000) continue; - //if (tMaterial.getcells(1)==null) { + for (Materials tMaterial : GregTech_API.sGeneratedMaterials) { + if (tMaterial == null || tMaterial.mMetaItemSubID < 0 || tMaterial.mMetaItemSubID >= 1_000) { + continue; + } + if ((tMaterial.contains(SubTag.SMELTING_TO_FLUID)) && (!tMaterial.contains(SubTag.NO_SMELTING)) && !tMaterial.contains(SubTag.SMELTING_TO_GEM)) { - register(tMaterial,tMaterial.mMetaItemSubID); - if (tMaterial.mSmeltInto != tMaterial) { - register(tMaterial.mSmeltInto,tMaterial.mSmeltInto.mMetaItemSubID); + registerMolten(tMaterial, tMaterial.mMetaItemSubID); + if (tMaterial.mSmeltInto != tMaterial + && tMaterial.mSmeltInto.mMetaItemSubID >= 0 && tMaterial.mSmeltInto.mMetaItemSubID < 1_000) { + registerMolten(tMaterial.mSmeltInto, tMaterial.mSmeltInto.mMetaItemSubID); } } - //} + + if (tMaterial.canBeCracked()) { + registerCracked(tMaterial, tMaterial.mMetaItemSubID); + } } + + // We're not going to use these BitSets, so clear them to save memory. mEnabledItems.clear(); mVisibleItems.clear(); } - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + private void registerMolten(Materials tMaterial,int i){ + ItemStack tStack = new ItemStack(this, 1, i); + enabled.set(i); - /** - * @return the Color Modulation the Material is going to be rendered with. - */ - @Override - public short[] getRGBa(ItemStack aStack) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[getDamage(aStack)]; - return tMaterial == null ? Materials._NULL.mMoltenRGBa : tMaterial.mMoltenRGBa; + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", cellMolten.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(cellMolten.mMaterialAmount / M)); + + if (cellMolten.mIsUnificatable) { + GT_OreDictUnificator.set(cellMolten, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(cellMolten.get(tMaterial), tStack); + } } - /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + private void registerCracked(Materials tMaterial, int i) { + int offset = 10_000; + for (OrePrefixes prefix : CRACKED_CELL_TYPES) { + ItemStack tStack = new ItemStack(this, 1, offset + i); + enabled.set(offset + i); - /** - * @param aPrefix the OreDict Prefix - * @param aMaterial the Material - * @param aMetaData a Index from [0 - 31999] - * @return the Localized Name when default LangFiles are used. - */ - @Deprecated - public String getDefaultLocalization(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { - return aPrefix.getDefaultLocalNameForItem(aMaterial); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", prefix.getDefaultLocalNameFormatForItem(tMaterial)); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(prefix.mMaterialAmount / M)); + + if (prefix.mIsUnificatable) { + GT_OreDictUnificator.set(prefix, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(prefix.get(tMaterial), tStack); + } + + offset += 1_000; + } } - /** - * @param aPrefix the OreDict Prefix - * @param aMaterial the Material - * @param aMetaData a Index from [0 - 31999] - * @return the Localized Name Format when default LangFiles are used. - */ - public String getDefaultLocalizationFormat(OrePrefixes aPrefix, Materials aMaterial, int aMetaData) { - return aPrefix.getDefaultLocalNameFormatForItem(aMaterial); + /** Returns null for item damage out of bounds. */ + private Materials getMaterial(int damage) { + if (damage < 0) { + return null; + } + return GregTech_API.sGeneratedMaterials[damage % 1_000]; } - /** - * @param aPrefix always != null - * @param aMaterial always != null - * @param aDoShowAllItems this is the Configuration Setting of the User, if he wants to see all the Stuff like Tiny Dusts or Crushed Ores as well. - * @return if this Item should be visible in NEI or Creative - */ - public boolean doesShowInCreative(OrePrefixes aPrefix, Materials aMaterial, boolean aDoShowAllItems) { - return true; + /** Returns null for item damage out of bounds. */ + private OrePrefixes getOrePrefix(int damage) { + if (damage < 0) { + return null; + } else if (damage < 1_000) { + return cellMolten; + } else if (damage >= 10_000 && damage < 10_000 + (NUM_CRACKED_CELL_TYPES * 1_000)) { + return CRACKED_CELL_TYPES.get((damage / 1_000) - 10); + } + return null; } - /* ---------- INTERNAL OVERRIDES ---------- */ + @Override + public short[] getRGBa(ItemStack aStack) { + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + Materials material = getMaterial(aStack.getItemDamage()); + if (material == null) { + material = Materials._NULL; + } + + if (prefix == cellMolten) { + return material.mMoltenRGBa; + } else { + return material.mRGBa; + } + } @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); - int aDamage = aStack.getItemDamage(); - if (aDamage < 1000 && aDamage >= 0) - return Materials.getLocalizedNameForItem(aName, aDamage); + Materials material = getMaterial(aStack.getItemDamage()); + if (material != null) { + return material.getLocalizedNameForItem(aName); + } return aName; } @Override public ItemStack getContainerItem(ItemStack aStack) { - int aDamage = aStack.getItemDamage(); - if (aDamage < 1000 && aDamage >= 0) { - return cellMolten.mContainerItem; + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mContainerItem; } return null; } @Override @SideOnly(Side.CLIENT) - public final void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 1000; i++) { - Materials aMaterial = GregTech_API.sGeneratedMaterials[i]; - if (aMaterial != null && enabled.get(i)) { - ItemStack tStack = new ItemStack(this, 1, i); - isItemStackUsable(tStack); - aList.add(tStack); - } - } - super.getSubItems(var1, aCreativeTab, aList); + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + enabled.stream() + .mapToObj(i -> new ItemStack(this, 1, i)) + .forEach(aList::add); } @Override public final IIcon getIconFromDamage(int aMetaData) { - if (aMetaData < 0) return null; - if (aMetaData < 1000) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData]; - if (tMaterial == null) return null; - IIconContainer tIcon = getIconContainer(aMetaData); - if (tIcon != null) return tIcon.getIcon(); - return null; + IIconContainer iconContainer = getIconContainer(aMetaData); + if (iconContainer != null) { + return iconContainer.getIcon(); } return null; } @Override public IIconContainer getIconContainer(int aMetaData) { - if (aMetaData < 0) return null; - if (aMetaData < 1000) { - Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData]; - if (tMaterial == null) return null; - return tMaterial.mIconSet.mTextures[cellMolten.mTextureIndex]; + Materials material = getMaterial(aMetaData); + OrePrefixes prefix = getOrePrefix(aMetaData); + if (material != null && prefix != null) { + return material.mIconSet.mTextures[prefix.mTextureIndex]; } return null; } @Override public int getItemStackLimit(ItemStack aStack) { - return cellMolten.mDefaultStackSize; + OrePrefixes prefix = getOrePrefix(aStack.getItemDamage()); + if (prefix != null) { + return prefix.mDefaultStackSize; + } else { + return 64; + } } } diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index 77b65e5b18..4fbc25f226 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -71,7 +71,6 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { new GT_MetaGenerated_Item_01(); new GT_MetaGenerated_Item_02(); new GT_MetaGenerated_Item_03(); - new GT_MetaGenerated_Item_04(); new GT_MetaGenerated_Item_99(); new GT_MetaGenerated_Tool_01(); new GT_FluidDisplayItem(); -- cgit From a54f4e65bafc16af5227d2e48ff7a59c6552e031 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:44:43 -0600 Subject: Code cleanup --- src/main/java/gregtech/api/enums/OrePrefixes.java | 11 +--- src/main/java/gregtech/common/GT_Proxy.java | 72 +++++++++++------------ 2 files changed, 37 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index cf8c776469..606d12c832 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -543,15 +543,7 @@ public enum OrePrefixes { cableGt01.mSecondaryMaterial = new MaterialStack(Materials.Rubber, plate.mMaterialAmount); bucket.mSecondaryMaterial = new MaterialStack(Materials.Iron, ingot.mMaterialAmount * 3); bucketClay.mSecondaryMaterial = new MaterialStack(Materials.Clay, dust.mMaterialAmount * 5); - cell.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellPlasma.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellMolten.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellHydroCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellHydroCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellHydroCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellSteamCracked1.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellSteamCracked2.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); - cellSteamCracked3.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2); + CELL_TYPES.forEach(prefix -> prefix.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2)); oreRedgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteRed, dust.mMaterialAmount); oreBlackgranite.mSecondaryMaterial = new MaterialStack(Materials.GraniteBlack, dust.mMaterialAmount); oreNetherrack.mSecondaryMaterial = new MaterialStack(Materials.Netherrack, dust.mMaterialAmount); @@ -1004,7 +996,6 @@ public enum OrePrefixes { return mLocalizedMaterialPre + OrePrefixes.gem.getDefaultLocalNameFormatForItem(aMaterial); case crateGtPlate: return mLocalizedMaterialPre + OrePrefixes.plate.getDefaultLocalNameFormatForItem(aMaterial); - case cellMolten: } switch (aMaterial.mName) { case "Glass": diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 3e76335410..bff044b4c3 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1780,45 +1780,45 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { } public void addAutoGeneratedHydroCrackedFluids(Materials aMaterial){ - Fluid[] crackedFluids = new Fluid[3]; - String[] namePrefixes = { "lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked." }; - OrePrefixes[] orePrefixes = { OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3 }; - GT_Fluid uncrackedFluid = null; - if (aMaterial.mFluid != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mFluid; - } else if (aMaterial.mGas != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mGas; - } - for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid( + Fluid[] crackedFluids = new Fluid[3]; + String[] namePrefixes = { "lightlyhydrocracked.", "moderatelyhydrocracked.", "severelyhydrocracked." }; + OrePrefixes[] orePrefixes = { OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3 }; + GT_Fluid uncrackedFluid = null; + if (aMaterial.mFluid != null) { + uncrackedFluid = (GT_Fluid) aMaterial.mFluid; + } else if (aMaterial.mGas != null) { + uncrackedFluid = (GT_Fluid) aMaterial.mGas; + } + for (int i = 0; i < 3; i++) { + crackedFluids[i] = addFluid( namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), ItemList.Cell_Empty.get(1L, new Object[0]), 1000); - int hydrogenAmount = 2 * i + 2; - GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), Materials.Hydrogen.getGas(hydrogenAmount * 1000), - new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 120 + 60 * i); - GT_Values.RA.addChemicalRecipe(Materials.Hydrogen.getCells(hydrogenAmount), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), - new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(hydrogenAmount), 160 + 80 * i, 30); - GT_Values.RA.addChemicalRecipe(aMaterial.getCells(1), GT_Utility.getIntegratedCircuit(i + 1), Materials.Hydrogen.getGas(hydrogenAmount * 1000), - new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); - } - aMaterial.setHydroCrackedFluids(crackedFluids); + int hydrogenAmount = 2 * i + 2; + GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), Materials.Hydrogen.getGas(hydrogenAmount * 1000), + new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 120 + 60 * i); + GT_Values.RA.addChemicalRecipe(Materials.Hydrogen.getCells(hydrogenAmount), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), + new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(hydrogenAmount), 160 + 80 * i, 30); + GT_Values.RA.addChemicalRecipe(aMaterial.getCells(1), GT_Utility.getIntegratedCircuit(i + 1), Materials.Hydrogen.getGas(hydrogenAmount * 1000), + new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); + } + aMaterial.setHydroCrackedFluids(crackedFluids); } public void addAutoGeneratedSteamCrackedFluids(Materials aMaterial){ - Fluid[] crackedFluids = new Fluid[3]; - String[] namePrefixes = { "lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked." }; + Fluid[] crackedFluids = new Fluid[3]; + String[] namePrefixes = { "lightlysteamcracked.", "moderatelysteamcracked.", "severelysteamcracked." }; OrePrefixes[] orePrefixes = { OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3 }; - GT_Fluid uncrackedFluid = null; - if (aMaterial.mFluid != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mFluid; - } else if (aMaterial.mGas != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mGas; - } - for (int i = 0; i < 3; i++) { + GT_Fluid uncrackedFluid = null; + if (aMaterial.mFluid != null) { + uncrackedFluid = (GT_Fluid) aMaterial.mFluid; + } else if (aMaterial.mGas != null) { + uncrackedFluid = (GT_Fluid) aMaterial.mGas; + } + for (int i = 0; i < 3; i++) { crackedFluids[i] = addFluid( namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), uncrackedFluid.mTextureName, orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, @@ -1827,13 +1827,13 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { ItemList.Cell_Empty.get(1L, new Object[0]), 1000); GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), - new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); - GT_Values.RA.addChemicalRecipe(GT_ModHandler.getIC2Item("steamCell", 1L), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), - new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); - GT_Values.RA.addChemicalRecipe(aMaterial.getCells(1), GT_Utility.getIntegratedCircuit(i + 1), GT_ModHandler.getSteam(1000), - new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); - } - aMaterial.setSteamCrackedFluids(crackedFluids); + new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); + GT_Values.RA.addChemicalRecipe(GT_ModHandler.getIC2Item("steamCell", 1L), GT_Utility.getIntegratedCircuit(i + 1), new FluidStack(uncrackedFluid, 1000), + new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); + GT_Values.RA.addChemicalRecipe(aMaterial.getCells(1), GT_Utility.getIntegratedCircuit(i + 1), GT_ModHandler.getSteam(1000), + new FluidStack(crackedFluids[i], 800), Materials.Empty.getCells(1), 160 + 80 * i, 30); + } + aMaterial.setSteamCrackedFluids(crackedFluids); } public Fluid addFluid(String aName, String aLocalized, Materials aMaterial, int aState, int aTemperatureK) { -- cgit From 182f596207ea875fdf2b4e640a342308a1bdb7f2 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 5 Aug 2021 02:51:03 +0800 Subject: Fix oversight in oil cracker structure code Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index c8dbe2321a..a90e1948d0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -49,10 +49,14 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addElement('c', ofCoil(GT_MetaTileEntity_OilCracker::setCoilLevel, GT_MetaTileEntity_OilCracker::getCoilLevel)) .addElement('l', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addLeftHatchToMachineList, CASING_INDEX, 2), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMaintenanceToMachineList, CASING_INDEX, 1), onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('r', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 3), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMaintenanceToMachineList, CASING_INDEX, 1), onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('m', ofChain( -- cgit From a3a540cc6e37ec9a8169146552caae037d70b37e Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 5 Aug 2021 20:57:30 -0600 Subject: Update GT_MetaTileEntity_ChestBuffer.java --- .../automation/GT_MetaTileEntity_ChestBuffer.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index 9da0eace39..774639401a 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -124,22 +124,7 @@ public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { @Override protected void fillStacksIntoFirstSlots() { sortStacks(); - // Merge small stacks together - // The last slot of mInventory is invalid, so we need to avoid iterating over it. - // Thus all max indices are reduced by 1 here. - for (int i = 0; i < this.mInventory.length - 2;) { - //GT_FML_LOGGER.info( (this.mInventory[i] == null) ? "Slot empty " + i : "Slot " + i + " holds " + this.mInventory[i].getDisplayName()); - for (int j = i + 1; j < this.mInventory.length - 1; j++) { - if ((this.mInventory[j] != null) && ((GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - //GT_FML_LOGGER.info( "Moving slot " + j + " into slot " + i ); - } - else { - i=j; - break; // No more matching items for this i, do next i - } - } - } + super.fillStacksIntoFirstSlots(); } @Override -- cgit From 0c5284cdff6a2bc8e9e409e61d0a290b1ea3b9d0 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 5 Aug 2021 21:53:49 -0600 Subject: Remove bSortStacks check --- .../implementations/GT_MetaTileEntity_Buffer.java | 20 +++++++++----------- .../GT_MetaTileEntity_ItemDistributor.java | 15 --------------- 2 files changed, 9 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index faea347c67..21cf0d73f1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -329,20 +329,18 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void fillStacksIntoFirstSlots() { - if (bSortStacks) { - for (int i = 0; i < mInventory.length - 1; i++) { - if (!isValidSlot(i)) { + for (int i = 0; i < mInventory.length - 1; i++) { + if (!isValidSlot(i)) { + continue; + } + + for (int j = i + 1; j < mInventory.length; j++) { + if (!isValidSlot(j)) { continue; } - for (int j = i + 1; j < mInventory.length; j++) { - if (!isValidSlot(j)) { - continue; - } - - if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); } } } diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index 3cf5adff99..a796ce9661 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -49,21 +49,6 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer this.mTextures); } - @Override - protected void fillStacksIntoFirstSlots() { - // The last slot of mInventory is invalid, so we need to avoid iterating over it. - // Thus all max indices are reduced by 1 here. - for (int i = 0; i < this.mInventory.length - 2; i++) { - for (int j = i + 1; j < this.mInventory.length - 1; j++) { - if ((this.mInventory[j] != null) - && ((this.mInventory[i] == null) || (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, - (byte) 64, (byte) 1); - } - } - } - } - @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_ItemDistributor(aPlayerInventory, aBaseMetaTileEntity); -- cgit From 05505604c98a63b66171ea8a0ed9a2cdce407d37 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 02:06:44 -0600 Subject: Add number formatting for tooltips & recipes --- build.properties | 2 +- .../GT_MetaTileEntity_Hatch_Input.java | 4 +++- .../GT_MetaTileEntity_Hatch_Output.java | 2 +- src/main/java/gregtech/api/util/GT_Utility.java | 27 ++++++++++++++++++++++ .../gregtech/common/blocks/GT_Item_Machines.java | 8 +++---- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 8 +++---- .../java/gregtech/nei/GT_NEI_DefaultHandler.java | 10 ++++---- 7 files changed, 45 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 9c6f282480..407cf4ff61 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.06 +gt.version=5.09.37.07 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 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 e37d2160a2..fd7eb0fc94 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 @@ -16,7 +16,9 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, new String[]{"Fluid Input for Multiblocks", "Capacity: " + (8000+8000*(aTier*(aTier+1)>>1)) + "L"}); + super(aID, aName, aNameRegional, aTier, 3, new String[]{ + "Fluid Input for Multiblocks", + "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L"}); } public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { 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 9965b88a17..db80c4685b 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 @@ -27,7 +27,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { 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: " + (8000+8000*(aTier*(aTier+1)>>1)) + "L", + "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"}); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 94195d76ce..29aa1a561a 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2224,9 +2224,36 @@ public class GT_Utility { DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); + formatter.setDecimalFormatSymbols(symbols); return formatter.format(aNumber); } + /** + * Formats a positive integer with grouping separators, and also attempts to display it as a (small multiple of a) + * power of 2. + */ + public static String formatPow2(long number) { + String formatted = formatNumbers(number); + if (number == V[V.length - 1]) { + formatted += " (MAX)"; + } else if (number >= 256) { + // Try to figure out if number is a (small multiple of a) power of 2. + long curr = number; + int pow = 0; + while ((curr & 1) == 0) { + curr = curr >>> 1; + pow++; + } + + if (curr == 1) { + formatted += String.format(" (2^%d)", pow); + } else if (curr <= 7) { + formatted += String.format(" (%d*2^%d)", curr, pow); + } + } + return formatted; + } + /* * Check if stack has enough items of given type and subtract from stack, if there's no creative or 111 stack. */ diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index c8e77f9b0a..ee99c8a053 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -70,16 +70,16 @@ public class GT_Item_Machines extends ItemBlock { if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); } - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatPow2(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); } } NBTTagCompound aNBT = aStack.getTagCompound(); diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index c692a2dce1..b9cd8ef687 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -235,11 +235,11 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + drawText(10, 73, trans("152","Total: ") + GT_Utility.formatNumbers((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers(tEUt) + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); - drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(this.mRecipeMap.mAmperage), -16777216); } else { drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index a4fc75a24e..2e9a265ff9 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -217,16 +217,16 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + drawText(10, 73, trans("152","Total: ") + GT_Utility.formatNumbers((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers(tEUt) + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { byte tier=GT_Utility.getTier(tEUt / this.mRecipeMap.mAmperage); if(tier<0||tier>=16){ - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", 0xffFF0000); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU", 0xffFF0000); //add here gt logger }else{ - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU ("+GT_Values.VN[tier]+")", -16777216); - }drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU ("+GT_Values.VN[tier]+")", -16777216); + }drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(this.mRecipeMap.mAmperage), -16777216); } else { drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); -- cgit From 3408222951008c37ad81fbab1aa455501e68026b Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 02:29:58 -0600 Subject: Also format recipe time --- src/main/java/gregtech/api/util/GT_Utility.java | 9 +++++++++ src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java | 2 +- src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 29aa1a561a..4ae785c50f 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2228,6 +2228,15 @@ public class GT_Utility { return formatter.format(aNumber); } + public static String formatNumbers(double aNumber) { + DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); + DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); + symbols.setGroupingSeparator(' '); + formatter.setDecimalFormatSymbols(symbols); + formatter.setMaximumFractionDigits(2); + return formatter.format(aNumber); + } + /** * Formats a positive integer with grouping separators, and also attempts to display it as a (small multiple of a) * power of 2. diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index b9cd8ef687..513b0b7552 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -246,7 +246,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { } } if (tDuration > 0) { - drawText(10, 113, trans("158","Time: ")+String.format("%.2f " + trans("161"," secs"), 0.05F * tDuration), -16777216); + drawText(10, 113, trans("158","Time: ") + GT_Utility.formatNumbers(0.05d * tDuration) + trans("161"," secs"), -16777216); } int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index 2e9a265ff9..f8aa9a015e 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -233,7 +233,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { } } if (tDuration > 0) { - drawText(10, 113, trans("158","Time: ")+String.format("%.2f " + trans("161"," secs"), 0.05F * tDuration), -16777216); + drawText(10, 113, trans("158","Time: ") + GT_Utility.formatNumbers(0.05d * tDuration) + trans("161"," secs"), -16777216); } int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { -- cgit From bbabaa92f82c14f49fbd968f1a14dfdb5c7aeeaa Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 02:55:54 -0600 Subject: Add warning comment just in case --- src/main/java/gregtech/api/util/GT_Utility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 4ae785c50f..e57014239c 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2249,7 +2249,7 @@ public class GT_Utility { // Try to figure out if number is a (small multiple of a) power of 2. long curr = number; int pow = 0; - while ((curr & 1) == 0) { + while ((curr & 1) == 0) { // N.B. this won't terminate if curr == 0 curr = curr >>> 1; pow++; } -- cgit From b470fee172543879f24fd9f43395686db808d045 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:32:43 -0600 Subject: Make DecimalFormat static --- src/main/java/gregtech/api/util/GT_Utility.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 4ae785c50f..d55dbd7d06 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -79,7 +79,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; import java.util.*; import java.util.Map.Entry; import java.util.function.IntFunction; @@ -95,6 +94,7 @@ import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; * Just a few Utility Functions I use. */ public class GT_Utility { + private static final DecimalFormat decimalFormat = new DecimalFormat(); /** * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. */ @@ -108,6 +108,11 @@ public class GT_Utility { public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); static { + DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); + symbols.setGroupingSeparator(' '); + decimalFormat.setDecimalFormatSymbols(symbols); + decimalFormat.setMaximumFractionDigits(2); + GregTech_API.sItemStackMappings.add(sFilledContainerToData); GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData); } @@ -2221,20 +2226,11 @@ public class GT_Utility { } public static String formatNumbers(long aNumber) { - DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); - DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); - symbols.setGroupingSeparator(' '); - formatter.setDecimalFormatSymbols(symbols); - return formatter.format(aNumber); + return decimalFormat.format(aNumber); } public static String formatNumbers(double aNumber) { - DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); - DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); - symbols.setGroupingSeparator(' '); - formatter.setDecimalFormatSymbols(symbols); - formatter.setMaximumFractionDigits(2); - return formatter.format(aNumber); + return decimalFormat.format(aNumber); } /** -- cgit From 531dd5e644ec39b7c10ad944d07331930bcb99a3 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:33:17 -0600 Subject: Add formatting to pipes, wires, super chests, super tanks --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java | 6 +++--- .../api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 4 ++-- .../api/metatileentity/implementations/GT_MetaPipeEntity_Item.java | 6 +++--- .../tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java | 2 +- .../common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java | 4 +++- .../common/tileentities/storage/GT_MetaTileEntity_SuperTank.java | 4 +++- 6 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index de008abcab..c5a33f7ae0 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -329,9 +329,9 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getDescription() { return new String[]{ - "Max Voltage: %%%" + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: %%%" + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + "%%% EU-Volt" + "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatPow2(mVoltage) + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(mAmperage) + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatPow2(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" }; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 59c1e91543..2e7fc8e8d9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -642,12 +642,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public String[] getDescription() { if (mPipeAmount == 1) { return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY }; } else { return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY, EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY }; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index e24aebc064..a4cc0e407e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -345,11 +345,11 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public String[] getDescription() { if (mTickTime == 20) - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/sec", "Routing Value: %%%" + mStepSize}; + return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/sec", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; else if (mTickTime % 20 == 0) - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + (mTickTime / 20) + "%%% sec", "Routing Value: %%%" + mStepSize}; + return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + (mTickTime / 20) + "%%% sec", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; else - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + mTickTime + "%%% ticks", "Routing Value: %%%" + mStepSize}; + return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + mTickTime + "%%% ticks", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; } private boolean isInventoryEmpty() { diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 9c8c5faaf9..6e01e456cf 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -31,7 +31,7 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti public GT_MetaTileEntity_DigitalChestBase(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 3, new String[]{ - "This Chest stores " + commonSizeCompute(aTier) + " Blocks", + "This Chest stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + " Blocks", "Use a screwdriver to enable", "voiding items on overflow" }); diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java index 396b6d6464..dc9682336b 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java @@ -5,6 +5,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; @@ -15,7 +16,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + commonSizeCompute(aTier) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, + "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid"); } private static int commonSizeCompute(int tier) { diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java index 41171720f5..c5b92d0863 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java @@ -5,6 +5,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; @@ -15,7 +16,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { public GT_MetaTileEntity_SuperTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + commonSizeCompute(aTier) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, + "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid"); } private static int commonSizeCompute(int tier) { -- cgit From f9afedeb5cebbfc7f7dc228fdbdbd2675859064a Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:33:27 -0600 Subject: Fix compiler warning --- src/main/java/gregtech/common/blocks/GT_Item_Machines.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index ee99c8a053..4be48b902d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -60,7 +60,7 @@ public class GT_Item_Machines extends ItemBlock { for (int j = 0; j < tString.length; j++) if (j % 2 == 0) tBuffer.append(tString[j]); else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} - aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), tRep)); + aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), (Object[]) tRep)); } }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); aList.add(tTranslated.equals("") ? tDescription : tTranslated);} -- cgit From 1302af9a3eb8431f23ff579a82129108905f6d3c Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Sun, 8 Aug 2021 02:06:15 +0800 Subject: coolant recipe conflict --- src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 5695180528..4a264c5ff5 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -145,8 +145,8 @@ public class GT_MachineRecipeLoader implements Runnable { GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.LightFuel, 5L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(5), Materials.HeavyFuel.getFluid(1000L), Materials.Fuel.getFluid(6000L), Materials.Empty.getCells(5), 16, 120); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.HeavyFuel, 1L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(6), Materials.LightFuel.getFluid(5000L), Materials.Fuel.getFluid(6000L), Materials.Empty.getCells(1), 16, 120); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Water, 5L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L), GT_Values.NI, GT_Values.NI, Materials.Lubricant.getFluid(20), new FluidStack(ItemList.sDrillingFluid, 5000), Materials.Empty.getCells(5), 64, 16); - GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(1), GT_Values.NI, GT_Values.NI, Materials.Water.getFluid(125), FluidRegistry.getFluidStack("ic2coolant", 125), GT_Values.NI, 256, 48); - GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(1), GT_Values.NI, GT_Values.NI, GT_ModHandler.getDistilledWater(1000), FluidRegistry.getFluidStack("ic2coolant", 1000), GT_Values.NI, 256, 48); + GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(2), GT_Values.NI, GT_Values.NI, Materials.Water.getFluid(125), FluidRegistry.getFluidStack("ic2coolant", 125), GT_Values.NI, 256, 48); + GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lapis, 1L), GT_Utility.getIntegratedCircuit(2), GT_Values.NI, GT_Values.NI, GT_ModHandler.getDistilledWater(1000), FluidRegistry.getFluidStack("ic2coolant", 1000), GT_Values.NI, 256, 48); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 4L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(1), Materials.Creosote.getFluid(1000), null, ItemList.SFMixture.get(8), 1600, 16); GT_Values.RA.addMixerRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sulfur, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wood, 4L), GT_Values.NI, GT_Values.NI, GT_Utility.getIntegratedCircuit(1), Materials.Creosote.getFluid(1000), null, ItemList.SFMixture.get(8), 1600, 16); -- cgit From 567e3e166d2bc92e2445207a606c1353b1a1b845 Mon Sep 17 00:00:00 2001 From: GlodBlock <60341015+GlodBlock@users.noreply.github.com> Date: Sun, 8 Aug 2021 03:17:24 +0800 Subject: add integrated circuit for dye recipe --- src/main/java/gregtech/loaders/oreprocessing/ProcessingDye.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDye.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDye.java index abfa47e570..4714f68be3 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDye.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDye.java @@ -26,8 +26,8 @@ public class ProcessingDye implements IOreRecipeRegistrator { (GT_Utility.getContainerItem(aStack, true) == null)) { GT_ModHandler.addAlloySmelterRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glass, 8L), GT_Utility.copyAmount(1L, aStack), new ItemStack(Blocks.stained_glass, 8, 15 - aDye.mIndex), 200, 8, false); GT_ModHandler.addAlloySmelterRecipe(new ItemStack(Blocks.glass, 8, 32767), GT_Utility.copyAmount(1L, aStack), new ItemStack(Blocks.stained_glass, 8, 15 - aDye.mIndex), 200, 8, false); - GT_Values.RA.addMixerRecipe(GT_Utility.copyAmount(1L, aStack), null, null, null, Materials.Water.getFluid(216L), FluidRegistry.getFluidStack("dye.watermixed." + aDye.name().toLowerCase(Locale.ENGLISH), 192), null, 16, 4); - GT_Values.RA.addMixerRecipe(GT_Utility.copyAmount(1L, aStack), null, null, null, GT_ModHandler.getDistilledWater(288L), FluidRegistry.getFluidStack("dye.watermixed." + aDye.name().toLowerCase(Locale.ENGLISH), 216), null, 16, 4); + GT_Values.RA.addMixerRecipe(GT_Utility.copyAmount(1L, aStack), GT_Utility.getIntegratedCircuit(1), null, null, Materials.Water.getFluid(216L), FluidRegistry.getFluidStack("dye.watermixed." + aDye.name().toLowerCase(Locale.ENGLISH), 192), null, 16, 4); + GT_Values.RA.addMixerRecipe(GT_Utility.copyAmount(1L, aStack), GT_Utility.getIntegratedCircuit(1), null, null, GT_ModHandler.getDistilledWater(288L), FluidRegistry.getFluidStack("dye.watermixed." + aDye.name().toLowerCase(Locale.ENGLISH), 216), null, 16, 4); GT_Values.RA.addChemicalRecipe(GT_Utility.copyAmount(1L, aStack), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Salt, 2), Materials.SulfuricAcid.getFluid(432), FluidRegistry.getFluidStack("dye.chemical." + aDye.name().toLowerCase(Locale.ENGLISH), 288), GT_Values.NI, 600, 48); } } -- cgit From 72c54aa140492f25d3ce4a03d61abb7de9642f87 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:50:43 -0600 Subject: Print powers of 10 instead, for large numbers only --- .../implementations/GT_MetaPipeEntity_Cable.java | 6 +-- src/main/java/gregtech/api/util/GT_Utility.java | 46 ++++++++-------------- .../gregtech/common/blocks/GT_Item_Machines.java | 8 ++-- 3 files changed, 23 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index c5a33f7ae0..b4396aec3e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -329,9 +329,9 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getDescription() { return new String[]{ - "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatPow2(mVoltage) + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(mAmperage) + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatPow2(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" + "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mVoltage) + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatNumbers(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" }; } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index da5c902c0e..f1f83c3c14 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -94,7 +94,11 @@ import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; * Just a few Utility Functions I use. */ public class GT_Utility { - private static final DecimalFormat decimalFormat = new DecimalFormat(); + /** Formats a number with group separator and at most 2 fraction digits. */ + private static final DecimalFormat basicFormatter = new DecimalFormat(); + /** Formats a number into scientific notation with at most 2 fraction digits. Meant for large numbers. */ + private static final DecimalFormat scientificNotationFormatter = new DecimalFormat("0.##E0"); + /** * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. */ @@ -108,10 +112,10 @@ public class GT_Utility { public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); static { - DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); + DecimalFormatSymbols symbols = basicFormatter.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); - decimalFormat.setDecimalFormatSymbols(symbols); - decimalFormat.setMaximumFractionDigits(2); + basicFormatter.setDecimalFormatSymbols(symbols); + basicFormatter.setMaximumFractionDigits(2); GregTech_API.sItemStackMappings.add(sFilledContainerToData); GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData); @@ -2226,35 +2230,17 @@ public class GT_Utility { } public static String formatNumbers(long aNumber) { - return decimalFormat.format(aNumber); + String formatted = basicFormatter.format(aNumber); + if (aNumber >= 1_000_000_000L) { + formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; + } + return formatted; } public static String formatNumbers(double aNumber) { - return decimalFormat.format(aNumber); - } - - /** - * Formats a positive integer with grouping separators, and also attempts to display it as a (small multiple of a) - * power of 2. - */ - public static String formatPow2(long number) { - String formatted = formatNumbers(number); - if (number == V[V.length - 1]) { - formatted += " (MAX)"; - } else if (number >= 256) { - // Try to figure out if number is a (small multiple of a) power of 2. - long curr = number; - int pow = 0; - while ((curr & 1) == 0) { // N.B. this won't terminate if curr == 0 - curr = curr >>> 1; - pow++; - } - - if (curr == 1) { - formatted += String.format(" (2^%d)", pow); - } else if (curr <= 7) { - formatted += String.format(" (%d*2^%d)", curr, pow); - } + String formatted = basicFormatter.format(aNumber); + if (aNumber >= 1_000_000_000d) { + formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; } return formatted; } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 4be48b902d..74e3e3653d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -70,16 +70,16 @@ public class GT_Item_Machines extends ItemBlock { if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); } - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatPow2(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); } } NBTTagCompound aNBT = aStack.getTagCompound(); -- cgit From 324c870597aef034712d80571f072cb45d609aee Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 8 Aug 2021 07:41:35 -0600 Subject: Remove scientific notation formatter --- src/main/java/gregtech/api/util/GT_Utility.java | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index f1f83c3c14..6ac69f55b3 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -95,9 +95,7 @@ import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; */ public class GT_Utility { /** Formats a number with group separator and at most 2 fraction digits. */ - private static final DecimalFormat basicFormatter = new DecimalFormat(); - /** Formats a number into scientific notation with at most 2 fraction digits. Meant for large numbers. */ - private static final DecimalFormat scientificNotationFormatter = new DecimalFormat("0.##E0"); + private static final DecimalFormat decimalFormat = new DecimalFormat(); /** * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. @@ -112,10 +110,10 @@ public class GT_Utility { public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); static { - DecimalFormatSymbols symbols = basicFormatter.getDecimalFormatSymbols(); + DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); - basicFormatter.setDecimalFormatSymbols(symbols); - basicFormatter.setMaximumFractionDigits(2); + decimalFormat.setDecimalFormatSymbols(symbols); + decimalFormat.setMaximumFractionDigits(2); GregTech_API.sItemStackMappings.add(sFilledContainerToData); GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData); @@ -2230,19 +2228,11 @@ public class GT_Utility { } public static String formatNumbers(long aNumber) { - String formatted = basicFormatter.format(aNumber); - if (aNumber >= 1_000_000_000L) { - formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; - } - return formatted; + return decimalFormat.format(aNumber); } public static String formatNumbers(double aNumber) { - String formatted = basicFormatter.format(aNumber); - if (aNumber >= 1_000_000_000d) { - formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; - } - return formatted; + return decimalFormat.format(aNumber); } /* -- cgit From 2a24e7fd242b062919a938a9a5ec28b9cd1d358b Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 8 Aug 2021 08:39:15 -0600 Subject: Add formatting to getInfoData() --- .../implementations/GT_MetaPipeEntity_Cable.java | 21 +++++++------- .../GT_MetaTileEntity_BasicMachine.java | 12 ++++---- .../GT_MetaTileEntity_Hatch_Output.java | 8 +++--- .../GT_MetaTileEntity_MultiBlockBase.java | 32 ++++++++++++---------- ..._MetaTileEntity_MicrowaveEnergyTransmitter.java | 6 ++-- .../basic/GT_MetaTileEntity_Teleporter.java | 6 ++-- .../multi/GT_MetaTileEntity_DieselEngine.java | 31 +++++++++++++-------- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 26 +++++++++++------- .../GT_MetaTileEntity_ExtremeDieselEngine.java | 31 +++++++++++++-------- .../multi/GT_MetaTileEntity_FusionComputer.java | 12 +++++--- .../multi/GT_MetaTileEntity_HeatExchanger.java | 17 +++++++----- .../multi/GT_MetaTileEntity_LargeTurbine.java | 22 +++++++++------ .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 24 ++++++++++------ .../multi/GT_MetaTileEntity_MultiFurnace.java | 23 +++++++++------- .../multi/GT_MetaTileEntity_ProcessingArray.java | 24 ++++++++-------- .../GT_MetaTileEntity_DigitalChestBase.java | 6 ++-- .../storage/GT_MetaTileEntity_QuantumTank.java | 6 ++-- .../storage/GT_MetaTileEntity_SuperTank.java | 6 ++-- 18 files changed, 181 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index b4396aec3e..439cacff91 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -371,18 +371,19 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } return new String[]{ //EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET, - "Heat: "+ - EnumChatFormatting.RED+ mOverheat +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW+ mMaxOverheat + EnumChatFormatting.RESET, + "Heat: " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(mOverheat) + EnumChatFormatting.RESET + " / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxOverheat) + EnumChatFormatting.RESET, "Max Load (1t):", - EnumChatFormatting.GREEN + Integer.toString(amps) + EnumChatFormatting.RESET +" A / "+ - EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.RESET +" A", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(amps) + EnumChatFormatting.RESET + " A / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.RESET + " A", "Max EU/p (1t):", - EnumChatFormatting.GREEN + Long.toString(volts) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + mVoltage + EnumChatFormatting.RESET +" EU", - "Max Load (20t): "+ - EnumChatFormatting.GREEN + mTransferredAmperageLast20OK + EnumChatFormatting.RESET +" A", - "Max EU/p (20t): "+ - EnumChatFormatting.GREEN + mTransferredVoltageLast20OK + EnumChatFormatting.RESET +" EU" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(volts) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mVoltage) + EnumChatFormatting.RESET + " EU", + "Max Load (20t): " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredAmperageLast20OK) + EnumChatFormatting.RESET + " A", + "Max EU/p (20t): " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredVoltageLast20OK) + EnumChatFormatting.RESET + " EU" }; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index a203097a4e..7c15137691 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -792,14 +792,14 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return new String[]{ EnumChatFormatting.BLUE + mNEIName + EnumChatFormatting.RESET, "Progress:", - EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET +" s", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers((mProgresstime/20)) + EnumChatFormatting.RESET +" s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", "Stored Energy:", - EnumChatFormatting.GREEN + Long.toString(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + getBaseMetaTileEntity().getEUCapacity() + EnumChatFormatting.RESET +" EU", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET + " EU", "Probably uses: " + - EnumChatFormatting.RED + mEUt + EnumChatFormatting.RESET + " EU/t at " + - EnumChatFormatting.RED + (mEUt == 0 ? 0 : mAmperage) + EnumChatFormatting.RESET +" A" + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt == 0 ? 0 : mAmperage) + EnumChatFormatting.RESET +" A" }; } 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 db80c4685b..bb23452220 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 @@ -315,11 +315,11 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { return new String[]{ - EnumChatFormatting.BLUE + "Output Hatch"+ EnumChatFormatting.RESET, + EnumChatFormatting.BLUE + "Output Hatch" + EnumChatFormatting.RESET, "Stored Fluid:", - EnumChatFormatting.GOLD + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName())+ EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(mFluid == null ? 0 : mFluid.amount) + " L"+ EnumChatFormatting.RESET+" "+ - EnumChatFormatting.YELLOW+ getCapacity() + " L"+ EnumChatFormatting.RESET, + 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())) }; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 3b1a963c9e..0a1b2e8b02 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -974,20 +974,24 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } return new String[]{ - /* 1*/ StatCollector.translateToLocal("GT5U.multiblock.Progress")+": " + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / " - + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s", - /* 2*/ StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + - EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - /* 3*/ StatCollector.translateToLocal("GT5U.multiblock.usage")+": "+ EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t", - /* 4*/ StatCollector.translateToLocal("GT5U.multiblock.mei")+": "+ - EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GT5U.machines.tier")+": "+ - EnumChatFormatting.YELLOW+VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET, - /* 5*/ StatCollector.translateToLocal("GT5U.multiblock.problems")+": "+ - EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ - " "+StatCollector.translateToLocal("GT5U.multiblock.efficiency")+": "+ - EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %", - /* 6*/ StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + /* 1*/ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime/20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime/20) + EnumChatFormatting.RESET + " s", + /* 2*/ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + /* 3*/ StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", + /* 4*/ StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, + /* 5*/ StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + /* 6*/ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java index 01f136747c..803bc7e163 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_MicrowaveEnergyTransmitter.java @@ -87,9 +87,9 @@ public class GT_MetaTileEntity_MicrowaveEnergyTransmitter extends GT_MetaTileEnt public String[] getInfoData() { return new String[]{ "Coordinates:", - "X: "+EnumChatFormatting.GREEN+ this.mTargetX+EnumChatFormatting.RESET, - "Y: "+EnumChatFormatting.GREEN+ this.mTargetY+EnumChatFormatting.RESET, - "Z: "+EnumChatFormatting.GREEN+ this.mTargetZ+EnumChatFormatting.RESET, + "X: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetX) + EnumChatFormatting.RESET, + "Y: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetY) + EnumChatFormatting.RESET, + "Z: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetZ) + EnumChatFormatting.RESET, "Dimension: " + EnumChatFormatting.GREEN+this.mTargetD+EnumChatFormatting.RESET, "Dimension Valid: " + (GT_Utility.isRealDimension(this.mTargetD) ? EnumChatFormatting.GREEN+"Yes"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"No"+EnumChatFormatting.RESET), "Dimension Registered: " + (DimensionManager.isDimensionRegistered(this.mTargetD) ? EnumChatFormatting.GREEN+"Yes"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"No"+EnumChatFormatting.RESET) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java index 7d6c0a29ed..eb59f1f7e5 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Teleporter.java @@ -188,9 +188,9 @@ public class GT_MetaTileEntity_Teleporter extends GT_MetaTileEntity_BasicTank { public String[] getInfoData() { return new String[]{ "Coordinates:", - "X: "+ EnumChatFormatting.GREEN+ this.mTargetX+EnumChatFormatting.RESET, - "Y: "+EnumChatFormatting.GREEN+ this.mTargetY+EnumChatFormatting.RESET, - "Z: "+EnumChatFormatting.GREEN+ this.mTargetZ+EnumChatFormatting.RESET, + "X: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetX) + EnumChatFormatting.RESET, + "Y: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetY) + EnumChatFormatting.RESET, + "Z: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.mTargetZ) + EnumChatFormatting.RESET, "Dimension: " + EnumChatFormatting.GREEN+this.mTargetD+EnumChatFormatting.RESET, "Dimension Valid: " + (GT_Utility.isRealDimension(this.mTargetD) ? EnumChatFormatting.GREEN+"Yes"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"No"+EnumChatFormatting.RESET), "Dimension Registered: " + (DimensionManager.isDimensionRegistered(this.mTargetD) ? EnumChatFormatting.GREEN+"Yes"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"No"+EnumChatFormatting.RESET) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java index 8dfc605d6b..c6a30ad085 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -14,6 +14,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffl import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -292,19 +293,25 @@ public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_EnhancedMu return new String[]{ - EnumChatFormatting.BLUE+"Diesel Engine"+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + - EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET +" EU", + EnumChatFormatting.BLUE + "Diesel Engine" + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", getIdealStatus() == getRepairStatus() ? - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t", - StatCollector.translateToLocal("GT5U.engine.consumption")+": " +EnumChatFormatting.YELLOW+fuelConsumption+EnumChatFormatting.RESET+" L/t", - StatCollector.translateToLocal("GT5U.engine.value")+": " +EnumChatFormatting.YELLOW+fuelValue+EnumChatFormatting.RESET+" EU/L", - StatCollector.translateToLocal("GT5U.turbine.fuel")+": " +EnumChatFormatting.GOLD+fuelRemaining+EnumChatFormatting.RESET+" L", - StatCollector.translateToLocal("GT5U.engine.efficiency")+": " +EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.YELLOW+" %", - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": " + EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") + EnumChatFormatting.RESET : + EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.engine.output") + ": " + + EnumChatFormatting.RED + GT_Utility.formatNumbers((mEUt*mEfficiency/10000)) + EnumChatFormatting.RESET + " EU/t", + StatCollector.translateToLocal("GT5U.engine.consumption") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(fuelConsumption) + EnumChatFormatting.RESET + " L/t", + StatCollector.translateToLocal("GT5U.engine.value") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(fuelValue) + EnumChatFormatting.RESET + " EU/L", + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(fuelRemaining) + EnumChatFormatting.RESET + " L", + StatCollector.translateToLocal("GT5U.engine.efficiency") + ": " + + EnumChatFormatting.YELLOW + (mEfficiency/100F) + EnumChatFormatting.YELLOW + " %", + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index d3c9e7176b..b55ae939b6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -358,20 +358,26 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab } return new String[]{ - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", - StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", - StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + -mEUt + EnumChatFormatting.RESET + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + getMaxInputVoltage() + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + - EnumChatFormatting.GREEN + mHeatingCapacity + EnumChatFormatting.RESET + " K", - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mHeatingCapacity) + EnumChatFormatting.RESET + " K", + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java index 1878f25a5f..8c3d474b8b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java @@ -11,6 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffl import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -180,19 +181,25 @@ public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_Die } return new String[]{ - EnumChatFormatting.BLUE+"Extreme Diesel Engine"+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + - EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET +" EU", + EnumChatFormatting.BLUE + "Extreme Diesel Engine" + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", getIdealStatus() == getRepairStatus() ? - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(-mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t", - StatCollector.translateToLocal("GT5U.engine.consumption")+": " +EnumChatFormatting.YELLOW+fuelConsumption+EnumChatFormatting.RESET+" L/t", - StatCollector.translateToLocal("GT5U.engine.value")+": " +EnumChatFormatting.YELLOW+fuelValue+EnumChatFormatting.RESET+" EU/L", - StatCollector.translateToLocal("GT5U.turbine.fuel")+": " +EnumChatFormatting.GOLD+fuelRemaining+EnumChatFormatting.RESET+" L", - StatCollector.translateToLocal("GT5U.engine.efficiency")+": " +EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.YELLOW+" %", - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": " + EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + EnumChatFormatting.GREEN + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") + EnumChatFormatting.RESET : + EnumChatFormatting.RED + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.engine.output") + ": " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt*mEfficiency/10000) + EnumChatFormatting.RESET + " EU/t", + StatCollector.translateToLocal("GT5U.engine.consumption") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(fuelConsumption) + EnumChatFormatting.RESET + " L/t", + StatCollector.translateToLocal("GT5U.engine.value") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(fuelValue) + EnumChatFormatting.RESET + " EU/L", + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(fuelRemaining) + EnumChatFormatting.RESET + " L", + StatCollector.translateToLocal("GT5U.engine.efficiency") + ": " + + EnumChatFormatting.YELLOW + (mEfficiency/100F) + EnumChatFormatting.YELLOW + " %", + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 7084111000..ca6495ea65 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -463,10 +463,14 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity } return new String[]{ - EnumChatFormatting.BLUE+"Fusion Reactor MK "+EnumChatFormatting.RESET+tier, - StatCollector.translateToLocal("GT5U.fusion.req")+": " +EnumChatFormatting.RED+powerRequired+EnumChatFormatting.RESET+"EU/t", - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " +EnumChatFormatting.GREEN+mEUStore+EnumChatFormatting.RESET+" EU / "+EnumChatFormatting.YELLOW+maxEUStore()+EnumChatFormatting.RESET+" EU", - StatCollector.translateToLocal("GT5U.fusion.plasma")+": " +EnumChatFormatting.YELLOW+plasmaOut+EnumChatFormatting.RESET+"L/t"}; + EnumChatFormatting.BLUE + "Fusion Reactor MK " + EnumChatFormatting.RESET + tier, + StatCollector.translateToLocal("GT5U.fusion.req") + ": " + + EnumChatFormatting.RED + GT_Utility.formatNumbers(powerRequired) + EnumChatFormatting.RESET + "EU/t", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mEUStore) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEUStore()) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.fusion.plasma") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(plasmaOut) + EnumChatFormatting.RESET + "L/t"}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index e8beb270e0..fa96971a07 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -16,6 +16,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -302,16 +303,18 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedM public String[] getInfoData() { return new String[]{ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", StatCollector.translateToLocal("GT5U.multiblock.usage") + " " + StatCollector.translateToLocal("GT5U.LHE.steam") + ": " + - (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + (superheated ? -2 * mEUt : -mEUt) + EnumChatFormatting.RESET + " EU/t", + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + GT_Utility.formatNumbers(superheated ? -2 * mEUt : -mEUt) + EnumChatFormatting.RESET + " EU/t", StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", - StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + superheated + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + EnumChatFormatting.GREEN + superheated_threshold + EnumChatFormatting.RESET + StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + superheated + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(superheated_threshold) + EnumChatFormatting.RESET }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java index f0a5abbe62..8966838f3f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -214,16 +214,22 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E } String[] ret = new String[]{ // 8 Lines available for information panels - tRunning + ": " + EnumChatFormatting.RED + mEUt + EnumChatFormatting.RESET + " EU/t", /* 1 */ + tRunning + ": " + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t", /* 1 */ tMaintainance, /* 2 */ - StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + EnumChatFormatting.YELLOW + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", /* 2 */ - StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + /* 3 */ - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", - StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t" + /* 4 */ + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + + EnumChatFormatting.YELLOW + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", /* 2 */ + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + /* 3 */ + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(GT_Utility.safeInt((long) realOptFlow)) + EnumChatFormatting.RESET + " L/t" + /* 4 */ EnumChatFormatting.YELLOW + " (" + (looseFit ? StatCollector.translateToLocal("GT5U.turbine.loose") : StatCollector.translateToLocal("GT5U.turbine.tight")) + ")", /* 5 */ - StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + EnumChatFormatting.GOLD + storedFluid + EnumChatFormatting.RESET + "L", /* 6 */ - StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + EnumChatFormatting.RED + tDura + EnumChatFormatting.RESET + "%", /* 7 */ - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(storedFluid) + EnumChatFormatting.RESET + "L", /* 6 */ + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + + EnumChatFormatting.RED + tDura + EnumChatFormatting.RESET + "%", /* 7 */ + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ }; if (!this.getClass().getName().contains("Steam")) ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t"; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index c34f190242..76c5533c09 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -238,16 +238,22 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar } String[] ret = new String[]{ // 8 Lines available for information panels - tRunning + ": " + EnumChatFormatting.RED+mEUt+EnumChatFormatting.RESET+" EU/t", /* 1 */ + tRunning + ": " + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t", /* 1 */ tMaintainance, /* 2 */ - StatCollector.translateToLocal("GT5U.turbine.efficiency")+": "+EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.RESET+"%", /* 2 */ - StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ /* 3 */ - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+GT_Utility.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/s" + /* 4 */ - EnumChatFormatting.YELLOW+" ("+(looseFit?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", /* 5 */ - StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", /* 6 */ - StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+EnumChatFormatting.RED+Integer.toString(tDura)+EnumChatFormatting.RESET+"%", /* 7 */ - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" /* 8 */ + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + + EnumChatFormatting.YELLOW + (mEfficiency/100F) + EnumChatFormatting.RESET + "%", /* 2 */ + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + /* 3 */ + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(GT_Utility.safeInt((long)realOptFlow)) + EnumChatFormatting.RESET + " L/s" + /* 4 */ + EnumChatFormatting.YELLOW + " (" + (looseFit?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight")) + ")", /* 5 */ + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(storedFluid) + EnumChatFormatting.RESET + "L", /* 6 */ + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + + EnumChatFormatting.RED + Integer.toString(tDura) + EnumChatFormatting.RESET + "%", /* 7 */ + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ }; if (!this.getClass().getName().contains("Steam")) ret[4]=StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+GT_Utility.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/s"; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 907de38f6b..37f56deef5 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -226,23 +226,26 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu return new String[]{ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + - EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + - EnumChatFormatting.RED + -mEUt + EnumChatFormatting.RESET + " EU/t", + EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + - EnumChatFormatting.YELLOW + getMaxInputVoltage() + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", StatCollector.translateToLocal("GT5U.MS.multismelting") + ": " + - EnumChatFormatting.GREEN + mLevel * 8 + EnumChatFormatting.RESET + " Discount: (EU/t) / " + EnumChatFormatting.GREEN + mCostDiscount + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" + EnumChatFormatting.GREEN + mLevel * 8 + EnumChatFormatting.RESET + + " Discount: (EU/t) / " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mCostDiscount) + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index ea56266b41..26cccb7819 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -385,25 +385,27 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu return new String[]{ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + - EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + - EnumChatFormatting.RED + -mEUt + EnumChatFormatting.RESET + " EU/t", + EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + - EnumChatFormatting.YELLOW + getMaxInputVoltage() + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", StatCollector.translateToLocal("GT5U.PA.machinetier") + ": " + - EnumChatFormatting.GREEN + tTier + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.PA.discount") + ": " + + EnumChatFormatting.GREEN + tTier + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.PA.discount") + ": " + EnumChatFormatting.GREEN + (1 << mMult) + EnumChatFormatting.RESET + " x", - StatCollector.translateToLocal("GT5U.PA.parallel") + ": " + EnumChatFormatting.GREEN + ((mInventory[1] != null) ? (mInventory[1].stackSize << mMult) : 0) + EnumChatFormatting.RESET + StatCollector.translateToLocal("GT5U.PA.parallel") + ": " + + EnumChatFormatting.GREEN + GT_Utility.formatNumbers((mInventory[1] != null) ? (mInventory[1].stackSize << mMult) : 0) + EnumChatFormatting.RESET }; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 6e01e456cf..0a426adf35 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -367,15 +367,15 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti "Stored Items:", EnumChatFormatting.GOLD + "No Items" + EnumChatFormatting.RESET, EnumChatFormatting.GREEN + "0" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxItemCount()) + EnumChatFormatting.RESET }; } return new String[]{ EnumChatFormatting.BLUE + chestName() + EnumChatFormatting.RESET, "Stored Items:", EnumChatFormatting.GOLD + getItemStack().getDisplayName() + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(getItemCount()) + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(getItemCount()) + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxItemCount()) + EnumChatFormatting.RESET }; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java index dc9682336b..ea935f1360 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java @@ -145,15 +145,15 @@ public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { "Stored Fluid:", EnumChatFormatting.GOLD + "No Fluid" + EnumChatFormatting.RESET, EnumChatFormatting.GREEN + Integer.toString(0) + " L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L" + EnumChatFormatting.RESET }; } return new String[]{ EnumChatFormatting.BLUE + "Quantum Tank" + EnumChatFormatting.RESET, "Stored Fluid:", EnumChatFormatting.GOLD + mFluid.getLocalizedName() + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L" + EnumChatFormatting.RESET }; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java index c5b92d0863..edb69abb20 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java @@ -145,15 +145,15 @@ public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { "Stored Fluid:", EnumChatFormatting.GOLD + "No Fluid" + EnumChatFormatting.RESET, EnumChatFormatting.GREEN + "0 L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L" + EnumChatFormatting.RESET }; } return new String[]{ EnumChatFormatting.BLUE + "Super Tank" + EnumChatFormatting.RESET, "Stored Fluid:", EnumChatFormatting.GOLD + mFluid.getLocalizedName() + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L" + EnumChatFormatting.RESET }; } -- cgit From 15e80c3195c4bfa04a714b236c493d0a45041385 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 8 Aug 2021 10:56:41 -0600 Subject: Add formatting to pipe heat capacity --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 2e7fc8e8d9..128f6fa916 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -643,12 +643,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (mPipeAmount == 1) { return new String[]{ EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY }; } else { return new String[]{ EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY, EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY }; } -- cgit From d577f73e8f33b2c6e04110ceddf35a59bc958716 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 8 Aug 2021 10:57:14 -0600 Subject: Add formatting to getCoordinateScan() --- src/main/java/gregtech/api/util/GT_Utility.java | 70 +++++++++++++++++-------- 1 file changed, 48 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 6ac69f55b3..77194a7bff 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1912,15 +1912,25 @@ public class GT_Utility { Block tBlock = aWorld.getBlock(aX, aY, aZ); - tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET+ " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " D: " +EnumChatFormatting.AQUA+ aWorld.provider.dimensionId +EnumChatFormatting.RESET+ " -----"); + tList.add( + "----- X: " + EnumChatFormatting.AQUA + formatNumbers(aX) + EnumChatFormatting.RESET + + " Y: " + EnumChatFormatting.AQUA + formatNumbers(aY) + EnumChatFormatting.RESET + + " Z: " + EnumChatFormatting.AQUA + formatNumbers(aZ) + EnumChatFormatting.RESET + + " D: " + EnumChatFormatting.AQUA + aWorld.provider.dimensionId + EnumChatFormatting.RESET + " -----"); try { if (tTileEntity instanceof IInventory) - tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET); + tList.add( + trans("162","Name: ") + EnumChatFormatting.BLUE + ((IInventory) tTileEntity).getInventoryName() + EnumChatFormatting.RESET + + trans("163"," MetaData: ") + EnumChatFormatting.AQUA + aWorld.getBlockMetadata(aX, aY, aZ) + EnumChatFormatting.RESET); else - tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET); - - tList.add(trans("164","Hardness: ") +EnumChatFormatting.YELLOW+ tBlock.getBlockHardness(aWorld, aX, aY, aZ) +EnumChatFormatting.RESET+ trans("165"," Blast Resistance: ") +EnumChatFormatting.YELLOW+ tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) +EnumChatFormatting.RESET); - if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD+ trans("166","Is valid Beacon Pyramid Material") +EnumChatFormatting.RESET); + tList.add( + trans("162","Name: ") + EnumChatFormatting.BLUE + tBlock.getUnlocalizedName() + EnumChatFormatting.RESET + + trans("163"," MetaData: ") + EnumChatFormatting.AQUA + aWorld.getBlockMetadata(aX, aY, aZ) + EnumChatFormatting.RESET); + + tList.add( + trans("164","Hardness: ") + EnumChatFormatting.YELLOW + tBlock.getBlockHardness(aWorld, aX, aY, aZ) + EnumChatFormatting.RESET + + trans("165"," Blast Resistance: ") + EnumChatFormatting.YELLOW + tBlock.getExplosionResistance(aPlayer, aWorld, aX, aY, aZ, aPlayer.posX, aPlayer.posY, aPlayer.posZ) + EnumChatFormatting.RESET); + if (tBlock.isBeaconBase(aWorld, aX, aY, aZ, aX, aY + 1, aZ)) tList.add(EnumChatFormatting.GOLD + trans("166","Is valid Beacon Pyramid Material") + EnumChatFormatting.RESET); } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } @@ -1930,7 +1940,10 @@ public class GT_Utility { rEUAmount += 500; FluidTankInfo[] tTanks = ((IFluidHandler) tTileEntity).getTankInfo(ForgeDirection.getOrientation(aSide)); if (tTanks != null) for (byte i = 0; i < tTanks.length; i++) { - tList.add(trans("167","Tank ") + i + ": " +EnumChatFormatting.GREEN+ formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) +EnumChatFormatting.RESET+ " L / " +EnumChatFormatting.YELLOW+ formatNumbers(tTanks[i].capacity) +EnumChatFormatting.RESET+ " L " +EnumChatFormatting.GOLD+ getFluidName(tTanks[i].fluid, true)+EnumChatFormatting.RESET); + tList.add( + trans("167","Tank ") + i + ": " + + EnumChatFormatting.GREEN + formatNumbers((tTanks[i].fluid == null ? 0 : tTanks[i].fluid.amount)) + EnumChatFormatting.RESET + " L / " + + EnumChatFormatting.YELLOW + formatNumbers(tTanks[i].capacity) + EnumChatFormatting.RESET + " L " + EnumChatFormatting.GOLD + getFluidName(tTanks[i].fluid, true) + EnumChatFormatting.RESET); } } } catch (Throwable e) { @@ -1947,8 +1960,12 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.reactor.IReactor) { rEUAmount += 500; - tList.add(trans("168","Heat: ") +EnumChatFormatting.GREEN+ ((ic2.api.reactor.IReactor) tTileEntity).getHeat() +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+ ((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()+EnumChatFormatting.RESET); - tList.add(trans("169","HEM: ") +EnumChatFormatting.YELLOW+((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() +EnumChatFormatting.RESET/*+ trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/); + tList.add( + trans("168","Heat: ") + EnumChatFormatting.GREEN + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getHeat()) + EnumChatFormatting.RESET + " / " + + EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.reactor.IReactor) tTileEntity).getMaxHeat()) + EnumChatFormatting.RESET); + tList.add( + trans("169","HEM: ") + EnumChatFormatting.YELLOW + ((ic2.api.reactor.IReactor) tTileEntity).getHeatEffectModifier() + EnumChatFormatting.RESET + /* + trans("170"," Base EU Output: ")/* + ((ic2.api.reactor.IReactor)tTileEntity).getOutput()*/); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2002,7 +2019,7 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.energy.tile.IEnergyConductor) { rEUAmount += 200; - tList.add(trans("175","Conduction Loss: ") +EnumChatFormatting.YELLOW+ ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss()+EnumChatFormatting.RESET); + tList.add(trans("175","Conduction Loss: ") + EnumChatFormatting.YELLOW + ((ic2.api.energy.tile.IEnergyConductor) tTileEntity).getConductionLoss() + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2010,7 +2027,9 @@ public class GT_Utility { try { if (tTileEntity instanceof ic2.api.tile.IEnergyStorage) { rEUAmount += 200; - tList.add(trans("176","Contained Energy: ") +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getStored() +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ ((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()+EnumChatFormatting.RESET+" EU"); + tList.add( + trans("176","Contained Energy: ") + EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getStored()) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + formatNumbers(((ic2.api.tile.IEnergyStorage) tTileEntity).getCapacity()) + EnumChatFormatting.RESET + " EU"); //aList.add(((ic2.api.tile.IEnergyStorage)tTileEntity).isTeleporterCompatible(ic2.api.Direction.YP)?"Teleporter Compatible":"Not Teleporter Compatible"); } } catch (Throwable e) { @@ -2019,7 +2038,7 @@ public class GT_Utility { try { if (tTileEntity instanceof IUpgradableMachine) { rEUAmount += 500; - if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN+ trans("177","Has Muffler Upgrade") +EnumChatFormatting.RESET); + if (((IUpgradableMachine) tTileEntity).hasMufflerUpgrade()) tList.add(EnumChatFormatting.GREEN + trans("177","Has Muffler Upgrade") + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2027,7 +2046,7 @@ public class GT_Utility { try { if (tTileEntity instanceof IMachineProgress) { if (((IMachineProgress) tTileEntity).isAllowedToWork()) { - tList.add("Disabled." + EnumChatFormatting.RED + EnumChatFormatting.RESET); + tList.add("Disabled." + EnumChatFormatting.RED + EnumChatFormatting.RESET); } if (((IMachineProgress) tTileEntity).wasShutdown()) { tList.add("Shut down due to power loss." + EnumChatFormatting.RED + EnumChatFormatting.RESET); @@ -2035,7 +2054,8 @@ public class GT_Utility { rEUAmount += 400; int tValue = 0; if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress())) - tList.add(trans("178","Progress/Load: ") +EnumChatFormatting.GREEN+ formatNumbers(((IMachineProgress) tTileEntity).getProgress()) +EnumChatFormatting.RESET+ " / " +EnumChatFormatting.YELLOW+ formatNumbers(tValue) +EnumChatFormatting.RESET); + tList.add(trans("178","Progress/Load: ") + EnumChatFormatting.GREEN + formatNumbers(((IMachineProgress) tTileEntity).getProgress()) + EnumChatFormatting.RESET + " / " + + EnumChatFormatting.YELLOW + formatNumbers(tValue) + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2051,16 +2071,22 @@ public class GT_Utility { } try { if (tTileEntity instanceof IBasicEnergyContainer && ((IBasicEnergyContainer) tTileEntity).getEUCapacity() > 0) { - tList.add(trans("179","Max IN: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getInputVoltage() + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+((IBasicEnergyContainer)tTileEntity).getInputAmperage()+EnumChatFormatting.RESET+trans("183"," A")); - tList.add(trans("181","Max OUT: ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputVoltage() + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " +EnumChatFormatting.RESET+ trans("182"," EU at ") +EnumChatFormatting.RED+ ((IBasicEnergyContainer) tTileEntity).getOutputAmperage() +EnumChatFormatting.RESET+ trans("183"," A")); - tList.add(trans("184","Energy: ") +EnumChatFormatting.GREEN+ formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) +EnumChatFormatting.RESET+ " EU / " +EnumChatFormatting.YELLOW+ formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) +EnumChatFormatting.RESET+ " EU"); + tList.add( + trans("179","Max IN: ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getInputVoltage()) + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getInputVoltage())] + ") " + EnumChatFormatting.RESET + + trans("182"," EU at ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer)tTileEntity).getInputAmperage()) + EnumChatFormatting.RESET + trans("183"," A")); + tList.add( + trans("181","Max OUT: ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputVoltage()) + " (" + GT_Values.VN[getTier(((IBasicEnergyContainer) tTileEntity).getOutputVoltage())] + ") " + EnumChatFormatting.RESET + + trans("182"," EU at ") + EnumChatFormatting.RED + formatNumbers(((IBasicEnergyContainer) tTileEntity).getOutputAmperage()) + EnumChatFormatting.RESET + trans("183"," A")); + tList.add( + trans("184","Energy: ") + EnumChatFormatting.GREEN + formatNumbers(((IBasicEnergyContainer) tTileEntity).getStoredEU()) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + formatNumbers(((IBasicEnergyContainer) tTileEntity).getEUCapacity()) + EnumChatFormatting.RESET + " EU"); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); } try { if (tTileEntity instanceof IGregTechTileEntity) { - tList.add(trans("186","Owned by: ") +EnumChatFormatting.BLUE+ ((IGregTechTileEntity) tTileEntity).getOwnerName()+EnumChatFormatting.RESET); + tList.add(trans("186","Owned by: ") + EnumChatFormatting.BLUE + ((IGregTechTileEntity) tTileEntity).getOwnerName() + EnumChatFormatting.RESET); } } catch (Throwable e) { if (D1) e.printStackTrace(GT_Log.err); @@ -2112,15 +2138,15 @@ public class GT_Utility { if (aPlayer.capabilities.isCreativeMode) { FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read if (tFluid!=null) - tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L"); + tList.add(EnumChatFormatting.GOLD + tFluid.getLocalizedName() + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + formatNumbers(tFluid.amount) + EnumChatFormatting.RESET + " L"); else - tList.add(EnumChatFormatting.GOLD+trans("201","Nothing")+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ '0' +EnumChatFormatting.RESET+" L"); + tList.add(EnumChatFormatting.GOLD + trans("201","Nothing") + EnumChatFormatting.RESET + ": " + EnumChatFormatting.YELLOW + '0' + EnumChatFormatting.RESET + " L"); } // if(aPlayer.capabilities.isCreativeMode){ int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair()); - if(chunkData !=null){ + if(chunkData != null){ if(chunkData[GTPOLLUTION]>0){ - tList.add(trans("202","Pollution in Chunk: ")+EnumChatFormatting.RED+chunkData[GTPOLLUTION]+EnumChatFormatting.RESET+trans("203"," gibbl")); + tList.add(trans("202","Pollution in Chunk: ") + EnumChatFormatting.RED + formatNumbers(chunkData[GTPOLLUTION]) + EnumChatFormatting.RESET + trans("203"," gibbl")); }else{ tList.add(EnumChatFormatting.GREEN+trans("204","No Pollution in Chunk! HAYO!")+EnumChatFormatting.RESET); } -- cgit From 2b8101172714d227e64380b500e3c1b8528b4aba Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 8 Aug 2021 11:50:10 -0600 Subject: Fix GT_MetaTileEntity_Buffer sort mode chat message --- .../api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 21cf0d73f1..d5741f599d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -350,7 +350,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (aPlayer.isSneaking()) { // I was so proud of all this but I literally just copied code from OutputBus bSortStacks = !bSortStacks; - GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (bSortStacks ? "Disabled" : "Enabled"))); + GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (bSortStacks ? "Enabled" : "Disabled"))); return true; } return super.onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); -- cgit From 915eafcfcaeb1d3b79d7ee85ac9e7da09a006a8c Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Tue, 10 Aug 2021 20:19:18 +0300 Subject: Added Damage Source Based on Hot Item (for gloves in GTNHCoreMod) --- .../api/damagesources/GT_DamageSources.java | 19 +++++++++- src/main/java/gregtech/api/util/GT_Utility.java | 18 ++++++--- src/main/java/gregtech/common/GT_Proxy.java | 43 +++++----------------- 3 files changed, 39 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java index fd13b9cfee..45f3fd5323 100644 --- a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java +++ b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java @@ -1,8 +1,11 @@ package gregtech.api.damagesources; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.*; +import javax.annotation.Nullable; + public class GT_DamageSources { public static DamageSource getElectricDamage() { return ic2.api.info.Info.DMG_ELECTRIC; @@ -33,7 +36,7 @@ public class GT_DamageSources { } private static class DamageSourceCombat extends EntityDamageSource { - private IChatComponent mDeathMessage; + private final IChatComponent mDeathMessage; public DamageSourceCombat(String aType, EntityLivingBase aPlayer, IChatComponent aDeathMessage) { super(aType, aPlayer); @@ -70,6 +73,20 @@ public class GT_DamageSources { } } + public static class DamageSourceHotItem extends DamageSourceHeat { + @Nullable + private final ItemStack stack; + + public DamageSourceHotItem(@Nullable ItemStack cause) { + this.stack = cause; + } + + @Nullable + public ItemStack getDamagingStack() { + return stack; + } + } + public static class DamageSourceExploding extends DamageSource { public DamageSourceExploding() { super("exploded"); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 77194a7bff..28c6b266ec 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -9,6 +9,7 @@ import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; +import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem; import gregtech.api.enchants.Enchantment_Radioactivity; import gregtech.api.enums.*; import gregtech.api.events.BlockScanningEvent; @@ -55,10 +56,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; @@ -1571,9 +1569,17 @@ public class GT_Utility { return isWearingFullGasHazmat(aEntity); } - public static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage) { + public static boolean applyHeatDamage(EntityLivingBase entity, float damage) { + return applyHeatDamage(entity, damage, GT_DamageSources.getHeatDamage()); + } + + public static boolean applyHeatDamageFromItem(EntityLivingBase entity, float damage, ItemStack item) { + return applyHeatDamage(entity, damage, new DamageSourceHotItem(item)); + } + + private static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage, DamageSource source) { if (aDamage > 0 && aEntity != null && aEntity.getActivePotionEffect(Potion.fireResistance) == null && !isWearingFullHeatHazmat(aEntity)) { - aEntity.attackEntityFrom(GT_DamageSources.getHeatDamage(), aDamage); + aEntity.attackEntityFrom(source, aDamage); return true; } return false; diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index bff044b4c3..76a7b01e85 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1,10 +1,6 @@ package gregtech.common; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.IFuelHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.*; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; @@ -15,16 +11,8 @@ import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.genetics.AlleleManager; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OreDictNames; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; +import gregtech.api.enums.*; import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.IBlockOnWalkOver; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.internal.IGT_Mod; @@ -88,22 +76,11 @@ import org.apache.commons.lang3.text.WordUtils; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.stream.Collectors; import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.GT_Values.debugEntityCramming; @@ -1520,7 +1497,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { float tHeat = GT_Utility.getHeatDamageFromItem(tStack); if (tHeat != 0.0F) { if (tHeat > 0.0F) { - GT_Utility.applyHeatDamage(aEvent.player, tHeat); + GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); } else { GT_Utility.applyFrostDamage(aEvent.player, -tHeat); } @@ -1640,7 +1617,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { float tHeat = GT_Utility.getHeatDamageFromItem(tStack); if (tHeat != 0.0F) { if (tHeat > 0.0F) { - GT_Utility.applyHeatDamage(aEvent.player, tHeat); + GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); } else { GT_Utility.applyFrostDamage(aEvent.player, -tHeat); } @@ -1795,7 +1772,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), - ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + ItemList.Cell_Empty.get(1L), 1000); int hydrogenAmount = 2 * i + 2; GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), Materials.Hydrogen.getGas(hydrogenAmount * 1000), @@ -1824,7 +1801,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, null, aMaterial.mRGBa, 2, 775, GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), - ItemList.Cell_Empty.get(1L, new Object[0]), 1000); + ItemList.Cell_Empty.get(1L), 1000); GT_Values.RA.addCrackingRecipe(i + 1, new FluidStack(uncrackedFluid, 1000), GT_ModHandler.getSteam(1000), new FluidStack(crackedFluids[i], 1000), 40 + 20 * i, 240 + 120 * i); @@ -2142,9 +2119,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { boolean isHeat = GT_Utility.isStackInList(aStack, GregTech_API.sHeatHazmatList); boolean isRadio = GT_Utility.isStackInList(aStack, GregTech_API.sRadioHazmatList); boolean isElectro = GT_Utility.isStackInList(aStack, GregTech_API.sElectroHazmatList); - if(isGas && isBio && isFrost && isHeat && isRadio && isElectro) - return true; - return false; + return isGas && isBio && isFrost && isHeat && isRadio && isElectro; } @SubscribeEvent -- cgit From c614c62d8277217a377a606d718dd398c1b53f72 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Wed, 11 Aug 2021 18:00:18 +0300 Subject: Optionally disable automation access to the digital chests with storage buses attached --- src/main/java/gregtech/GT_Mod.java | 2 +- src/main/java/gregtech/api/enums/GT_Values.java | 4 ++++ .../GT_MetaTileEntity_DigitalChestBase.java | 23 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 590f01292e..2f26833fb6 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -289,7 +289,7 @@ public class GT_Mod implements IGT_Mod { GT_Values.enableChunkloaders = tMainConfig.get("machines", "enableChunkloaders", true).getBoolean(true); GT_Values.alwaysReloadChunkloaders = tMainConfig.get("machines", "alwaysReloadChunkloaders", false).getBoolean(false); GT_Values.debugChunkloaders = tMainConfig.get("machines", "debugChunkloaders", false).getBoolean(false); - + GT_Values.disableDigitalChestsExternalAccess = tMainConfig.get("machines", "disableDigitalChestsExternalAccess", false).getBoolean(false); GregTech_API.TICKS_FOR_LAG_AVERAGING = tMainConfig.get(aTextGeneral, "TicksForLagAveragingWithScanner", 25).getInt(25); GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = tMainConfig.get(aTextGeneral, "MillisecondsPassedInGTTileEntityUntilLagWarning", 100).getInt(100); if (tMainConfig.get(aTextGeneral, "disable_STDOUT", false).getBoolean(false)) { diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index 7152663c42..0c484d05e0 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -302,4 +302,8 @@ public class GT_Values { public static boolean hideAssLineRecipes = false; public static boolean updateFluidDisplayItems = true; public static final int STEAM_PER_WATER = 160; + /** + * If true, then digital chest with AE2 storage bus will be accessible only through AE2 + */ + public static boolean disableDigitalChestsExternalAccess = false; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 0a426adf35..1bd7ead0d4 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -2,6 +2,7 @@ package gregtech.common.tileentities.storage; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; @@ -406,6 +407,24 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti }); } + @Optional.Method(modid = "appliedenergistics2") + private boolean hasActiveMEConnection() { + if (listeners == null || listeners.isEmpty()) + return false; + for (Map.Entry, Object> e : listeners.entrySet()) + { + if ((e.getKey() instanceof appeng.api.parts.IPart)) + { + appeng.api.networking.IGridNode n = ((appeng.api.parts.IPart) e.getKey()).getGridNode(); + if (n != null && n.isActive()) + return true; + } + } + // if there are no active storage buses - clear the listeners + listeners = null; + return false; + } + @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("mItemCount", getItemCount()); @@ -426,11 +445,15 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) + return false; return aIndex == 1; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) + return false; return aIndex == 0 && (mInventory[0] == null || GT_Utility.areStacksEqual(mInventory[0], aStack)); } -- cgit From 43feab055e075c19df598841ffa0da477b1eecef Mon Sep 17 00:00:00 2001 From: repo_alt Date: Wed, 11 Aug 2021 18:49:31 +0300 Subject: use `clear` to avoid hash map recreation --- .../common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 1bd7ead0d4..7110ed20f9 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -421,7 +421,7 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti } } // if there are no active storage buses - clear the listeners - listeners = null; + listeners.clear(); return false; } -- cgit From a94cc1810c20d527ec119c9cc43e5b0fde1c335e Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 12 Aug 2021 02:37:21 +0300 Subject: Item Renderers: improved readability --- .../gregtech/common/render/GT_FlaskRenderer.java | 23 +++++------ .../render/GT_MetaGenerated_Item_Renderer.java | 46 ++++++++++------------ 2 files changed, 33 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/render/GT_FlaskRenderer.java b/src/main/java/gregtech/common/render/GT_FlaskRenderer.java index 7ba4d8e037..48d9b0bf90 100644 --- a/src/main/java/gregtech/common/render/GT_FlaskRenderer.java +++ b/src/main/java/gregtech/common/render/GT_FlaskRenderer.java @@ -1,5 +1,6 @@ package gregtech.common.render; +import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.ItemList; import gregtech.common.items.GT_VolumetricFlask; @@ -15,8 +16,8 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) -public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { +@SideOnly(Side.CLIENT) +public final class GT_FlaskRenderer implements IItemRenderer { public GT_FlaskRenderer() { MinecraftForgeClient.registerItemRenderer(ItemList.VOLUMETRIC_FLASK.getItem(), this); } @@ -36,8 +37,8 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); IIcon icon = item.getIconIndex(); - GL11.glEnable(3042); - GL11.glEnable(3008); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); if (type.equals(ItemRenderType.ENTITY)) { GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); @@ -56,7 +57,7 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe IIcon fluidicon = fs.getFluid().getIcon(fs); int fluidColor = fs.getFluid().getColor(fs); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(0, 1); + GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE); if (type.equals(ItemRenderType.INVENTORY)) { DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); } else { @@ -65,8 +66,8 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe } Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glBlendFunc(770, 771); - GL11.glDepthFunc(514); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); if (type.equals(ItemRenderType.INVENTORY)) { DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); @@ -76,17 +77,17 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe } GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); - GL11.glDepthFunc(515); + GL11.glDepthFunc(GL11.GL_LEQUAL); } Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (type.equals(ItemRenderType.INVENTORY)) { DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); } - GL11.glDisable(3008); - GL11.glDisable(3042); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); } } diff --git a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java index 6e4aadc938..f40443096e 100644 --- a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java +++ b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java @@ -15,13 +15,10 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -import java.util.Iterator; - public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { public GT_MetaGenerated_Item_Renderer() { - GT_MetaGenerated_Item tItem; - for (Iterator i$ = GT_MetaGenerated_Item.sInstances.values().iterator(); i$.hasNext(); MinecraftForgeClient.registerItemRenderer(tItem, this)) { - tItem = (GT_MetaGenerated_Item) i$.next(); + for (GT_MetaGenerated_Item item : GT_MetaGenerated_Item.sInstances.values()) { + MinecraftForgeClient.registerItemRenderer(item, this); } } @@ -53,7 +50,7 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { GT_MetaGenerated_Item aItem = (GT_MetaGenerated_Item) aStack.getItem(); - GL11.glEnable(3042); + GL11.glEnable(GL11.GL_BLEND); if (type == IItemRenderer.ItemRenderType.ENTITY) { if (RenderItem.renderInFrame) { GL11.glScalef(0.85F, 0.85F, 0.85F); @@ -67,7 +64,7 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { if (aMetaData < aItem.mOffset) { IIconContainer aIcon = aItem.getIconContainer(aMetaData); IIcon tOverlay = null; - IIcon tFluidIcon = null; + IIcon fluidIcon = null; IIcon tIcon; if (aIcon == null) { tIcon = aStack.getIconIndex(); @@ -79,12 +76,12 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { return; } FluidStack tFluid = GT_Utility.getFluidForFilledItem(aStack, true); - if ((tOverlay != null) && (tFluid != null) && (tFluid.getFluid() != null)) { - tFluidIcon = tFluid.getFluid().getIcon(tFluid); + if (tOverlay != null && tFluid != null && tFluid.getFluid() != null) { + fluidIcon = tFluid.getFluid().getIcon(tFluid); } Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); - if (tFluidIcon == null) { + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if (fluidIcon == null) { short[] tModulation = aItem.getRGBa(aStack); GL11.glColor3f(tModulation[0] / 255.0F, tModulation[1] / 255.0F, tModulation[2] / 255.0F); } @@ -93,24 +90,23 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { } else { ItemRenderer.renderItemIn2D(Tessellator.instance, tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); } - if (tFluidIcon != null) { - assert (tFluid != null); + if (fluidIcon != null) { int tColor = tFluid.getFluid().getColor(tFluid); GL11.glColor3f((tColor >> 16 & 0xFF) / 255.0F, (tColor >> 8 & 0xFF) / 255.0F, (tColor & 0xFF) / 255.0F); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glBlendFunc(770, 771); - GL11.glDepthFunc(514); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { - GT_RenderUtil.renderItemIcon(tFluidIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + GT_RenderUtil.renderItemIcon(fluidIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { - ItemRenderer.renderItemIn2D(Tessellator.instance, tFluidIcon.getMaxU(), tFluidIcon.getMinV(), tFluidIcon.getMinU(), tFluidIcon.getMaxV(), tFluidIcon.getIconWidth(), tFluidIcon.getIconHeight(), 0.0625F); + ItemRenderer.renderItemIn2D(Tessellator.instance, fluidIcon.getMaxU(), fluidIcon.getMinV(), fluidIcon.getMinU(), fluidIcon.getMaxV(), fluidIcon.getIconWidth(), fluidIcon.getIconHeight(), 0.0625F); } - GL11.glDepthFunc(515); + GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glColor3f(1.0F, 1.0F, 1.0F); if (tOverlay != null) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { @@ -120,19 +116,19 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { } else { IIcon tIcon; if (aItem.mIconList[(aMetaData - aItem.mOffset)].length > 1) { - Long[] tStats = (Long[]) aItem.mElectricStats.get(Short.valueOf(aMetaData)); + Long[] tStats = aItem.mElectricStats.get(aMetaData); - if ((tStats != null) && (tStats[3].longValue() < 0L)) { + if ((tStats != null) && (tStats[3] < 0L)) { long tCharge = aItem.getRealCharge(aStack); if (tCharge <= 0L) { tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][1]; } else { - if (tCharge >= tStats[0].longValue()) { + if (tCharge >= tStats[0]) { tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][8]; } else { - tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][(7 - (int) java.lang.Math.max(0L, java.lang.Math.min(5L, (tStats[0].longValue() - tCharge) * 6L / tStats[0].longValue())))]; + tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][(7 - (int) Math.max(0L, Math.min(5L, (tStats[0] - tCharge) * 6L / tStats[0])))]; } } } else { @@ -142,13 +138,13 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][0]; } Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { ItemRenderer.renderItemIn2D(Tessellator.instance, tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); } } - GL11.glDisable(3042); + GL11.glDisable(GL11.GL_BLEND); } } -- cgit From 53df8347026d0b66acffe0c6285c97bbafdf4834 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 12 Aug 2021 03:35:42 +0300 Subject: Sped up GT_Utility#areUnificationsEqual --- src/main/java/gregtech/api/util/GT_Utility.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 28c6b266ec..17606b85a4 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -898,7 +898,7 @@ public class GT_Utility { } public static boolean areUnificationsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { - return areStacksEqual(GT_OreDictUnificator.get(aStack1), GT_OreDictUnificator.get(aStack2), aIgnoreNBT); + return areStacksEqual(GT_OreDictUnificator.get_nocopy(aStack1), GT_OreDictUnificator.get_nocopy(aStack2), aIgnoreNBT); } public static String getFluidName(Fluid aFluid, boolean aLocalized) { -- cgit From daa13f1cf8e5e0af0b6e4e92d1889ef9f642b0aa Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Thu, 12 Aug 2021 05:07:46 +0300 Subject: Added liquid rendering inside Large Fluid Pipe --- src/main/java/gregtech/GT_Mod.java | 6 ++ src/main/java/gregtech/api/enums/ItemList.java | 13 +++- .../render/GT_MetaGenerated_Item_Renderer.java | 76 +++++++++++++++++++++ src/main/java/gregtech/loaders/ExtraIcons.java | 36 ++++++++++ .../gregtech/textures/items/gt.metaitem.01/405.png | Bin 303 -> 252 bytes .../gregtech/textures/items/gt.metaitem.01/406.png | Bin 290 -> 226 bytes .../gregtech/textures/items/gt.metaitem.01/407.png | Bin 2975 -> 2902 bytes .../gregtech/textures/items/gt.metaitem.01/408.png | Bin 2959 -> 2892 bytes .../gregtech/textures/items/gt.metaitem.01/409.png | Bin 2932 -> 2858 bytes .../gregtech/textures/items/gt.metaitem.01/410.png | Bin 2917 -> 2851 bytes .../gregtech/textures/items/gt.metaitem.01/411.png | Bin 2955 -> 2902 bytes .../gregtech/textures/items/gt.metaitem.01/412.png | Bin 2966 -> 2902 bytes .../gregtech/textures/items/gt.metaitem.01/413.png | Bin 2941 -> 2894 bytes .../large_fluid_cell_custom/aluminium_inner.png | Bin 0 -> 155 bytes .../large_fluid_cell_custom/chromium_inner.png | Bin 0 -> 155 bytes .../large_fluid_cell_custom/iridium_inner.png | Bin 0 -> 155 bytes .../large_fluid_cell_custom/neutronium_inner.png | Bin 0 -> 155 bytes .../items/large_fluid_cell_custom/osmium_inner.png | Bin 0 -> 155 bytes .../stainlesssteel_inner.png | Bin 0 -> 155 bytes .../items/large_fluid_cell_custom/steel_inner.png | Bin 0 -> 155 bytes .../large_fluid_cell_custom/titanium_inner.png | Bin 0 -> 155 bytes .../tungstensteel_inner.png | Bin 0 -> 155 bytes 22 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 src/main/java/gregtech/loaders/ExtraIcons.java create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/aluminium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/chromium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/iridium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/neutronium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/osmium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/stainlesssteel_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/steel_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/titanium_inner.png create mode 100644 src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/tungstensteel_inner.png (limited to 'src') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 2f26833fb6..f42e9a5ced 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -29,6 +29,7 @@ import gregtech.common.items.behaviors.Behaviour_DataOrb; import gregtech.common.misc.GT_Command; import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Massfabricator; import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalChestBase; +import gregtech.loaders.ExtraIcons; import gregtech.loaders.load.GT_CoverBehaviorLoader; import gregtech.loaders.load.GT_FuelLoader; import gregtech.loaders.load.GT_ItemIterator; @@ -53,6 +54,7 @@ import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -177,6 +179,10 @@ public class GT_Mod implements IGT_Mod { } } + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { + MinecraftForge.EVENT_BUS.register(new ExtraIcons()); + } + File tFile = new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg"); Configuration tMainConfig = new Configuration(tFile); tMainConfig.load(); diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 64bda0f170..862985faca 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -2026,11 +2026,11 @@ public enum ItemList implements IItemContainer { } if (tCamelCasedDisplayNameBuilder.length() == 0) { // CamelCased DisplayName is empty, so use hash of aDisplayName - tCamelCasedDisplayNameBuilder.append(((Long) (long)aDisplayName.hashCode()).toString()); + tCamelCasedDisplayNameBuilder.append(((Long) (long) aDisplayName.hashCode())); } // Construct a translation key from UnlocalizedName and CamelCased DisplayName - final String tKey = rStack.getUnlocalizedName() + ".with." + tCamelCasedDisplayNameBuilder.toString() + ".name"; + final String tKey = rStack.getUnlocalizedName() + ".with." + tCamelCasedDisplayNameBuilder + ".name"; rStack.setStackDisplayName(GT_LanguageManager.addStringLocalization(tKey, aDisplayName)); return GT_Utility.copyAmount(aAmount, rStack); @@ -2071,4 +2071,13 @@ public enum ItemList implements IItemContainer { GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); return this; } + + /** + * Returns the internal stack. + * This method is unsafe. It's here only for quick operations. + * DON'T CHANGE THE RETURNED VALUE! + */ + public ItemStack getInternalStack_unsafe() { + return mStack; + } } diff --git a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java index f40443096e..54eafccc3a 100644 --- a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java +++ b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java @@ -1,8 +1,10 @@ package gregtech.common.render; +import gregtech.api.enums.ItemList; import gregtech.api.interfaces.IIconContainer; import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.util.GT_Utility; +import gregtech.loaders.ExtraIcons; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -15,6 +17,10 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; +import javax.annotation.Nullable; + +import static gregtech.api.enums.ItemList.*; + public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { public GT_MetaGenerated_Item_Renderer() { for (GT_MetaGenerated_Item item : GT_MetaGenerated_Item.sInstances.values()) { @@ -137,6 +143,12 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { } else { tIcon = aItem.mIconList[(aMetaData - aItem.mOffset)][0]; } + + ItemList largeFluidCell = getLargeFluidCell(aStack); + if (largeFluidCell != null) { + renderLargeFluidCellExtraParts(type, largeFluidCell, aStack); + } + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { @@ -147,4 +159,68 @@ public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { } GL11.glDisable(GL11.GL_BLEND); } + + @Nullable + private static ItemList getLargeFluidCell(ItemStack stack) { + if (isSame(Large_Fluid_Cell_Steel, stack)) return Large_Fluid_Cell_Steel; + if (isSame(Large_Fluid_Cell_Aluminium, stack)) return Large_Fluid_Cell_Aluminium; + if (isSame(Large_Fluid_Cell_TungstenSteel, stack)) return Large_Fluid_Cell_TungstenSteel; + if (isSame(Large_Fluid_Cell_StainlessSteel, stack)) return Large_Fluid_Cell_StainlessSteel; + if (isSame(Large_Fluid_Cell_Titanium, stack)) return Large_Fluid_Cell_Titanium; + if (isSame(Large_Fluid_Cell_Chrome, stack)) return Large_Fluid_Cell_Chrome; + if (isSame(Large_Fluid_Cell_Iridium, stack)) return Large_Fluid_Cell_Iridium; + if (isSame(Large_Fluid_Cell_Osmium, stack)) return Large_Fluid_Cell_Osmium; + if (isSame(Large_Fluid_Cell_Neutronium, stack)) return Large_Fluid_Cell_Neutronium; + + return null; + } + + private static void renderLargeFluidCellExtraParts(IItemRenderer.ItemRenderType type, ItemList item, ItemStack stack) { + + IIcon inner; + if (item == Large_Fluid_Cell_Steel) inner = ExtraIcons.steelLargeCellInner; + else if (item == Large_Fluid_Cell_Aluminium) inner = ExtraIcons.aluminiumLargeCellInner; + else if (item == Large_Fluid_Cell_StainlessSteel) inner = ExtraIcons.stainlesssteelLargeCellInner; + else if (item == Large_Fluid_Cell_Titanium) inner = ExtraIcons.titaniumLargeCellInner; + else if (item == Large_Fluid_Cell_TungstenSteel) inner = ExtraIcons.tungstensteelLargeCellInner; + else if (item == Large_Fluid_Cell_Iridium) inner = ExtraIcons.iridiumLargeCellInner; + else if (item == Large_Fluid_Cell_Osmium) inner = ExtraIcons.osmiumLargeCellInner; + else if (item == Large_Fluid_Cell_Chrome) inner = ExtraIcons.chromiumLargeCellInner; + else inner = ExtraIcons.neutroniumLargeCellInner; + + // Empty inner side + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + if (type.equals(ItemRenderType.INVENTORY)) { + GT_RenderUtil.renderItemIcon(inner, 16.0D, -0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D(Tessellator.instance, inner.getMaxU(), inner.getMinV(), inner.getMinU(), inner.getMaxV(), inner.getIconWidth(), inner.getIconHeight(), 0.0625F); + } + + FluidStack fluidStack = GT_Utility.getFluidForFilledItem(stack, true); + + if (fluidStack != null && fluidStack.getFluid() != null) { + IIcon fluidIcon = fluidStack.getFluid().getIcon(fluidStack); + int fluidColor = fluidStack.getFluid().getColor(fluidStack); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); + if (type.equals(ItemRenderType.INVENTORY)) { + GT_RenderUtil.renderItemIcon(fluidIcon, 16.0D, -0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D(Tessellator.instance, fluidIcon.getMaxU(), fluidIcon.getMinV(), fluidIcon.getMinU(), fluidIcon.getMaxV(), fluidIcon.getIconWidth(), fluidIcon.getIconHeight(), 0.0625F); + } + + GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + private static boolean isSame(ItemList item, ItemStack stack) { + ItemStack internal = item.getInternalStack_unsafe(); + if (GT_Utility.isStackInvalid(internal)) return false; + + return internal.getItem() == stack.getItem() && internal.getItemDamage() == stack.getItemDamage(); + } } diff --git a/src/main/java/gregtech/loaders/ExtraIcons.java b/src/main/java/gregtech/loaders/ExtraIcons.java new file mode 100644 index 0000000000..ec50a7c3e2 --- /dev/null +++ b/src/main/java/gregtech/loaders/ExtraIcons.java @@ -0,0 +1,36 @@ +package gregtech.loaders; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.event.TextureStitchEvent; + +import static gregtech.api.enums.GT_Values.RES_PATH_ITEM; + +public class ExtraIcons { + public static IIcon steelLargeCellInner; + public static IIcon aluminiumLargeCellInner; + public static IIcon stainlesssteelLargeCellInner; + public static IIcon tungstensteelLargeCellInner; + public static IIcon titaniumLargeCellInner; + public static IIcon chromiumLargeCellInner; + public static IIcon iridiumLargeCellInner; + public static IIcon osmiumLargeCellInner; + public static IIcon neutroniumLargeCellInner; + + @SubscribeEvent + public void regIcons(TextureStitchEvent.Pre event) { + TextureMap reg = event.map; + if (reg.getTextureType() == 1) {// are for items + steelLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/steel_inner"); + aluminiumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/aluminium_inner"); + stainlesssteelLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/stainlesssteel_inner"); + tungstensteelLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/tungstensteel_inner"); + titaniumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/titanium_inner"); + chromiumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/chromium_inner"); + iridiumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/iridium_inner"); + osmiumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/osmium_inner"); + neutroniumLargeCellInner = reg.registerIcon(RES_PATH_ITEM + "large_fluid_cell_custom/neutronium_inner"); + } + } +} diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/405.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/405.png index 00bfc9bc71..a4e07eae7b 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/405.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/405.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/406.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/406.png index 3c075135dd..5f82638932 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/406.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/406.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/407.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/407.png index 6d2a21cf93..40293ded93 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/407.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/407.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/408.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/408.png index 86ae8dd7e2..6ac9d00433 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/408.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/408.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/409.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/409.png index 3131758123..ea82375e52 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/409.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/409.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/410.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/410.png index 0a9d1f880d..70671e9fd4 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/410.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/410.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/411.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/411.png index 61f7255c52..9657000840 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/411.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/411.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/412.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/412.png index 5cba994104..32fca14289 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/412.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/412.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/413.png b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/413.png index 80cd9711cd..ae4bbb7282 100644 Binary files a/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/413.png and b/src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/413.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/aluminium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/aluminium_inner.png new file mode 100644 index 0000000000..dbc4fab348 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/aluminium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/chromium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/chromium_inner.png new file mode 100644 index 0000000000..0d74ef13f9 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/chromium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/iridium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/iridium_inner.png new file mode 100644 index 0000000000..d1862a3062 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/iridium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/neutronium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/neutronium_inner.png new file mode 100644 index 0000000000..4373928eb1 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/neutronium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/osmium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/osmium_inner.png new file mode 100644 index 0000000000..d2a55cfb09 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/osmium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/stainlesssteel_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/stainlesssteel_inner.png new file mode 100644 index 0000000000..817ddd36e8 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/stainlesssteel_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/steel_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/steel_inner.png new file mode 100644 index 0000000000..58d8099c55 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/steel_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/titanium_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/titanium_inner.png new file mode 100644 index 0000000000..ae66699b8c Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/titanium_inner.png differ diff --git a/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/tungstensteel_inner.png b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/tungstensteel_inner.png new file mode 100644 index 0000000000..40f47df0af Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/items/large_fluid_cell_custom/tungstensteel_inner.png differ -- cgit From bddb7a81cc3a8da321dcbd58b3247ceb9cbdf1e2 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Wed, 11 Aug 2021 23:42:52 -0600 Subject: Update bee mutations to handle modified climate --- build.properties | 2 +- src/main/java/gregtech/common/bees/GT_Bee_Mutation.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/build.properties b/build.properties index 407cf4ff61..533532927a 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.07 +gt.version=5.09.37.08 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java index b088f724f5..a4a162ddae 100644 --- a/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java +++ b/src/main/java/gregtech/common/bees/GT_Bee_Mutation.java @@ -1,6 +1,7 @@ package gregtech.common.bees; import forestry.api.apiculture.*; +import forestry.api.core.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; @@ -37,7 +38,7 @@ public class GT_Bee_Mutation extends BeeMutation { int y = housingCoordinates != null ? housingCoordinates.posY : 0; int z = housingCoordinates != null ? housingCoordinates.posZ : 0; - float processedChance = getBasicChance(world, x, y, z, allele0, allele1, genome0, genome1); + float processedChance = getBasicChance(world, x, y, z, allele0, allele1, genome0, genome1, housing); if (processedChance <= 0f) { return 0f; @@ -53,7 +54,7 @@ public class GT_Bee_Mutation extends BeeMutation { } @SuppressWarnings("unchecked") - private float getBasicChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { + private float getBasicChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) { float mutationChance = this.getBaseChance(); List mutationConditions = null; Field f = FieldUtils.getDeclaredField(Mutation.class, "mutationConditions", true); @@ -69,7 +70,7 @@ public class GT_Bee_Mutation extends BeeMutation { if (mutationConditions != null) for (IMutationCondition mutationCondition : mutationConditions) { - mutationChance *= mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1); + mutationChance *= mutationCondition.getChance(world, x, y, z, allele0, allele1, genome0, genome1, climate); if (mutationChance == 0) { return 0; } -- cgit From c3d45e1c7d595c40b3647ed743633fd30126142d Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:16:41 -0600 Subject: Fix some overlooked overrides --- src/main/java/gregtech/loaders/misc/GT_Bees.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/misc/GT_Bees.java b/src/main/java/gregtech/loaders/misc/GT_Bees.java index 0e08ac3de6..a6b8399cb6 100644 --- a/src/main/java/gregtech/loaders/misc/GT_Bees.java +++ b/src/main/java/gregtech/loaders/misc/GT_Bees.java @@ -2,6 +2,7 @@ package gregtech.loaders.misc; import cpw.mods.fml.common.Loader; import forestry.api.apiculture.EnumBeeChromosome; +import forestry.api.core.IClimateProvider; import forestry.api.genetics.*; import forestry.core.genetics.alleles.Allele; import forestry.core.utils.StringUtil; @@ -133,7 +134,7 @@ public class GT_Bees { } @Override - public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,IGenome genome1) { + public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) { if(world.provider.dimensionId == dimID)return 1; return 0; } @@ -156,8 +157,8 @@ public class GT_Bees { } @Override - public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,IGenome genome1) { - if(world.getBiomeGenForCoords(x, z).biomeID == biomeID) return 1; + public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,IGenome genome1, IClimateProvider climate) { + if(climate.getBiome().biomeID == biomeID) return 1; return 0; } -- cgit From 3ade6e9c5669fc03edb83b8ac28d73a86da9d3c7 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:33:58 -0600 Subject: Add a space --- src/main/java/gregtech/loaders/misc/GT_Bees.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/loaders/misc/GT_Bees.java b/src/main/java/gregtech/loaders/misc/GT_Bees.java index a6b8399cb6..1d8441e4d6 100644 --- a/src/main/java/gregtech/loaders/misc/GT_Bees.java +++ b/src/main/java/gregtech/loaders/misc/GT_Bees.java @@ -157,7 +157,7 @@ public class GT_Bees { } @Override - public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,IGenome genome1, IClimateProvider climate) { + public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) { if(climate.getBiome().biomeID == biomeID) return 1; return 0; } -- cgit From 2490781f3693c6b177c845c2e8ced94b492f8498 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 15 Aug 2021 14:46:49 -0600 Subject: Add number formatting for recipe special value --- src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java | 2 +- src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index 513b0b7552..e1ec4c6459 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -256,7 +256,7 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { } else if (tSpecial == -201) { drawText(10, 123, trans("206","Scan for Assembly Line"), -16777216); } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { - drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } else { int i = 0; diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index f8aa9a015e..a483e27fc0 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -247,7 +247,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { } else if (tSpecial == -400) { drawText(10, 123, trans("216","Deprecated Recipe"), -16777216); } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { - drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 123,this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } else { int i = 0; -- cgit From 4f4d4e2d97cd1c6e238cab466dbdf0e1170287a9 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sun, 15 Aug 2021 14:54:36 -0600 Subject: Fix accidentally deleted space --- src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index a483e27fc0..0e77a2c08d 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -247,7 +247,7 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { } else if (tSpecial == -400) { drawText(10, 123, trans("216","Deprecated Recipe"), -16777216); } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { - drawText(10, 123,this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } else { int i = 0; -- cgit From b05f1651f62eb87823f4ed9fe5143931b48150d9 Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Mon, 16 Aug 2021 02:34:35 +0300 Subject: Removed useless concurrency for some maps --- .../gregtech/api/items/GT_MetaGenerated_Tool.java | 3 ++- .../implementations/GT_MetaPipeEntity_Item.java | 4 +-- .../java/gregtech/api/objects/CollectorUtils.java | 29 ++++++++++++++++++++++ src/main/java/gregtech/api/util/GT_Utility.java | 12 +++------ .../items/behaviors/Behaviour_Plunger_Item.java | 4 +-- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 src/main/java/gregtech/api/objects/CollectorUtils.java (limited to 'src') diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 65e9dfcc39..82f19351a5 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -47,6 +47,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.world.BlockEvent; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; @@ -645,7 +646,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements return false; } Materials aMaterial = getPrimaryMaterial(aStack); - ConcurrentHashMap tMap = new ConcurrentHashMap(), tResult = new ConcurrentHashMap(); + HashMap tMap = new HashMap<>(), tResult = new HashMap<>(); if (aMaterial.mEnchantmentTools != null) { tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); if (aMaterial.mEnchantmentTools == Enchantment.fortune) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index a4cc0e407e..edec79fe65 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -29,8 +29,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.Textures.BlockIcons.PIPE_RESTRICTOR; @@ -174,7 +174,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) { temp = false; tPipeList.clear(); - for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new ConcurrentHashMap(), 0, false, false)).keySet()) { + for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<>(), 0, false, false)).keySet()) { if (temp) break; tPipeList.add(tTileEntity); while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) diff --git a/src/main/java/gregtech/api/objects/CollectorUtils.java b/src/main/java/gregtech/api/objects/CollectorUtils.java new file mode 100644 index 0000000000..3f89ad0773 --- /dev/null +++ b/src/main/java/gregtech/api/objects/CollectorUtils.java @@ -0,0 +1,29 @@ +package gregtech.api.objects; + +import java.util.Map; +import java.util.function.BiFunction; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collector; +import java.util.stream.Collectors; + +public class CollectorUtils { + /** + * Returns a merge function, suitable for use in + * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or + * {@link Collectors#toMap(Function, Function, BinaryOperator) toMap()}, which always + * throws {@code IllegalStateException}. This can be used to enforce the + * assumption that the elements being collected are distinct. + * + * @param the type of input arguments to the merge function + * @return a merge function which always throw {@code IllegalStateException} + */ + public static BinaryOperator throwingMerger() { + return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; + } + + public static , M extends Map> Collector entriesToMap(Supplier mapSupplier) { + return Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, CollectorUtils.throwingMerger(), mapSupplier); + } +} diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 17606b85a4..be5f978d6e 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -22,6 +22,7 @@ import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.net.GT_Packet_Sound; +import gregtech.api.objects.CollectorUtils; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; @@ -1752,15 +1753,8 @@ public class GT_Utility { return aMap; } - /** - * Why the fuck do neither Java nor Guava have a Function to do this? - */ - public static LinkedHashMap sortMapByValuesAcending(Map aMap) { - List> tEntrySet = new LinkedList<>(aMap.entrySet()); - tEntrySet.sort(Entry.comparingByValue()); - LinkedHashMap rMap = new LinkedHashMap<>(); - for (Map.Entry tEntry : tEntrySet) rMap.put(tEntry.getKey(), tEntry.getValue()); - return rMap; + public static > LinkedHashMap sortMapByValuesAcending(Map map) { + return map.entrySet().stream().sorted(Entry.comparingByValue()).collect(CollectorUtils.entriesToMap(LinkedHashMap::new)); } /** diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java index 43a95fd2c7..ddb88b80c8 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java @@ -14,8 +14,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; public class Behaviour_Plunger_Item extends Behaviour_None { private final int mCosts; @@ -34,7 +34,7 @@ public class Behaviour_Plunger_Item extends Behaviour_None { if ((aTileEntity instanceof IGregTechTileEntity)) { IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); if ((tMetaTileEntity instanceof IMetaTileEntityItemPipe)) { - for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, new ConcurrentHashMap(), 0L, false, true)).keySet()) + for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, new HashMap<>(), 0L, false, true)).keySet()) { int i = 0; -- cgit