This commit is contained in:
Etil
2022-01-08 21:24:31 +01:00
parent bed6310bba
commit 883bb9c470
2 changed files with 18 additions and 5 deletions

View File

@@ -8,10 +8,10 @@ You can find the original code on https://github.com/CaffeineMC/lithium-fabric (
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java
new file mode 100644
index 0000000000000000000000000000000000000000..f0cbb3c231f248a044cbed6cc7c836d0cacca206
index 0000000000000000000000000000000000000000..6af5d13b5dfb620306d8d7028aeb393fa8a55583
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java
@@ -0,0 +1,89 @@
@@ -0,0 +1,90 @@
+package me.jellysquid.mods.lithium.common.util.math;
+
+import net.minecraft.util.Mth;
@@ -46,6 +46,7 @@ index 0000000000000000000000000000000000000000..f0cbb3c231f248a044cbed6cc7c836d0
+ private static final float SINE_TABLE_MIDPOINT;
+
+ static {
+ final float[] SINE_TABLE = Mth.getSinTable();
+ // Copy the sine table, covering to raw int bits
+ for (int i = 0; i < SINE_TABLE_INT.length; i++) {
+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(Mth.SIN[i]);
@@ -103,7 +104,7 @@ index 0000000000000000000000000000000000000000..f0cbb3c231f248a044cbed6cc7c836d0
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index 7443df5c2648d279630a7db38d7ddcf4e7113f97..420b55fa64e1f88a856a96aa9d030e16407f3380 100644
index 7443df5c2648d279630a7db38d7ddcf4e7113f97..3b6a84fee8e24f53f2f1f8a1ef7db388ae414fe8 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -8,6 +8,7 @@ import net.minecraft.core.Vec3i;
@@ -114,16 +115,28 @@ index 7443df5c2648d279630a7db38d7ddcf4e7113f97..420b55fa64e1f88a856a96aa9d030e16
public class Mth {
private static final int BIG_ENOUGH_INT = 1024;
@@ -40,11 +41,11 @@ public class Mth {
@@ -30,7 +31,8 @@ public class Mth {
}
});
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new wtf.etil.mirai.server.util.XoRoShiRoRandom(); // Mirai
+ public static float[] getSinTable() { return SIN; } // Mirai
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
private static final double ONE_SIXTH = 0.16666666666666666D;
private static final int FRAC_EXP = 8;
@@ -40,11 +42,13 @@ public class Mth {
private static final double[] COS_TAB = new double[257];
public static float sin(float value) {
- return SIN[(int)(value * 10430.378F) & '\uffff'];
+ //return SIN[(int)(value * 10430.378F) & '\uffff'];
+ return CompactSineLUT.sin(value); // Mirai
}
public static float cos(float value) {
- return SIN[(int)(value * 10430.378F + 16384.0F) & '\uffff'];
+ //return SIN[(int)(value * 10430.378F + 16384.0F) & '\uffff'];
+ return CompactSineLUT.cos(value); // Mirai
}

View File

@@ -14,7 +14,7 @@ index b470da69f271d1a5ebb9727c0c34944e85ce3a51..5e80825c0e98c0eb5c4309a9234e7b03
private static final Logger LOGGER = LogManager.getLogger();
private final File playerDir;
protected final DataFixer fixerUpper;
+ private final wtf.etil.mirai.server.cache.NBTCache dataCache = new wtf.etil.mirai.server.NBTCache(); // Mirai - NBT Cache system
+ private final wtf.etil.mirai.server.cache.NBTCache dataCache = new wtf.etil.mirai.server.cache.NBTCache(); // Mirai - NBT Cache system
public PlayerDataStorage(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer) {
this.fixerUpper = dataFixer;