mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
91 lines
3.4 KiB
Diff
91 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Thu, 7 Nov 2024 21:50:47 +0100
|
|
Subject: [PATCH] Lithium: fast util
|
|
|
|
This patch is based on the following mixins:
|
|
* "net/caffeinemc/mods/lithium/mixin/math/fast_util/DirectionMixin.java"
|
|
* "net/caffeinemc/mods/lithium/mixin/math/fast_util/AABBMixin.java"
|
|
By: 2No2Name <2No2Name@web.de>
|
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
|
index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..9e527f8ada7ab076e41b22e8ef6ba5986e3db21e 100644
|
|
--- a/src/main/java/net/minecraft/core/Direction.java
|
|
+++ b/src/main/java/net/minecraft/core/Direction.java
|
|
@@ -204,7 +204,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
|
|
}
|
|
|
|
public Direction getOpposite() {
|
|
- return this.opposite; // Paper - optimise collisions
|
|
+ return VALUES[this.oppositeIndex]; // Leaf - Lithium - fast util
|
|
}
|
|
|
|
public Direction getClockWise(Direction.Axis axis) {
|
|
@@ -366,7 +366,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
|
|
}
|
|
|
|
public static Direction getRandom(RandomSource random) {
|
|
- return Util.getRandom(VALUES, random);
|
|
+ return VALUES[random.nextInt(VALUES.length)]; // Leaf - Lithium - fast util
|
|
}
|
|
|
|
public static Direction getNearest(double x, double y, double z) {
|
|
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
index db78616676ba021ee0f03cfea932f2912f4ec987..8e161efc19de76b0624b15f1c5ad399d2b1fa52d 100644
|
|
--- a/src/main/java/net/minecraft/world/phys/AABB.java
|
|
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
@@ -17,6 +17,15 @@ public class AABB {
|
|
public final double maxY;
|
|
public final double maxZ;
|
|
|
|
+ // Leaf start - Lithium - fast util
|
|
+ static {
|
|
+ assert Direction.Axis.X.ordinal() == 0;
|
|
+ assert Direction.Axis.Y.ordinal() == 1;
|
|
+ assert Direction.Axis.Z.ordinal() == 2;
|
|
+ assert Direction.Axis.values().length == 3;
|
|
+ }
|
|
+ // Leaf end - Lithium - fast util
|
|
+
|
|
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
|
this.minX = Math.min(x1, x2);
|
|
this.minY = Math.min(y1, y2);
|
|
@@ -85,11 +94,33 @@ public class AABB {
|
|
}
|
|
|
|
public double min(Direction.Axis axis) {
|
|
- return axis.choose(this.minX, this.minY, this.minZ);
|
|
+ // Leaf start - Lithium - fast util
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return this.minX;
|
|
+ case 1: //Y
|
|
+ return this.minY;
|
|
+ case 2: //Z
|
|
+ return this.minZ;
|
|
+ }
|
|
+
|
|
+ throw new IllegalArgumentException();
|
|
+ // Leaf end - Lithium - fast util
|
|
}
|
|
|
|
public double max(Direction.Axis axis) {
|
|
- return axis.choose(this.maxX, this.maxY, this.maxZ);
|
|
+ // Leaf start - Lithium - fast util
|
|
+ switch (axis.ordinal()) {
|
|
+ case 0: //X
|
|
+ return this.maxX;
|
|
+ case 1: //Y
|
|
+ return this.maxY;
|
|
+ case 2: //Z
|
|
+ return this.maxZ;
|
|
+ }
|
|
+
|
|
+ throw new IllegalArgumentException();
|
|
+ // Leaf end - Lithium - fast util
|
|
}
|
|
|
|
@Override
|