From b3ff057195ffa51b5221b22f2d06b0db4973ab47 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:50:49 +0100 Subject: [PATCH] Implement Simple Difficulty altitude modifier tweak --- README.md | 1 + .../universaltweaks/config/UTConfigMods.java | 15 +++++++++++ .../mixin/UTModifierAltitudeMixin.java | 27 +++++++++++++++++++ .../mixins.mods.simpledifficulty.json | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/simpledifficulty/mixin/UTModifierAltitudeMixin.java diff --git a/README.md b/README.md index cee8202c..89220e5c 100644 --- a/README.md +++ b/README.md @@ -400,6 +400,7 @@ All changes are toggleable via config files. * **Early Register CT Chickens:** Improves load time by registering ContentTweaker chickens early for Roost to detect them * **Simple Difficulty** * **Iron Canteen Interaction Fix:** Fixes the interaction of iron canteens with rain collectors + * **Altitude Modifier:** Sets additional variables for altitude modifier calculations * **Simply Jetpacks** * **Memory Leak Fix:** Fixes a client-side memory leak associated with EntityPlayer * **Spice Of Life** diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index c7e340fe..b0319a35 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -854,6 +854,21 @@ public static class SimpleDifficultyCategory @Config.Name("Iron Canteen Interaction Fix") @Config.Comment("Fixes the interaction of iron canteens with rain collectors") public boolean utRainCollectorCanteenToggle = true; + + @Config.RequiresMcRestart + @Config.Name("Altitude Modifier: Sea Level") + @Config.Comment("Sets the sea level for altitude modifier calculations") + public int utAltitudeSeaLevel = 64; + + @Config.RequiresMcRestart + @Config.Name("Altitude Modifier: Above Sea Level Multiplier") + @Config.Comment("Sets the multiplier above sea level for altitude modifier calculations") + public double utAltitudeMultiplierAboveSeaLevel = 1.0D; + + @Config.RequiresMcRestart + @Config.Name("Altitude Modifier: Below Sea Level Multiplier") + @Config.Comment("Sets the multiplier below sea level for altitude modifier calculations") + public double utAltitudeMultiplierBelowSeaLevel = 1.0D; } public static class SimplyJetpacksCategory diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/simpledifficulty/mixin/UTModifierAltitudeMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/simpledifficulty/mixin/UTModifierAltitudeMixin.java new file mode 100644 index 00000000..1b0a9557 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/simpledifficulty/mixin/UTModifierAltitudeMixin.java @@ -0,0 +1,27 @@ +package mod.acgaming.universaltweaks.mods.simpledifficulty.mixin; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import com.charles445.simpledifficulty.config.ModConfig; +import com.charles445.simpledifficulty.temperature.ModifierAltitude; +import mod.acgaming.universaltweaks.config.UTConfigMods; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = ModifierAltitude.class, remap = false) +public class UTModifierAltitudeMixin +{ + @Inject(method = "getWorldInfluence", at = @At(value = "RETURN"), cancellable = true) + public void utModifierAltitude(World world, BlockPos pos, CallbackInfoReturnable cir) + { + if (!world.provider.isSurfaceWorld()) cir.setReturnValue(0.0F); + + float seaLevel = UTConfigMods.SIMPLE_DIFFICULTY.utAltitudeSeaLevel; + float multiplier = pos.getY() > seaLevel ? (float) UTConfigMods.SIMPLE_DIFFICULTY.utAltitudeMultiplierAboveSeaLevel : (float) UTConfigMods.SIMPLE_DIFFICULTY.utAltitudeMultiplierBelowSeaLevel; + + cir.setReturnValue(-1.0F * (Math.abs(((seaLevel - pos.getY()) / seaLevel * ModConfig.server.temperature.altitudeMultiplier * multiplier) + 1.0F))); + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.mods.simpledifficulty.json b/src/main/resources/mixins.mods.simpledifficulty.json index 63cdfa8c..16e356b9 100644 --- a/src/main/resources/mixins.mods.simpledifficulty.json +++ b/src/main/resources/mixins.mods.simpledifficulty.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTRainCollectorCanteenMixin"] + "mixins": ["UTModifierAltitudeMixin", "UTRainCollectorCanteenMixin"] } \ No newline at end of file