Skip to content

Commit

Permalink
Implement Simple Difficulty altitude modifier tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Nov 22, 2024
1 parent 3bb977e commit b3ff057
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Float> 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)));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.mods.simpledifficulty.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTRainCollectorCanteenMixin"]
"mixins": ["UTModifierAltitudeMixin", "UTRainCollectorCanteenMixin"]
}

0 comments on commit b3ff057

Please sign in to comment.