diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e18bc253b..37f853b1c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index 39d96f7e3..42601a0f9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.33' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.36' } diff --git a/src/main/java/forestry/api/core/IClimateControlled.java b/src/main/java/forestry/api/core/IClimateControlled.java index 0ae4ae6d1..f19fd93ca 100644 --- a/src/main/java/forestry/api/core/IClimateControlled.java +++ b/src/main/java/forestry/api/core/IClimateControlled.java @@ -12,11 +12,15 @@ public interface IClimateControlled { /** * Change the temperature, but not lower than boundaryDown or higher than boundaryUp. + * + * When used in an alveary the change applies a 20x stronger effect */ void addTemperatureChange(float change, float boundaryDown, float boundaryUp); /** * Change the humidity, but not lower than boundaryDown or higher than boundaryUp. + * + * When used in an alveary the change applies a 20x stronger effect */ void addHumidityChange(float change, float boundaryDown, float boundaryUp); } diff --git a/src/main/java/forestry/api/multiblock/IAlvearyComponent.java b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java index 13a904caa..a21d8d502 100644 --- a/src/main/java/forestry/api/multiblock/IAlvearyComponent.java +++ b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java @@ -49,6 +49,14 @@ public interface IAlvearyComponent extends IM * @param alveary the climate controlled alveary */ void changeClimate(int tickCount, IClimateControlled alveary); + + /** + * Get the priority of this climatiser. Called when alveary is constructed. + * {@link #changeClimate(int, IClimateControlled)} are run in descending priority. + */ + default int getPriority() { + return 0; + } } /** diff --git a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java index cfbfcb066..2057d45bc 100644 --- a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java +++ b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java @@ -9,8 +9,10 @@ package forestry.apiculture.multiblock; import java.io.IOException; +import java.util.Comparator; import java.util.HashSet; import java.util.Set; +import java.util.TreeSet; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; @@ -59,7 +61,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase // PARTS private final Set beeModifiers = new HashSet<>(); private final Set beeListeners = new HashSet<>(); - private final Set climatisers = new HashSet<>(); + private final Set climatisers = new TreeSet<>( + Comparator.comparingInt(IAlvearyComponent.Climatiser::getPriority).thenComparingInt(Object::hashCode) + .reversed()); private final Set activeComponents = new HashSet<>(); // CLIENT @@ -233,26 +237,24 @@ public class AlvearyController extends RectangularMultiblockControllerBase beekeepingLogic.doWork(); } + tempChange = 0; + humidChange = 0; for (IAlvearyComponent.Climatiser climatiser : climatisers) { climatiser.changeClimate(tickCount, this); } - tempChange = equalizeChange(tempChange); - humidChange = equalizeChange(humidChange); - return canWork; } - private static float equalizeChange(float change) { - if (change == 0) { - return 0; + private float applyChange(float base, float currentChange, float extraChange, float boundaryDown, + float boundaryUp) { + float boundedNewChange = Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp)) + - base; + if (extraChange > 0) { + return Math.max(currentChange, boundedNewChange); + } else { + return Math.min(currentChange, boundedNewChange); } - - change *= 0.95f; - if (change <= 0.001f && change >= -0.001f) { - change = 0; - } - return change; } @Override @@ -410,19 +412,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase ChunkCoordinates coordinates = getCoordinates(); float temperature = getBiome().getFloatTemperature(coordinates.posX, coordinates.posY, coordinates.posZ); - - tempChange += change; - tempChange = Math.max(boundaryDown - temperature, tempChange); - tempChange = Math.min(boundaryUp - temperature, tempChange); + tempChange = applyChange(temperature, tempChange, change, boundaryDown, boundaryUp); } @Override public void addHumidityChange(float change, float boundaryDown, float boundaryUp) { float humidity = getBiome().rainfall; - - humidChange += change; - humidChange = Math.max(boundaryDown - humidity, humidChange); - humidChange = Math.min(boundaryUp - humidity, humidChange); + humidChange = applyChange(humidity, humidChange, change, boundaryDown, boundaryUp); } /* GUI */ diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java index fb562a8a9..02a577929 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java @@ -56,9 +56,9 @@ public class TileAlvearyHygroregulator extends TileAlveary this.tankManager = new TankManager(this, liquidTank); this.recipes = new HygroregulatorRecipe[] { - new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.0005f), - new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.0005f), - new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.001f) }; + new HygroregulatorRecipe(new FluidStack(water, 1), 1, +0.01f, -0.005f), + new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f), + new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, +0.02f, -0.01f) }; } @Override @@ -111,6 +111,11 @@ public class TileAlvearyHygroregulator extends TileAlveary } } + @Override + public int getPriority() { + return 100; + } + /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) {