Port & improve fastmath

This commit is contained in:
ThisIsALegitUsername 2023-02-02 16:41:19 +00:00
parent 1022a6b561
commit 15bcbff7e8
2 changed files with 9 additions and 19 deletions

View File

@ -1,23 +1,14 @@
package dev.resent.module.impl.misc;
import dev.resent.annotation.Module;
import dev.resent.module.base.Category;
import dev.resent.module.base.Mod;
import net.minecraft.util.MathHelper;
@Module(name = "Fast math", category = Category.MISC)
public class FPSB extends Mod {
public void onEnable() { MathHelper.fastMath = true; }
public void onDisable() { MathHelper.fastMath = false; }
public static boolean yes = false;
public FPSB() {
super("Fast math", Category.MISC);
}
@Override
public void onEnable() {
yes = true;
}
@Override
public void onDisable() {
yes = false;
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.util;
import dev.resent.module.impl.misc.FPSB;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
@ -35,20 +34,20 @@ public class MathHelper {
private static final double field_181163_d;
private static final double[] field_181164_e;
private static final double[] field_181165_f;
public static boolean fps = FPSB.yes;
public static boolean fastMath = false;
/**+
* sin looked up in a table
*/
public static float sin(float parFloat1) {
return fps ? SIN_TABLE_FAST[(int) (parFloat1 * 651.8986f) & 4095] : SIN_TABLE[(int) (parFloat1 * 10430.378F) & '\uffff'];
return fastMath ? SIN_TABLE_FAST[(int) (parFloat1 * 651.8986f) & 4095] : SIN_TABLE[(int) (parFloat1 * 10430.378F) & '\uffff'];
}
/**+
* cos looked up in the sin table with the appropriate offset
*/
public static float cos(float value) {
return fps ? SIN_TABLE_FAST[(int) ((value + ((float) Math.PI / 2f)) * 651.8986f) & 4095] : SIN_TABLE[(int) (value * 10430.378F + 16384.0F) & '\uffff'];
return fastMath ? SIN_TABLE_FAST[(int) ((value + ((float) Math.PI / 2f)) * 651.8986f) & 4095] : SIN_TABLE[(int) (value * 10430.378F + 16384.0F) & '\uffff'];
}
public static float sqrt_float(float value) {