From 15bcbff7e87c37c7966bca2987459832d73629c2 Mon Sep 17 00:00:00 2001 From: ThisIsALegitUsername Date: Thu, 2 Feb 2023 16:41:19 +0000 Subject: [PATCH] Port & improve fastmath --- .../dev/resent/module/impl/misc/FPSB.java | 21 ++++++------------- .../java/net/minecraft/util/MathHelper.java | 7 +++---- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/java/dev/resent/module/impl/misc/FPSB.java b/src/main/java/dev/resent/module/impl/misc/FPSB.java index 8d2a567a..79d6fc60 100644 --- a/src/main/java/dev/resent/module/impl/misc/FPSB.java +++ b/src/main/java/dev/resent/module/impl/misc/FPSB.java @@ -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; - } } diff --git a/src/main/java/net/minecraft/util/MathHelper.java b/src/main/java/net/minecraft/util/MathHelper.java index 605c3b79..287564f7 100644 --- a/src/main/java/net/minecraft/util/MathHelper.java +++ b/src/main/java/net/minecraft/util/MathHelper.java @@ -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) {