Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getFloatTemperature causing lag #461

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
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;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;

@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));
@ModifyReturnValue(method = "getFloatTemperature", at = @At("RETURN"))
public final float hodgepodge$getFloatTemperature(float original) {
return Math.max(original, ABSOLUTE_ZERO);
}
}