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

Remove the SINE_TABLE array in MathHelper #567

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
@@ -1,12 +1,35 @@
package me.jellysquid.mods.lithium.mixin.math.sine_lut;

import me.jellysquid.mods.lithium.common.util.math.CompactSineLUT;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.util.math.MathHelper;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(MathHelper.class)
public class MixinMathHelper {
@Shadow
@Mutable
public static float[] SINE_TABLE;

@Inject(method = "<clinit>", at = @At("RETURN"))
private static void onClassInit(CallbackInfo ci) {
new CompactSineLUT(); // Force class initialisation
MixinMathHelper.SINE_TABLE = null;
}

static {
ServerLifecycleEvents.SERVER_STARTING.register((server) -> {
Colonel-Sandvich marked this conversation as resolved.
Show resolved Hide resolved
MixinMathHelper.SINE_TABLE = null;
});
}

/**
* @author jellysquid3
* @reason use an optimized implementation
Expand Down