Skip to content

Commit

Permalink
Fix the local temperature can go below absolute zero (#384)
Browse files Browse the repository at this point in the history
* add mixin

* address requested changes

---------

Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
Quarri6343 and Dream-Master authored Jul 9, 2024
1 parent 973b07c commit 6a9a25c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public class FixesConfig {
@Config.RequiresMcRestart
public static boolean earlyChunkTileCoordinateCheck;

@Config.Comment("Fix the temperature can go below absolute zero at very high place")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixNegativeKelvin;

@Config.Comment("Destroy and log TileEntities failing the safe coordinate instead of crashing the game (can cause loss of data)")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ public enum Mixins {
FAST_BLOCK_PLACING(new Builder("Allows blocks to be placed faster").addTargetedMod(TargetedMod.VANILLA)
.setSide(Side.CLIENT).setPhase(Phase.EARLY).addMixinClasses("minecraft.MixinMinecraft_FastBlockPlacing")
.setApplyIf(() -> true)), // Always apply, config handled in mixin
FIX_NEGATIVE_KELVIN(new Builder("Fix the local temperature can go below absolute zero")
.addTargetedMod(TargetedMod.VANILLA).setSide(Side.BOTH).setPhase(Phase.EARLY)
.addMixinClasses("minecraft.MixinBiomeGenBase").setApplyIf(() -> FixesConfig.fixNegativeKelvin)),

SPIGOT_EXTENDED_CHUNKS(new Builder("Spigot-style extended chunk format to remove the 2MB chunk size limit")
.addTargetedMod(TargetedMod.VANILLA).addExcludedMod(TargetedMod.BUKKIT).setSide(Side.BOTH)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.world.biome.BiomeGenBase;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BiomeGenBase.class)
public abstract class MixinBiomeGenBase {

@Unique
private static final float ABSOLUTE_ZERO = -459.67f / 100f; // in Fahrenheit scale

@Inject(method = "getFloatTemperature", at = @At("RETURN"), cancellable = true)
public final void hodgepodge$getFloatTemperature(int x, int y, int z, CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(Math.max(cir.getReturnValue(), ABSOLUTE_ZERO));
}
}

0 comments on commit 6a9a25c

Please sign in to comment.