From 4d6dd17d60bc1e892fa8d2ca3bd562fb05049558 Mon Sep 17 00:00:00 2001 From: boubou_19 Date: Tue, 23 Nov 2021 23:25:14 +0100 Subject: centralized pollution for GT multies --- src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java | 2 +- src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java | 2 +- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 2 +- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index a24c4acbcd..e1f3c3f0e0 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -73,7 +73,7 @@ public class NodeEnergyReceiver extends ConsumerNode { tWorld.setBlock(tX, tY, tZ, Blocks.air); if (GregTech_API.sMachineExplosions) if (GT_Mod.gregtechproxy.mPollution) - GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), 100000); + GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), GT_Mod.gregtechproxy.mPollutionOnExplosion); new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() .setStrength(tStrength) diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 24d0576864..30a5230168 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -113,7 +113,7 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd tWorld.setBlock(tX, tY, tZ, Blocks.air); if (GregTech_API.sMachineExplosions) if (GT_Mod.gregtechproxy.mPollution) - GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), 100000); + GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), GT_Mod.gregtechproxy.mPollutionOnExplosion); new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() .setStrength(tStrength) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9176d063ce..a0a5e75b54 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1403,7 +1403,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } - GT_Pollution.addPollution(this, 100000); + GT_Pollution.addPollution(this, GT_Mod.gregtechproxy.mPollutionOnExplosion); mMetaTileEntity.doExplosion(aAmount); } } 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 6369c48f8e..b2100e7fd0 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 @@ -539,7 +539,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { GT_Log.exp.println("MultiBlockExplosion at: " +this.getBaseMetaTileEntity().getXCoord()+" | "+this.getBaseMetaTileEntity().getYCoord()+" | "+this.getBaseMetaTileEntity().getZCoord()+" DIMID: "+ this.getBaseMetaTileEntity().getWorld().provider.dimensionId+"."); - GT_Pollution.addPollution(getBaseMetaTileEntity(), 300000); + GT_Pollution.addPollution(getBaseMetaTileEntity(), GT_Mod.gregtechproxy.mPollutionOnExplosion); mInventory[1] = null; for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); -- cgit From edfa66b41faa598b3d0219df4534839e7ed88e74 Mon Sep 17 00:00:00 2001 From: boubou_19 Date: Thu, 25 Nov 2021 01:34:56 +0100 Subject: changed large boilers to use per second for more precision --- src/main/java/gregtech/GT_Mod.java | 9 +++++---- .../GT_MetaTileEntity_MultiBlockBase.java | 7 +++++++ src/main/java/gregtech/common/GT_Proxy.java | 9 +++++---- .../multi/GT_MetaTileEntity_LargeBoiler.java | 2 +- .../GT_MetaTileEntity_LargeBoiler_Bronze.java | 23 +++++++--------------- .../multi/GT_MetaTileEntity_LargeBoiler_Steel.java | 22 +++++++-------------- .../GT_MetaTileEntity_LargeBoiler_Titanium.java | 20 ++++++------------- ...T_MetaTileEntity_LargeBoiler_TungstenSteel.java | 23 +++++++--------------- 8 files changed, 45 insertions(+), 70 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index d5698b9657..82f0228d41 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -392,10 +392,11 @@ public class GT_Mod implements IGT_Mod { gregtechproxy.mPollutionLargeCombustionEngine = tMainConfig.get("Pollution", "PollutionLargeCombustionEngine",gregtechproxy.mPollutionLargeCombustionEngine).getInt(gregtechproxy.mPollutionLargeCombustionEngine); gregtechproxy.mPollutionExtremeCombustionEngine = tMainConfig.get("Pollution", "PollutionExtremeCombustionEngine",gregtechproxy.mPollutionExtremeCombustionEngine).getInt(gregtechproxy.mPollutionExtremeCombustionEngine); gregtechproxy.mPollutionImplosionCompressor = tMainConfig.get("Pollution", "PollutionImplosionCompressor", gregtechproxy.mPollutionImplosionCompressor).getInt(gregtechproxy.mPollutionImplosionCompressor); - gregtechproxy.mPollutionLargeBronzeBoiler = tMainConfig.get("Pollution", "PollutionLargeBronzeBoiler", gregtechproxy.mPollutionLargeBronzeBoiler).getInt(gregtechproxy.mPollutionLargeBronzeBoiler); - gregtechproxy.mPollutionLargeSteelBoiler = tMainConfig.get("Pollution", "PollutionLargeSteelBoiler", gregtechproxy.mPollutionLargeSteelBoiler).getInt(gregtechproxy.mPollutionLargeSteelBoiler); - gregtechproxy.mPollutionLargeTitaniumBoiler = tMainConfig.get("Pollution", "PollutionLargeTitaniumBoiler", gregtechproxy.mPollutionLargeTitaniumBoiler ).getInt(gregtechproxy.mPollutionLargeTitaniumBoiler ); - gregtechproxy.mPollutionLargeTungstenSteelBoiler = tMainConfig.get("Pollution", "PollutionLargeTungstenSteelBoiler", gregtechproxy.mPollutionLargeTungstenSteelBoiler).getInt(gregtechproxy.mPollutionLargeTungstenSteelBoiler); + gregtechproxy.mPollutionLargeBronzeBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeBronzeBoiler", gregtechproxy.mPollutionLargeBronzeBoilerPerSecond).getInt(gregtechproxy.mPollutionLargeBronzeBoilerPerSecond); + gregtechproxy.mPollutionLargeSteelBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeSteelBoiler", gregtechproxy.mPollutionLargeSteelBoilerPerSecond).getInt(gregtechproxy.mPollutionLargeSteelBoilerPerSecond); + gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeTitaniumBoiler", gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond ).getInt(gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond ); + gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond = tMainConfig.get("Pollution", "PollutionLargeTungstenSteelBoiler", gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond).getInt(gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond); + gregtechproxy.mPollutionReleasedByThrottle = tMainConfig.get("Pollution", "PollutionReleasedByThrottle", gregtechproxy.mPollutionReleasedByThrottle).getDouble(gregtechproxy.mPollutionReleasedByThrottle); gregtechproxy.mPollutionLargeGasTurbine = tMainConfig.get("Pollution", "PollutionLargeGasTurbine", gregtechproxy.mPollutionLargeGasTurbine).getInt( gregtechproxy.mPollutionLargeGasTurbine); gregtechproxy.mPollutionMultiSmelter = tMainConfig.get("Pollution", "PollutionMultiSmelter", gregtechproxy.mPollutionMultiSmelter).getInt(gregtechproxy.mPollutionMultiSmelter); gregtechproxy.mPollutionPyrolyseOven = tMainConfig.get("Pollution", "PollutionPyrolyseOven", gregtechproxy.mPollutionPyrolyseOven).getInt(gregtechproxy.mPollutionPyrolyseOven); 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 b2100e7fd0..8fe70c4f72 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 @@ -400,6 +400,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { */ public abstract int getPollutionPerTick(ItemStack aStack); + /** + * Gets the pollution produced per second by this multiblock + */ + public int getPollutionPerSecond(ItemStack aStack){ + return 20 * getPollutionPerTick(aStack); + } + /** * Gets the damage to the ItemStack, usually 0 or 1. */ diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index b39812b53f..12da46b8d7 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -195,10 +195,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public int mPollutionLargeCombustionEngine = 24; public int mPollutionExtremeCombustionEngine = 192; public int mPollutionImplosionCompressor = 500; - public int mPollutionLargeBronzeBoiler = 12; - public int mPollutionLargeSteelBoiler = 12; - public int mPollutionLargeTitaniumBoiler = 12; - public int mPollutionLargeTungstenSteelBoiler = 12; + public int mPollutionLargeBronzeBoilerPerSecond = 1000; + public int mPollutionLargeSteelBoilerPerSecond = 2000; + public int mPollutionLargeTitaniumBoilerPerSecond = 3000; + public int mPollutionLargeTungstenSteelBoilerPerSecond = 4000; + public double mPollutionReleasedByThrottle = 1.0/24.0; // divided by 24 because 24 circuit conf public int mPollutionLargeGasTurbine = 15; public int mPollutionMultiSmelter = 20; public int mPollutionPyrolyseOven = 30; 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 d5701d61a0..a73fb68962 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 @@ -90,7 +90,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_En .addInfo("Produces " + (getEUt() * 40) * (runtimeBoost(20) / 20f) + "L of Steam with 1 Coal at " + getEUt() * 40 + "L/s")//? .addInfo("A programmed circuit in the main block throttles the boiler (-1000L/s per config)") .addInfo(String.format("Diesel fuels have 1/4 efficiency - Takes %.2f seconds to heat up", 500.0 / getEfficiencyIncrease()))//? check semifluid again - .addPollutionAmount(20 * getPollutionPerTick(null)) + .addPollutionAmount(getPollutionPerSecond(null)) .addSeparator() .beginStructureBlock(3, 5, 3, false) .addController("Front bottom") diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java index 4277f306c6..1e89258ae4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java @@ -22,25 +22,16 @@ public class GT_MetaTileEntity_LargeBoiler_Bronze extends GT_MetaTileEntity_Larg } @Override - public int getPollutionPerTick(ItemStack aStack) { - + public int getPollutionPerSecond(ItemStack aStack) { int integratedCircuitConfig = getIntegratedCircuitConfig(); + return Math.max(1, (int) (GT_Mod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond/(GT_Mod.gregtechproxy.mPollutionReleasedByThrottle * integratedCircuitConfig))); + } - /** - * This is the coefficient reducing the pollution based on the throttle applied via the circuit. - * 25 is the equivalent of EU/t removed by a throttle of -1000L/s (25 EU/t * 2 L/EU * 20 ticks = 1000 L/s) - * so 25/getEUt() is the normalized quantity removed by each increment in the throttle - */ - - int integratedCircuitReduction = (1-integratedCircuitConfig*25/getEUt()); - /** - * max here to clamp it to one in case the integratedCircuitReduction goes negative to ensure 1 gibbl/t - * of pollution. - */ - return Math.max(1, GT_Mod.gregtechproxy.mPollutionLargeBronzeBoiler*integratedCircuitReduction); - + @Override + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; } - + @Override public String getCasingMaterial(){ return "Bronze"; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java index 637cdaa32d..4c08b1fff1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java @@ -22,24 +22,16 @@ public class GT_MetaTileEntity_LargeBoiler_Steel extends GT_MetaTileEntity_Large } @Override - public int getPollutionPerTick(ItemStack aStack) { - + public int getPollutionPerSecond(ItemStack aStack) { int integratedCircuitConfig = getIntegratedCircuitConfig(); + return Math.max(1, (int) (GT_Mod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond/(GT_Mod.gregtechproxy.mPollutionReleasedByThrottle * integratedCircuitConfig))); + } - /** - * This is the coefficient reducing the pollution based on the throttle applied via the circuit. - * 25 is the equivalent of EU/t removed by a throttle of -1000L/s (25 EU/t * 2 L/EU * 20 ticks = 1000 L/s) - * so 25/getEUt() is the normalized quantity removed by each increment in the throttle - */ - - int integratedCircuitReduction = (1-integratedCircuitConfig*25/getEUt()); - /** - * max here to clamp it to one in case the integratedCircuitReduction goes negative to ensure 1 gibbl/t - * of pollution. - */ - return Math.max(1, GT_Mod.gregtechproxy.mPollutionLargeSteelBoiler*integratedCircuitReduction); - + @Override + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; } + @Override public String getCasingMaterial(){ return "Steel"; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java index 45542acd9a..3a2566c82e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java @@ -22,22 +22,14 @@ public class GT_MetaTileEntity_LargeBoiler_Titanium extends GT_MetaTileEntity_La } @Override - public int getPollutionPerTick(ItemStack aStack) { - + public int getPollutionPerSecond(ItemStack aStack) { int integratedCircuitConfig = getIntegratedCircuitConfig(); + return Math.max(1, (int) (GT_Mod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond/(GT_Mod.gregtechproxy.mPollutionReleasedByThrottle * integratedCircuitConfig))); + } - /** - * This is the coefficient reducing the pollution based on the throttle applied via the circuit. - * 25 is the equivalent of EU/t removed by a throttle of -1000L/s (25 EU/t * 2 L/EU * 20 ticks = 1000 L/s) - * so 25/getEUt() is the normalized quantity removed by each increment in the throttle - */ - - int integratedCircuitReduction = (1-integratedCircuitConfig*25/getEUt()); - /** - * max here to clamp it to one in case the integratedCircuitReduction goes negative to ensure 1 gibbl/t - * of pollution. - */ - return Math.max(1, GT_Mod.gregtechproxy.mPollutionLargeTitaniumBoiler*integratedCircuitReduction); + @Override + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java index 2006ba9d99..4a1fa4d931 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java @@ -22,25 +22,16 @@ public class GT_MetaTileEntity_LargeBoiler_TungstenSteel extends GT_MetaTileEnti } @Override - public int getPollutionPerTick(ItemStack aStack) { - + public int getPollutionPerSecond(ItemStack aStack) { int integratedCircuitConfig = getIntegratedCircuitConfig(); + return Math.max(1, (int) (GT_Mod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond/(GT_Mod.gregtechproxy.mPollutionReleasedByThrottle * integratedCircuitConfig))); + } - /** - * This is the coefficient reducing the pollution based on the throttle applied via the circuit. - * 25 is the equivalent of EU/t removed by a throttle of -1000L/s (25 EU/t * 2 L/EU * 20 ticks = 1000 L/s) - * so 25/getEUt() is the normalized quantity removed by each increment in the throttle - */ - - int integratedCircuitReduction = (1-integratedCircuitConfig*25/getEUt()); - /** - * max here to clamp it to one in case the integratedCircuitReduction goes negative to ensure 1 gibbl/t - * of pollution. - */ - return Math.max(1, GT_Mod.gregtechproxy.mPollutionLargeTungstenSteelBoiler*integratedCircuitReduction); - + @Override + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; } - + @Override public String getCasingMaterial(){ return "TungstenSteel"; -- cgit From a174c85a2585dc80f0d50c6d3e909e59fb451681 Mon Sep 17 00:00:00 2001 From: boubou_19 Date: Thu, 25 Nov 2021 02:29:28 +0100 Subject: adapt base generator class to produce correct amount of pollution per sec --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') 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 bb7b795c36..b9612e1769 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 @@ -214,7 +214,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { - GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution()); + GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); mFluid.amount -= tFluidAmountToUse * tConsumed; } } @@ -229,7 +229,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution()); + GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); } } } -- cgit From 00b682a49b7f60986630710dff410ece5eeb1a81 Mon Sep 17 00:00:00 2001 From: boubou_19 Date: Thu, 25 Nov 2021 14:56:31 +0100 Subject: explain why it's divided by 2 --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/gregtech/api') 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 b9612e1769..ff8615e4c5 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 @@ -214,6 +214,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { + // divided by two because this is called every 10 ticks, not 20 GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); mFluid.amount -= tFluidAmountToUse * tConsumed; } @@ -229,6 +230,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + // divided by two because this is called every 10 ticks, not 20 GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); } } -- cgit From 82f7eae1493e09c9f7a871c39f6d2e6a7ace5e89 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Fri, 26 Nov 2021 14:33:38 +0300 Subject: fix GT_Recipe_Map_FormingPress for PA https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/8875 --- src/main/java/gregtech/api/util/GT_Recipe.java | 53 +++++++++++++++++--------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index c0ea06af07..6e12a3d36c 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1585,23 +1585,8 @@ public class GT_Recipe implements Comparable { GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); if (aInputs == null || aInputs.length < 2 || aInputs[0] == null || aInputs[1] == null || !GregTech_API.sPostloadFinished) return rRecipe; - if (rRecipe == null) { - if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[0], false, true)) { - ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[1]); - tOutput.setStackDisplayName(aInputs[0].getDisplayName()); - rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[1])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0); - rRecipe.mCanBeBuffered = false; - return rRecipe; - } - if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[1], false, true)) { - ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[0]); - tOutput.setStackDisplayName(aInputs[1].getDisplayName()); - rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0); - rRecipe.mCanBeBuffered = false; - return rRecipe; - } - return null; - } + if (rRecipe == null) + return findRenamingRecipe(aInputs); for (ItemStack aMold : aInputs) { if (ItemList.Shape_Mold_Credit.isStackEqual(aMold, false, true)) { NBTTagCompound tNBT = aMold.getTagCompound(); @@ -1617,6 +1602,40 @@ public class GT_Recipe implements Comparable { } return rRecipe; } + + private ItemStack findNameMoldIndex(ItemStack[] inputs) { + for (ItemStack stack: inputs) { + if (ItemList.Shape_Mold_Name.isStackEqual(stack, false, true)) + return stack; + } + return null; + } + + private ItemStack findStackToRename(ItemStack[] inputs, ItemStack mold) { + for (ItemStack stack: inputs) { + if (stack == mold || stack == null) + continue; + return stack; + } + return null; + } + + private GT_Recipe findRenamingRecipe(ItemStack[] inputs) { + ItemStack mold = findNameMoldIndex(inputs); + if (mold == null) + return null; + ItemStack input = findStackToRename(inputs, mold); + if (input == null) + return null; + ItemStack output = GT_Utility.copyAmount(1, input); + output.setStackDisplayName(mold.getDisplayName()); + GT_Recipe recipe = new GT_Recipe(false, + new ItemStack[]{ ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, input) }, + new ItemStack[]{ output }, + null, null, null, null, 128, 8, 0); + recipe.mCanBeBuffered = false; + return recipe; + } } /** -- cgit From d56cb909f63dcefa9f8dce6e75ad1074ccc1e872 Mon Sep 17 00:00:00 2001 From: bombcar Date: Fri, 26 Nov 2021 08:37:08 -0600 Subject: allow generators to face down --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 2 +- .../api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java | 2 +- .../machines/basic/GT_MetaTileEntity_SeismicProspector.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api') 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 bb7b795c36..fe8317be95 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 @@ -117,7 +117,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean isFacingValid(byte aSide) { - return aSide > 1; + return true; } @Override 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 7b99d78009..552d3d6587 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 @@ -16,7 +16,7 @@ import net.minecraftforge.fluids.FluidTankInfo; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

+ * * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually */ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock implements IHasFluidDisplayItem { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java index 42c8db6722..b6ff782cfb 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java @@ -95,7 +95,7 @@ public class GT_MetaTileEntity_SeismicProspector extends GT_MetaTileEntity_Basic }else if(aStack.getItem() == Ic2Items.dynamite.getItem()){ aStack.stackSize -= 4; }else if(aStack.getItem() == ItemList.Block_Powderbarrel.getItem() && aStack.getItemDamage()==ItemList.Block_Powderbarrel.get(1).getItemDamage()){ - aStack.stackSize -=8; + aStack.stackSize -= 8; }else{ aStack.stackSize -= 1; } -- cgit From 9090fc1ecc4890f8f2837447b2e0a781fb754f14 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 26 Nov 2021 23:05:38 +0800 Subject: Reduce innate outbound loss by one tier This will make LV power networks less annoying to build Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9176d063ce..2d8dd5c910 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -481,7 +481,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); + long tOutputVoltage = Math.max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1))), + tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); if (tUsableAmperage > 0) { long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); mAverageEUOutput[mAverageEUOutputIndex] += tEU; -- cgit From 9d432a42b6b7e502f8593b437fb2c110f5de8082 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 28 Nov 2021 21:52:26 +0800 Subject: Fix pollution ticking and reading Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/api/util/GT_ChunkAssociatedData.java | 2 +- src/main/java/gregtech/common/GT_Pollution.java | 73 ++++++++++++++-------- 2 files changed, 48 insertions(+), 27 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java index bd9148b516..aa779b0359 100644 --- a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java @@ -296,7 +296,7 @@ public abstract class GT_ChunkAssociatedData pollutionList = new ArrayList<>();//chunks left to process - private final List chunkData = new ArrayList<>();//link to chunk data that is saved/loaded + private List pollutionList = new ArrayList<>();//chunks left to process in this cycle + private final Set pollutedChunks = new HashSet<>();// a global list of all chunks with positive pollution private int operationsPerTick = 0;//how much chunks should be processed in each cycle private static final short cycleLen = 1200; private final World world; + private boolean blank = true; public static int mPlayerPollution; private static int POLLUTIONPACKET_MINVALUE = 1000; @@ -103,16 +108,18 @@ public class GT_Pollution { private void tickPollutionInWorld(int aTickID) {//called from method above //gen data set - if (aTickID == 0) { + if (aTickID == 0 || blank) { // make a snapshot of what to work on - // counterintuitive as it seems, but this is the fastest way java collections framework offers us. - pollutionList = new ArrayList<>(chunkData); + pollutionList = new ArrayList<>(pollutedChunks); //set operations per tick - if (pollutionList.size() > 0) operationsPerTick = (pollutionList.size() / cycleLen); - else operationsPerTick = 0;//SANity + if (pollutionList.size() > 0) + operationsPerTick = Math.max(1, pollutionList.size() / cycleLen); + else + operationsPerTick = 0; //SANity + blank = false; } - for (int chunksProcessed = 0; chunksProcessed <= operationsPerTick; chunksProcessed++) { + for (int chunksProcessed = 0; chunksProcessed < operationsPerTick; chunksProcessed++) { if (pollutionList.size() == 0) break;//no more stuff to do ChunkCoordIntPair actualPos = pollutionList.remove(pollutionList.size() - 1);//faster //get pollution @@ -120,10 +127,8 @@ public class GT_Pollution { int tPollution = currentData.getAmount(); //remove some tPollution = (int) (0.9945f * tPollution); - //tPollution -= 2000;//This does not really matter... - if (tPollution <= 0) tPollution = 0;//SANity check - else if (tPollution > 400000) {//Spread Pollution + if (tPollution > 400000) {//Spread Pollution ChunkCoordIntPair[] tNeighbors = new ChunkCoordIntPair[4];//array is faster tNeighbors[0] = (new ChunkCoordIntPair(actualPos.chunkXPos + 1, actualPos.chunkZPos)); @@ -138,7 +143,7 @@ public class GT_Pollution { tDiff = tDiff / 20; neighborPollution = GT_Utility.safeInt((long) neighborPollution + tDiff);//tNPol += tDiff; tPollution -= tDiff; - neighbor.setAmount(neighborPollution); + setChunkPollution(neighborPosition, neighborPollution); } } @@ -200,7 +205,7 @@ public class GT_Pollution { } } //Write new pollution to Hashmap !!! - currentData.setAmount(tPollution); + setChunkPollution(actualPos, tPollution); //Send new value to players nearby if (tPollution > POLLUTIONPACKET_MINVALUE) { @@ -210,6 +215,10 @@ public class GT_Pollution { } } + private void setChunkPollution(ChunkCoordIntPair coord, int pollution) { + mutatePollution(world, coord.chunkXPos, coord.chunkZPos, c -> c.setAmount(pollution), pollutedChunks); + } + private static void damageBlock(World world, int x, int y, int z, boolean sourRain) { if (world.isRemote) return; Block tBlock = world.getBlock(x, y, z); @@ -265,13 +274,33 @@ public class GT_Pollution { } } + private static GT_Pollution getPollutionManager(World world) { + return dimensionWisePollution.computeIfAbsent(world.provider.dimensionId, i -> new GT_Pollution(world)); + } + public static void addPollution(IGregTechTileEntity te, int aPollution) { - addPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(), te.getZCoord()), aPollution); + if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0) return; + mutatePollution(te.getWorld(), te.getXCoord() >> 4, te.getZCoord() >> 4, d -> d.changeAmount(aPollution), null); } public static void addPollution(Chunk ch, int aPollution) { if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0) return; - STORAGE.get(ch).changeAmount(aPollution); + mutatePollution(ch.worldObj, ch.xPosition, ch.zPosition, d -> d.changeAmount(aPollution), null); + } + + private static void mutatePollution(World world, int x, int z, Consumer mutator, @Nullable Set chunks) { + ChunkData data = STORAGE.get(world, x, z); + boolean hadPollution = data.getAmount() > 0; + mutator.accept(data); + boolean hasPollution = data.getAmount() > 0; + if (hasPollution != hadPollution) { + if (chunks == null) + chunks = getPollutionManager(world).pollutedChunks; + if (hasPollution) + chunks.add(new ChunkCoordIntPair(x, z)); + else + chunks.remove(new ChunkCoordIntPair(x, z)); + } } public static int getPollution(IGregTechTileEntity te) { @@ -341,14 +370,11 @@ public class GT_Pollution { @Override protected ChunkData readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException { ChunkData data = new ChunkData(input.readInt()); - getChunkData(world).add(new ChunkCoordIntPair(chunkX, chunkZ)); + if (data.getAmount() > 0) + getPollutionManager(world).pollutedChunks.add(new ChunkCoordIntPair(chunkX, chunkZ)); return data; } - private List getChunkData(World world) { - return dimensionWisePollution.computeIfAbsent(world.provider.dimensionId, i -> new GT_Pollution(world)).chunkData; - } - @Override protected ChunkData createElement(World world, int chunkX, int chunkZ) { return new ChunkData(); @@ -359,11 +385,6 @@ public class GT_Pollution { super.loadAll(w); } - public void set(World world, ChunkCoordIntPair coord, ChunkData data) { - set(world, coord.chunkXPos, coord.chunkZPos, data); - getChunkData(world).add(coord); - } - public boolean isCreated(World world, ChunkCoordIntPair coord) { return isCreated(world.provider.dimensionId, coord.chunkXPos, coord.chunkZPos); } @@ -377,7 +398,7 @@ public class GT_Pollution { } private ChunkData(int amount) { - this.amount = amount; + this.amount = Math.max(0, amount); } /** -- cgit From a3da11bb7c82ddec2409989314adeb3076c0157b Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Sun, 28 Nov 2021 22:52:54 +0800 Subject: remove tiny dust in ore process --- .../api/interfaces/internal/IGT_RecipeAdder.java | 4 ++++ src/main/java/gregtech/api/util/GT_ModHandler.java | 19 ++++++++++++++-- src/main/java/gregtech/common/GT_RecipeAdder.java | 26 ++++++++++++++++++++++ .../oreprocessing/ProcessingCrushedOre.java | 2 +- .../loaders/oreprocessing/ProcessingDirty.java | 4 ++-- .../loaders/oreprocessing/ProcessingDust.java | 2 +- 6 files changed, 51 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java index 2267b6c241..9d66e38060 100644 --- a/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java +++ b/src/main/java/gregtech/api/interfaces/internal/IGT_RecipeAdder.java @@ -407,6 +407,8 @@ public interface IGT_RecipeAdder { */ boolean addOreWasherRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, FluidStack aFluidInput, int aDuration, int aEUt); + boolean addOreWasherRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, FluidStack aFluidInput, int[] aChances, int aDuration, int aEUt); + /** * Adds an Implosion Compressor Recipe * @@ -488,6 +490,8 @@ public interface IGT_RecipeAdder { */ boolean addThermalCentrifugeRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, int aDuration, int aEUt); + boolean addThermalCentrifugeRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, int[] aChances, int aDuration, int aEUt); + /** * Adds an Unboxing Recipe */ diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 810a204c40..acd9a294f9 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -797,6 +797,13 @@ public class GT_ModHandler { /** * IC2-ThermalCentrifuge Recipe. Overloads old Recipes automatically */ + public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int[] aChances, int aHeat, Object... aOutput) { + if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; + RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, aChances, 500, 48); + return true; + } + public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; @@ -807,11 +814,19 @@ public class GT_ModHandler { /** * IC2-OreWasher Recipe. Overloads old Recipes automatically */ + public static boolean addOreWasherRecipe(ItemStack aInput, int[] aChances, int aWaterAmount, Object... aOutput) { + if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; + if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; + RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(aWaterAmount), aChances, 500, 16); + RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(aWaterAmount / 5), aChances, 300, 16); + return true; + } + public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(1000L), 500, 16); - RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(200L), 300, 16); + RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(aWaterAmount), 500, 16); + RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getDistilledWater(aWaterAmount / 5), 300, 16); return true; } diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index 1571ef7b46..4ba4601490 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -594,6 +594,20 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { return true; } + @Override + public boolean addOreWasherRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, FluidStack aFluidInput, int[] aChances, int aDuration, int aEUt) { + if ((aInput == null) || (aFluidInput == null) || ((aOutput1 == null) || (aOutput2 == null) || (aOutput3 == null))) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("orewasher", aInput, aDuration)) <= 0) { + return false; + } + GT_Recipe.GT_Recipe_Map.sOreWasherRecipes.addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput1, aOutput2, aOutput3}, null, aChances, new FluidStack[]{aFluidInput}, null, aDuration, aEUt, 0); + return true; + } + + + @Override public boolean addImplosionRecipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) { if ((aInput1 == null) || (aOutput1 == null)) { @@ -774,6 +788,18 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { return true; } + @Override + public boolean addThermalCentrifugeRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, int[] aChances, int aDuration, int aEUt) { + if ((aInput == null) || (aOutput1 == null)) { + return false; + } + if (!GregTech_API.sRecipeFile.get("thermalcentrifuge", aInput, true)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes.addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput1, aOutput2, aOutput3}, null, aChances, null, null, aDuration, aEUt, 0); + return true; + } + @Override public boolean addAmplifier(ItemStack aAmplifierItem, int aDuration, int aAmplifierAmountOutputted) { if ((aAmplifierItem == null) || (aAmplifierAmountOutputted <= 0)) { diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingCrushedOre.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingCrushedOre.java index fd500b258a..a7c3a524b8 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingCrushedOre.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingCrushedOre.java @@ -22,7 +22,7 @@ public class ProcessingCrushedOre implements gregtech.api.interfaces.IOreRecipeR GT_ModHandler.addPulverisationRecipe(GT_Utility.copyAmount(1L, aStack), GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial.mMacerateInto, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, GT_Utility.selectItemInList(2, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), 10, false); break; case crushedPurified: - GT_ModHandler.addThermalCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), (int) Math.min(5000L, Math.abs(aMaterial.getMass() * 20L)), GT_OreDictUnificator.get(OrePrefixes.crushedCentrifuged, aMaterial.mMacerateInto, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial.mMacerateInto, 1L), 1L), GT_OreDictUnificator.get(OrePrefixes.dustTiny, GT_Utility.selectItemInList(1, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L)); + GT_ModHandler.addThermalCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), new int[] {10000, 1111}, (int) Math.min(5000L, Math.abs(aMaterial.getMass() * 20L)), GT_OreDictUnificator.get(OrePrefixes.crushedCentrifuged, aMaterial.mMacerateInto, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial.mMacerateInto, 1L), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, GT_Utility.selectItemInList(1, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L)); ItemStack tGem = GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L); if(tGem!=null){ diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDirty.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDirty.java index ca73118d20..2682cf24a2 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDirty.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDirty.java @@ -21,8 +21,8 @@ public class ProcessingDirty implements gregtech.api.interfaces.IOreRecipeRegist public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, net.minecraft.item.ItemStack aStack) { GT_Values.RA.addForgeHammerRecipe(GT_Utility.copyAmount(1L, aStack), GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial.mMacerateInto, 1L), 10, 16); GT_ModHandler.addPulverisationRecipe(GT_Utility.copyAmount(1L, aStack), GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial.mMacerateInto, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial.mMacerateInto, 1L), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, GT_Utility.selectItemInList(0, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), 10, false); - GT_ModHandler.addOreWasherRecipe(GT_Utility.copyAmount(1L, aStack), 1000, GT_OreDictUnificator.get(aPrefix == OrePrefixes.crushed ? OrePrefixes.crushedPurified : OrePrefixes.dustPure, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dustTiny, GT_Utility.selectItemInList(0, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); - GT_ModHandler.addThermalCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), (int) Math.min(5000L, Math.abs(aMaterial.getMass() * 20L)), GT_OreDictUnificator.get(aPrefix == OrePrefixes.crushed ? OrePrefixes.crushedCentrifuged : OrePrefixes.dust, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dustTiny, GT_Utility.selectItemInList(1, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); + GT_ModHandler.addOreWasherRecipe(GT_Utility.copyAmount(1L, aStack), new int[] {10000, 1111, 10000}, 1000, GT_OreDictUnificator.get(aPrefix == OrePrefixes.crushed ? OrePrefixes.crushedPurified : OrePrefixes.dustPure, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, GT_Utility.selectItemInList(0, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); + GT_ModHandler.addThermalCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), new int[] {10000, 1111, 10000}, (int) Math.min(5000L, Math.abs(aMaterial.getMass() * 20L)), GT_OreDictUnificator.get(aPrefix == OrePrefixes.crushed ? OrePrefixes.crushedCentrifuged : OrePrefixes.dust, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, GT_Utility.selectItemInList(1, aMaterial.mMacerateInto, aMaterial.mOreByProducts), 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); if (aMaterial.contains(SubTag.WASHING_MERCURY)) GT_Values.RA.addChemicalBathRecipe(GT_Utility.copyAmount(1L, aStack), Materials.Mercury.getFluid(1000L), GT_OreDictUnificator.get(aPrefix == OrePrefixes.crushed ? OrePrefixes.crushedPurified : OrePrefixes.dustPure, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial.mMacerateInto, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDust.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDust.java index 9fa2c63970..29a89ccc65 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingDust.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingDust.java @@ -191,7 +191,7 @@ public class ProcessingDust implements gregtech.api.interfaces.IOreRecipeRegistr GT_Values.RA.addCentrifugeRecipe(GT_Utility.copyAmount(2L, aStack), 0, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial, 2L), tImpureStack, null, null, null, null, (int) Math.max(1L, aMaterial.getMass() * 16L)); } } else { - GT_Values.RA.addCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), 0, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial, 1L), tImpureStack, null, null, null, null, (int) Math.max(1L, aMaterial.getMass() * 8L)); + GT_Values.RA.addCentrifugeRecipe(GT_Utility.copyAmount(1L, aStack), null, null, null, GT_OreDictUnificator.get(OrePrefixes.dust, aMaterial, 1L), GT_OreDictUnificator.get(OrePrefixes.dust, tByProduct, GT_OreDictUnificator.get(OrePrefixes.nugget, tByProduct, 1L), 1L), null, null, null, null, new int[]{10000, 1111}, (int) Math.max(1L, aMaterial.getMass() * 8L), 5); } break; case dustSmall: -- cgit From 8494b65c5d390dd8c1035fd07534df55d1fb3ad4 Mon Sep 17 00:00:00 2001 From: boubou_19 Date: Mon, 29 Nov 2021 02:39:06 +0100 Subject: removed useless overrides --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 9 ++++++--- .../machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java | 5 ----- .../machines/multi/GT_MetaTileEntity_AssemblyLine.java | 5 ----- .../machines/multi/GT_MetaTileEntity_Charcoal_Pit.java | 5 ----- .../tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java | 5 ----- .../machines/multi/GT_MetaTileEntity_DieselEngine.java | 5 ----- .../machines/multi/GT_MetaTileEntity_DistillationTower.java | 5 ----- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 5 ----- .../machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java | 5 ----- .../machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java | 5 ----- .../machines/multi/GT_MetaTileEntity_FusionComputer.java | 5 ----- .../machines/multi/GT_MetaTileEntity_HeatExchanger.java | 5 ----- .../machines/multi/GT_MetaTileEntity_ImplosionCompressor.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeBoiler.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java | 5 ----- .../machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java | 5 ----- .../machines/multi/GT_MetaTileEntity_MultiFurnace.java | 5 ----- .../machines/multi/GT_MetaTileEntity_OilCracker.java | 5 ----- .../machines/multi/GT_MetaTileEntity_ProcessingArray.java | 5 ----- .../machines/multi/GT_MetaTileEntity_PyrolyseOven.java | 5 ----- .../machines/multi/GT_MetaTileEntity_VacuumFreezer.java | 5 ----- 24 files changed, 6 insertions(+), 118 deletions(-) (limited to 'src/main/java/gregtech/api') 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 8fe70c4f72..f7b15f2c44 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 @@ -398,13 +398,16 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { /** * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) */ - public abstract int getPollutionPerTick(ItemStack aStack); + public int getPollutionPerTick(ItemStack aStack){ + return getPollutionPerSecond(aStack)/20; + } /** - * Gets the pollution produced per second by this multiblock + * Gets the pollution produced per second by this multiblock, default to 0. Override this with + * its actual value in the code of the multiblock. */ public int getPollutionPerSecond(ItemStack aStack){ - return 20 * getPollutionPerTick(aStack); + return 0; } /** 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 2409c1660c..af6afbc4c4 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 @@ -34,11 +34,6 @@ public abstract class GT_MetaTileEntity_AbstractMultiFurnace aFluids, int aOptFlow, int aBaseEff) { if (aFluids.size() >= 1) { 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 2c803712f1..b34662e619 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 @@ -82,11 +82,6 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La return 59; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { if (looseFit) { 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 76c5533c09..b32385c1be 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 @@ -88,11 +88,6 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar return 60; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { if (aFluids.size() >= 1) { 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 356dda9183..651d9c9d09 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 @@ -85,11 +85,6 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg return 16; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - private int condenseSteam(int steam) { excessWater += steam; int water = excessWater / STEAM_PER_WATER; 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 ca334e5bd6..cd07476194 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 @@ -118,11 +118,6 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu return GT_Mod.gregtechproxy.mPollutionMultiSmelterPerSecond; } - @Override - public int getPollutionPerTick(ItemStack aStack){ - return getPollutionPerSecond(aStack)/20; - } - @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredInputs(); 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 b9ade288c1..10b94fc254 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 @@ -272,11 +272,6 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult return 10000; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - @Override public int getDamageToComponent(ItemStack aStack) { return 0; 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 a48f63c60a..44f93eb3db 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 @@ -409,11 +409,6 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu return 10000; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - @Override public int getDamageToComponent(ItemStack aStack) { return 0; 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 d60f38fdc9..18eda558a0 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 @@ -230,11 +230,6 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu return GT_Mod.gregtechproxy.mPollutionPyrolyseOvenPerSecond; } - @Override - public int getPollutionPerTick(ItemStack aStack){ - return getPollutionPerSecond(aStack)/20; - } - @Override public int getDamageToComponent(ItemStack aStack) { return 0; 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 843f2ff337..f476e78310 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 @@ -142,11 +142,6 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMult return 10000; } - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - @Override public int getDamageToComponent(ItemStack aStack) { return 0; -- cgit From 4923b13c5a5e1c7798acd6ff45d8360a78474f7b Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 30 Nov 2021 03:07:30 +0800 Subject: Bug fix pass in UO and Pollution Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/api/util/GT_ChunkAssociatedData.java | 69 ++++++++++++++-------- src/main/java/gregtech/common/GT_Pollution.java | 59 ++++++++++++++---- .../java/gregtech/common/GT_UndergroundOil.java | 32 ++++++++-- .../common/render/GT_PollutionRenderer.java | 4 ++ 4 files changed, 124 insertions(+), 40 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java index aa779b0359..184f6f1011 100644 --- a/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java +++ b/src/main/java/gregtech/api/util/GT_ChunkAssociatedData.java @@ -104,7 +104,7 @@ public abstract class GT_ChunkAssociatedData stream) { - stream.filter(r -> !r.isDirty()) + stream.filter(r -> r.isDirty()) .map(c -> (Runnable) c::save) .map(r -> CompletableFuture.runAsync(r, IO_WORKERS)) .reduce(CompletableFuture::allOf) @@ -242,7 +242,12 @@ public abstract class GT_ChunkAssociatedData world; + /** + * Be aware, this means region coord, not bottom-left chunk coord + */ private final ChunkCoordIntPair coord; - private SuperRegion(World world, int chunkX, int chunkZ) { + private SuperRegion(World world, int regionX, int regionZ) { this.world = new WeakReference<>(world); - this.coord = new ChunkCoordIntPair(chunkX, chunkZ); - backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, chunkX, chunkZ)); + this.coord = new ChunkCoordIntPair(regionX, regionZ); + backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, regionX, regionZ)); if (backingStorage.isFile()) load(); } - private SuperRegion(World world, ChunkCoordIntPair coord) { + private SuperRegion(World world, ChunkCoordIntPair regionCoord) { this.world = new WeakReference<>(world); - this.coord = coord; - backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, coord.chunkXPos, coord.chunkZPos)); + this.coord = regionCoord; + backingStorage = new File(getSaveDirectory(world), String.format("%s.%d.%d.dat", mId, regionCoord.chunkXPos, regionCoord.chunkZPos)); if (backingStorage.isFile()) load(); } @@ -308,16 +316,16 @@ public abstract class GT_ChunkAssociatedData new GT_Pollution(world)); } + /** @see #addPollution(World, int, int, int) */ public static void addPollution(IGregTechTileEntity te, int aPollution) { - if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0) return; + if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0 || te.isClientSide()) return; mutatePollution(te.getWorld(), te.getXCoord() >> 4, te.getZCoord() >> 4, d -> d.changeAmount(aPollution), null); } + /** @see #addPollution(World, int, int, int) */ public static void addPollution(Chunk ch, int aPollution) { - if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0) return; + if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0 || ch.worldObj.isRemote) return; mutatePollution(ch.worldObj, ch.xPosition, ch.zPosition, d -> d.changeAmount(aPollution), null); } + /** + * Add some pollution to given chunk. Can pass in negative to remove pollution. + * Will clamp the final pollution number to 0 if it would be changed into negative. + * + * @param w world to modify. do nothing if it's a client world + * @param chunkX chunk coordinate X, i.e. blockX >> 4 + * @param chunkZ chunk coordinate Z, i.e. blockZ >> 4 + * @param aPollution desired delta. Positive means the pollution in chunk would go higher. + */ + public static void addPollution(World w, int chunkX, int chunkZ, int aPollution) { + if (!GT_Mod.gregtechproxy.mPollution || aPollution == 0 || w.isRemote) return; + mutatePollution(w, chunkX, chunkZ, d -> d.changeAmount(aPollution), null); + } + private static void mutatePollution(World world, int x, int z, Consumer mutator, @Nullable Set chunks) { ChunkData data = STORAGE.get(world, x, z); boolean hadPollution = data.getAmount() > 0; @@ -303,14 +321,36 @@ public class GT_Pollution { } } + /** @see #getPollution(World, int, int) */ public static int getPollution(IGregTechTileEntity te) { - return getPollution(te.getWorld().getChunkFromBlockCoords(te.getXCoord(), te.getZCoord())); + return getPollution(te.getWorld(), te.getXCoord() >> 4, te.getZCoord() >> 4); } + /** @see #getPollution(World, int, int) */ public static int getPollution(Chunk ch) { + return getPollution(ch.worldObj, ch.xPosition, ch.zPosition); + } + + /** + * Get the pollution in specified chunk + * @param w world to look in. can be a client world, but that limits the knowledge to what server side send us + * @param chunkX chunk coordinate X, i.e. blockX >> 4 + * @param chunkZ chunk coordinate Z, i.e. blockZ >> 4 + * @return pollution amount. may be 0 if pollution is disabled, or if it's a client world and server did not send + * us info about this chunk + */ + public static int getPollution(World w, int chunkX, int chunkZ) { if (!GT_Mod.gregtechproxy.mPollution) return 0; - return STORAGE.get(ch).getAmount(); + if (w.isRemote) + // it really should be querying the client side stuff instead + return GT_PollutionRenderer.getKnownPollution(chunkX << 4, chunkZ << 4); + return STORAGE.get(w, chunkX, chunkZ).getAmount(); + } + + @Deprecated + public static int getPollution(ChunkCoordIntPair aCh, int aDim) { + return getPollution(DimensionManager.getWorld(aDim), aCh.chunkXPos, aCh.chunkZPos); } public static boolean hasPollution(Chunk ch) { @@ -319,12 +359,6 @@ public class GT_Pollution { return STORAGE.isCreated(ch.worldObj, ch.getChunkCoordIntPair()) && STORAGE.get(ch).getAmount() > 0; } - public static int getPollution(ChunkCoordIntPair aCh, int aDim) { - if (!GT_Mod.gregtechproxy.mPollution) - return 0; - return STORAGE.get(DimensionManager.getWorld(aDim), aCh.chunkXPos, aCh.chunkZPos).getAmount(); - } - //Add compatibility with old code @Deprecated /*Don't use it... too weird way of passing position*/ public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution) { @@ -352,7 +386,8 @@ public class GT_Pollution { @SubscribeEvent public void onWorldLoad(WorldEvent.Load e) { // super class loads everything lazily. We force it to load them all. - STORAGE.loadAll(e.world); + if (!e.world.isRemote) + STORAGE.loadAll(e.world); } } @@ -369,6 +404,8 @@ public class GT_Pollution { @Override protected ChunkData readElement(DataInput input, int version, World world, int chunkX, int chunkZ) throws IOException { + if (version != 0) + throw new IOException("Region file corrupted"); ChunkData data = new ChunkData(input.readInt()); if (data.getAmount() > 0) getPollutionManager(world).pollutedChunks.add(new ChunkCoordIntPair(chunkX, chunkZ)); diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index 21b681de4a..b725b4bbb6 100644 --- a/src/main/java/gregtech/common/GT_UndergroundOil.java +++ b/src/main/java/gregtech/common/GT_UndergroundOil.java @@ -31,22 +31,46 @@ public class GT_UndergroundOil { private static final GT_UndergroundOilStore STORAGE = new GT_UndergroundOilStore(); private static final ChunkData NIL_FLUID_STACK = new ChunkData(-1, null, null, false); + /** + * Effectively just call {@code undergroundOil(te, -1)} for you + * @see #undergroundOil(World, int, int, float) + */ public static FluidStack undergroundOilReadInformation(IGregTechTileEntity te){ return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),-1); } + /** + * Effectively just call {@code undergroundOil(chunk, -1)} for you + * @see #undergroundOil(World, int, int, float) + */ public static FluidStack undergroundOilReadInformation(Chunk chunk) { return undergroundOil(chunk,-1); } + /** @see #undergroundOil(World, int, int, float) */ public static FluidStack undergroundOil(IGregTechTileEntity te, float readOrDrainCoefficient){ return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),readOrDrainCoefficient); } //Returns whole content for information purposes -> when drainSpeedCoefficient < 0 //Else returns extracted fluidStack if amount > 0, or null otherwise + /** @see #undergroundOil(World, int, int, float) */ public static FluidStack undergroundOil(Chunk chunk, float readOrDrainCoefficient) { - ChunkData chunkData = STORAGE.get(chunk); + return undergroundOil(chunk.worldObj, chunk.xPosition, chunk.zPosition, readOrDrainCoefficient); + } + + /** + * Pump fluid or read info. + * @param w a remote World. For a WorldClient it will always tell you null + * @param chunkX chunk coordinate X, i.e. blockX >> 4 + * @param chunkZ chunk coordinate Z, i.e. blockZ >> 4 + * @param readOrDrainCoefficient how fast to pump. The higher the faster. use negative to read expected current output + * @return null if nothing here, or depleted already, or a client side world + */ + public static FluidStack undergroundOil(World w, int chunkX, int chunkZ, float readOrDrainCoefficient) { + if (w.isRemote) + return null; // troublemakers go away + ChunkData chunkData = STORAGE.get(w, chunkX, chunkZ); if (chunkData.getVein() == null || chunkData.getFluid() == null) // nothing here... return null; //do stuff on it if needed @@ -102,7 +126,7 @@ public class GT_UndergroundOil { ChunkData chunkData = STORAGE.get(e.getChunk()); Fluid fluid = chunkData.getFluid(); if (fluid != null && fluid.getID() == e.getData().getInteger("GTOILFLUID")) - chunkData.setAmount(Math.min(0, Math.min(chunkData.getAmount(), e.getData().getInteger("GTOIL")))); + chunkData.setAmount(Math.min(chunkData.getAmount(), e.getData().getInteger("GTOIL"))); } } @@ -250,7 +274,7 @@ public class GT_UndergroundOil { public void changeAmount(int delta) { if (delta != 0) dirty = true; - this.amount = Math.max(0, amount - delta); + this.amount = Math.max(amount + delta, 0); } @Nullable @@ -272,7 +296,7 @@ public class GT_UndergroundOil { @Override public boolean isSameAsDefault() { - return dirty; + return !dirty; } } } diff --git a/src/main/java/gregtech/common/render/GT_PollutionRenderer.java b/src/main/java/gregtech/common/render/GT_PollutionRenderer.java index 305eadf145..5128af1c36 100644 --- a/src/main/java/gregtech/common/render/GT_PollutionRenderer.java +++ b/src/main/java/gregtech/common/render/GT_PollutionRenderer.java @@ -101,6 +101,10 @@ public class GT_PollutionRenderer { return color(oColor, pollutionMap.getPollution(x, z)/1000, 300, 500, foliageColor); } + public static int getKnownPollution(int x, int z) { + return pollutionMap.getPollution(x, z); + } + @SubscribeEvent(priority = EventPriority.LOW) public void manipulateColor(EntityViewRenderEvent.FogColors event) { if (!DEBUG && Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) -- cgit From a07d8b58642eb9161479dcb3a285ad9979a74d2c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 30 Nov 2021 21:44:02 +0800 Subject: fix wrong Arrays being used in assline datasticks Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java index f35f1962d1..62238a8112 100644 --- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java +++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java @@ -2,6 +2,7 @@ package gregtech.api.util; import static gregtech.GT_Mod.GT_FML_LOGGER; +import java.util.Arrays; import java.util.HashMap; import cpw.mods.fml.common.FMLCommonHandler; @@ -14,7 +15,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraftforge.fluids.FluidStack; -import scala.actors.threadpool.Arrays; public class GT_AssemblyLineUtils { @@ -159,7 +159,7 @@ public class GT_AssemblyLineUtils { for (GT_Recipe_AssemblyLine aRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { if (aRecipe.mEUt == aEU && aRecipe.mDuration == aTime) { if (GT_Utility.areStacksEqual(aOutputs[0], aRecipe.mOutput, true)) { - if (Arrays.equals(aRecipe.mInputs, aInputs) && Arrays.equals(aRecipe.mFluidInputs, aFluidInputs)) { + if (Arrays.equals(aRecipe.mInputs, aInputs) && Arrays.equals(aRecipe.mFluidInputs, aFluidInputs)) { // Cache it String aRecipeHash = generateRecipeHash(aRecipe); sRecipeCacheByRecipeHash.put(aRecipeHash, aRecipe); -- cgit From 9d42b299def1c41bbc7a1f01efe445be28f54399 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 1 Dec 2021 02:52:15 +0800 Subject: Add a new ghost slot to single block machines for config circuits Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- build.properties | 2 +- src/main/java/gregtech/GT_Mod.java | 2 +- src/main/java/gregtech/api/GregTech_API.java | 51 ++++++++++++++++-- .../api/gui/GT_Container_BasicMachine.java | 60 +++++++++++++++++++--- .../gregtech/api/gui/GT_Container_BasicTank.java | 4 ++ .../api/metatileentity/BaseMetaTileEntity.java | 8 ++- .../api/metatileentity/MetaTileEntity.java | 2 + .../GT_MetaTileEntity_BasicMachine.java | 28 +++++++++- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 4 ++ .../common/items/GT_IntegratedCircuit_Item.java | 3 ++ 10 files changed, 146 insertions(+), 18 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/build.properties b/build.properties index 00228f40fb..e4e8b23ca1 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.39.01 +gt.version=5.09.40.00 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/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index d8ebca57a2..872055bcb8 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -115,7 +115,7 @@ import static gregtech.api.enums.GT_Values.MOD_ID_FR; " after:TConstruct;" + " after:Translocator;") public class GT_Mod implements IGT_Mod { - public static final int VERSION = 509, SUBVERSION = 39; + public static final int VERSION = 509, SUBVERSION = 40; public static final int TOTAL_VERSION = calculateTotalGTVersion(VERSION, SUBVERSION); public static final int REQUIRED_IC2 = 624; @Mod.Instance("gregtech") diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index ff875c4884..12fc6b6814 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -19,7 +19,15 @@ import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; import gregtech.api.threads.GT_Runnable_Cable_Update; import gregtech.api.threads.GT_Runnable_MachineBlockUpdate; -import gregtech.api.util.*; +import gregtech.api.util.GT_CircuitryBehavior; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.GT_CreativeTab; +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.world.GT_Worldgen; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -30,10 +38,19 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.B; +import static gregtech.api.enums.GT_Values.L; +import static gregtech.api.enums.GT_Values.M; +import static gregtech.api.enums.GT_Values.MOD_ID_IC2; /** * Please do not include this File in your Mod-download as it ruins compatiblity, like with the IC2-API @@ -161,6 +178,8 @@ public class GregTech_API { sHeatHazmatList = new GT_HashSet<>(), sRadioHazmatList = new GT_HashSet<>(), sElectroHazmatList = new GT_HashSet<>(); + private static final List sRealConfigurationList = new ArrayList<>(); + private static final List sConfigurationList = Collections.unmodifiableList(sRealConfigurationList); /** * The List of Dimensions, which are Whitelisted for the Teleporter. This list should not contain other Planets. * Mystcraft Dimensions and other Dimensional Things should be allowed. @@ -614,6 +633,31 @@ public class GregTech_API { } } + /** + * Register a new ItemStack as configuration circuits. + * Duplicates or invalid stacks will be silently ignored. + */ + public static void registerConfigurationCircuit(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) + return; + for (ItemStack tRegistered : sRealConfigurationList) + if (GT_Utility.areStacksEqual(tRegistered, aStack)) + return; + sRealConfigurationList.add(GT_Utility.copyAmount(0, aStack)); + } + + /** + * Get a list of Configuration circuits. All of these stacks will have a stack size of 0. + * Use {@link #registerConfigurationCircuit(ItemStack)} to add to this list. + * + * @return An unmodifiable view of actual list. + * It will reflect the changes to the underlying list as new circuits are registered. + * DO NOT MODIFY THE ItemStacks! + */ + public static List getConfigurationCircuitList() { + return sConfigurationList; + } + public static void registerCover(ItemStack aStack, ITexture aCover, GT_CoverBehavior aBehavior) { registerCover(aStack, aCover, (GT_CoverBehaviorBase) aBehavior); } @@ -812,5 +856,4 @@ public class GregTech_API { public static void setItemIconRegister(IIconRegister aIconRegister) { GregTech_API.sItemIcons = aIconRegister; } - } 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 fbae0b6752..712109b1eb 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -11,7 +11,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; + +import java.util.List; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; @@ -36,10 +37,13 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 8, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Holo(mTileEntity, 0, 26, 63, false, true, 1)); addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 107, 63)); + GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); + if (machine.allowSelectCircuit()) + addSlotToContainer(new GT_Slot_Render(mTileEntity, machine.getCircuitSlot(), 153, 63)); - int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); + int tStartIndex = machine.getInputSlot(); - switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mInputSlotCount) { + switch (machine.mInputSlotCount) { case 0: break; case 1: @@ -107,9 +111,9 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { break; } - tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getOutputSlot(); + tStartIndex = machine.getOutputSlot(); - switch (((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mOutputItems.length) { + switch (machine.mOutputItems.length) { case 0: break; case 1: @@ -182,19 +186,59 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { addSlotToContainer(new GT_Slot_Render(mTileEntity, tStartIndex++, 53, 63)); } + private static int find(List aStacks, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) + return -1; + for (int i = 0, aStacksSize = aStacks.size(); i < aStacksSize; i++) { + ItemStack tStack = aStacks.get(i); + if (GT_Utility.areStacksEqual(aStack, tStack)) + return i; + } + return -1; + } + @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (mTileEntity.getMetaTileEntity() == null) return null; GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); if (machine == null) return null; ItemStack tResultStack; + System.out.printf("shift %d, index %d, mouse %d, client? %b\n", aShifthold, aSlotIndex, aMouseclick, mTileEntity.isClientSide()); switch (aSlotIndex) { case 0: machine.mFluidTransfer = !machine.mFluidTransfer; return null; case 1: - if (mTileEntity.getMetaTileEntity() == null) return null; machine.mItemTransfer = !machine.mItemTransfer; return null; + case 3: + if (machine.allowSelectCircuit() && aMouseclick < 2) { + ItemStack newCircuit; + if (aMouseclick == 1 && aShifthold == 1) { + // clear + newCircuit = null; + } else { + ItemStack cursorStack = aPlayer.inventory.getItemStack(); + List tCircuits = machine.getConfigurationCircuits(); + int index = find(tCircuits, cursorStack); + if (index < 0) { + int curIndex = find(tCircuits, machine.getStackInSlot(machine.getCircuitSlot())) + 1; + if (aMouseclick == 0) { + curIndex += 1; + } else { + curIndex -= 1; + } + curIndex = Math.floorMod(curIndex, tCircuits.size() + 1) - 1; + newCircuit = curIndex < 0 ? null : tCircuits.get(curIndex); + } else { + // set to whatever it is + newCircuit = tCircuits.get(index); + } + } + mTileEntity.setInventorySlotContents(machine.getCircuitSlot(), newCircuit); + return newCircuit; + } + return null; default: if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length && aMouseclick < 2) { if (mTileEntity.isClientSide()) { @@ -255,12 +299,12 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { @Override public int getSlotStartIndex() { - return 3; + return 4; } @Override public int getShiftClickStartIndex() { - return 3; + return 4; } @Override 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 e8810c14c0..79d3636068 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -28,6 +28,10 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { super(aInventoryPlayer, aTileEntity); } + /** + * Subclasses must ensure third slot (aSlotIndex==2) is drainable fluid display item slot. + * Otherwise, subclasses must intercept the appropriate the slotClick event and call super.slotClick(2, xxx) if necessary + */ @Override public void addSlots(InventoryPlayer aInventoryPlayer) { addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index bd2dbcd630..f2514f1290 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -270,7 +270,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (int i = 0; i < tItemList.tagCount(); i++) { NBTTagCompound tTag = tItemList.getCompoundTagAt(i); int tSlot = tTag.getInteger("IntSlot"); - tSlot = shiftInventoryIndex(tSlot, nbtVersion); + tSlot = migrateInventoryIndex(tSlot, nbtVersion); if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); } @@ -2309,9 +2309,13 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE * @param nbtVersion The GregTech version in which the original Inventory Index was saved. * @return The corrected Inventory index */ - private int shiftInventoryIndex(int slotIndex, int nbtVersion){ + private int migrateInventoryIndex(int slotIndex, int nbtVersion){ int oldInputSize, newInputSize, oldOutputSize, newOutputSize; int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31); + int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40); + // 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4) + slotIndex += 1; if (mID >= 211 && mID <= 218) {//Assembler if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 2; diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index b3c25ff345..3c499aea53 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -5,6 +5,8 @@ import appeng.me.helpers.AENetworkProxy; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gnu.trove.list.TIntList; +import gnu.trove.list.array.TIntArrayList; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; 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 e8cac808dd..8f77b6ac5a 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 @@ -31,6 +31,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import java.util.Arrays; +import java.util.List; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; @@ -53,7 +54,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B DID_NOT_FIND_RECIPE = 0, FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - public static final int OTHER_SLOT_COUNT = 4; + public static final int OTHER_SLOT_COUNT = 5; public final ItemStack[] mOutputItems; public final int mInputSlotCount, mAmperage; public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; @@ -694,8 +695,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + int tRealInputSlotCount = this.mInputSlotCount + (allowSelectCircuit() ? 1 : 0); + ItemStack[] rInputs = new ItemStack[tRealInputSlotCount]; for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + if (allowSelectCircuit()) + rInputs[mInputSlotCount] = getStackInSlot(getCircuitSlot()); return rInputs; } @@ -850,6 +854,26 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return mInventory[aIndex] == null; } + public boolean allowSelectCircuit() { + return false; + } + + /** + * This might be non-final in the future, but for now, no, don't change this. + */ + public final int getCircuitSlot() { + return 4; + } + + /** + * Return a list of possible configuration circuit this machine expects. + * + * This list is unmodifiable. Its elements are not supposed to be modified in any way! + */ + public List getConfigurationCircuits() { + return GregTech_API.getConfigurationCircuitList(); + } + /** * @return the Recipe List which is used for this Machine, this is a useful Default Handler */ diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index 281d0f6541..7cd9fe65e1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -813,6 +813,10 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } } + @Override + public boolean allowSelectCircuit() { + return true; + } @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { diff --git a/src/main/java/gregtech/common/items/GT_IntegratedCircuit_Item.java b/src/main/java/gregtech/common/items/GT_IntegratedCircuit_Item.java index 9cbdb2b832..4b7d294a25 100644 --- a/src/main/java/gregtech/common/items/GT_IntegratedCircuit_Item.java +++ b/src/main/java/gregtech/common/items/GT_IntegratedCircuit_Item.java @@ -33,6 +33,9 @@ public class GT_IntegratedCircuit_Item extends GT_Generic_Item { ItemList.Circuit_Integrated.set(this); + for (int i = 1; i <= 24; i++) { + GregTech_API.registerConfigurationCircuit(new ItemStack(this, 0, i)); + } GT_ModHandler.addShapelessCraftingRecipe(ItemList.Circuit_Integrated.getWithDamage(1L, 0L, new Object[0]), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{OrePrefixes.circuit.get(Materials.Basic)}); long bits = GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE; -- cgit From 9082224a9e98b7c6149da5bc6f33ecbeae0403f3 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 1 Dec 2021 03:16:41 +0800 Subject: Remove debug message Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/gregtech/api') 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 712109b1eb..3c1d35c771 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -203,7 +203,6 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { GT_MetaTileEntity_BasicMachine machine = (GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity(); if (machine == null) return null; ItemStack tResultStack; - System.out.printf("shift %d, index %d, mouse %d, client? %b\n", aShifthold, aSlotIndex, aMouseclick, mTileEntity.isClientSide()); switch (aSlotIndex) { case 0: machine.mFluidTransfer = !machine.mFluidTransfer; -- cgit