126 lines
4.9 KiB
Diff
126 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
|
|
Date: Thu, 16 Feb 2023 21:34:37 +0200
|
|
Subject: [PATCH] Lithium Math FastUtil
|
|
|
|
Author: JellySquid
|
|
Licence: LGPL-3.0
|
|
|
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
index 913f2f26b1d022e8a812af7caa5dfca5fa548782..95742b2ec27156071867a9467669b350f3ad4280 100644
|
|
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
|
|
@@ -206,7 +206,9 @@ public class KaiijuConfig {
|
|
}
|
|
|
|
public static boolean lithiumEnable = true;
|
|
+ public static boolean lithiumMathFastUtil = true;
|
|
private static void lithiumSettings() {
|
|
lithiumEnable = getBoolean("lithium.enable", lithiumEnable);
|
|
+ lithiumMathFastUtil = getBoolean("lithium.math.fast-util", lithiumMathFastUtil) && lithiumEnable;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/core/AxisCycle.java b/src/main/java/net/minecraft/core/AxisCycle.java
|
|
index b5d8a60dc78a76c0a55bfc30cc49d26857bd914a..dd8d98acf21bb676e86f9befb45fd09e1b14a01d 100644
|
|
--- a/src/main/java/net/minecraft/core/AxisCycle.java
|
|
+++ b/src/main/java/net/minecraft/core/AxisCycle.java
|
|
@@ -35,6 +35,18 @@ public enum AxisCycle {
|
|
|
|
@Override
|
|
public Direction.Axis cycle(Direction.Axis axis) {
|
|
+ // Kaiiju start - Lithium
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return Direction.Axis.Y;
|
|
+ case 1: //Y
|
|
+ return Direction.Axis.Z;
|
|
+ case 2: //Z
|
|
+ return Direction.Axis.X;
|
|
+ }
|
|
+ }
|
|
+ // Kaiiju end
|
|
return AXIS_VALUES[Math.floorMod(axis.ordinal() + 1, 3)];
|
|
}
|
|
|
|
@@ -56,6 +68,18 @@ public enum AxisCycle {
|
|
|
|
@Override
|
|
public Direction.Axis cycle(Direction.Axis axis) {
|
|
+ // Kaiiju start - Lithium
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return Direction.Axis.Z;
|
|
+ case 1: //Y
|
|
+ return Direction.Axis.X;
|
|
+ case 2: //Z
|
|
+ return Direction.Axis.Y;
|
|
+ }
|
|
+ }
|
|
+ // Kaiiju end
|
|
return AXIS_VALUES[Math.floorMod(axis.ordinal() - 1, 3)];
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
|
index a4dc96b1a3bf309584657e3a1e7dfaea967f9425..09c1989dc3b12d9488b8869e71f2a4890656cc36 100644
|
|
--- a/src/main/java/net/minecraft/core/Direction.java
|
|
+++ b/src/main/java/net/minecraft/core/Direction.java
|
|
@@ -191,6 +191,7 @@ public enum Direction implements StringRepresentable {
|
|
}
|
|
|
|
public Direction getOpposite() {
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil) return VALUES[this.oppositeIndex]; // Kaiiju
|
|
return from3DDataValue(this.oppositeIndex);
|
|
}
|
|
|
|
@@ -453,6 +454,7 @@ public enum Direction implements StringRepresentable {
|
|
}
|
|
|
|
public static Direction getRandom(RandomSource random) {
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil) return VALUES[random.nextInt(VALUES.length)]; // Kaiiju
|
|
return Util.getRandom(VALUES, random);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
index cfb2e46b34b2982d6724f18214557fc80cf4adfa..4fae201f57dc23ed0e25f17739f97133a7f7534c 100644
|
|
--- a/src/main/java/net/minecraft/world/phys/AABB.java
|
|
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
@@ -81,10 +81,36 @@ public class AABB {
|
|
}
|
|
|
|
public double min(Direction.Axis axis) {
|
|
+ // Kaiiju start - Lithium
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return this.minX;
|
|
+ case 1: //Y
|
|
+ return this.minY;
|
|
+ case 2: //Z
|
|
+ return this.minZ;
|
|
+ }
|
|
+ throw new IllegalArgumentException();
|
|
+ }
|
|
+ // Kaiiju end
|
|
return axis.choose(this.minX, this.minY, this.minZ);
|
|
}
|
|
|
|
public double max(Direction.Axis axis) {
|
|
+ // Kaiiju start - Lithium
|
|
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.lithiumMathFastUtil){
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return this.maxX;
|
|
+ case 1: //Y
|
|
+ return this.maxY;
|
|
+ case 2: //Z
|
|
+ return this.maxZ;
|
|
+ }
|
|
+ throw new IllegalArgumentException();
|
|
+ }
|
|
+ // Kaiiju end
|
|
return axis.choose(this.maxX, this.maxY, this.maxZ);
|
|
}
|
|
|