9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/server/0005-lithium-fast-util.patch
2023-03-21 20:54:44 +03:00

87 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 2No2Name <2No2Name@web.de>
Date: Tue, 14 Dec 2021 12:04:01 -0500
Subject: [PATCH] lithium: fast util
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
index 82bce6109d59cba30178a446f0ff129da6f3692f..28f3145193e8bc22f3bbd0442248ea09ccc91973 100644
--- a/src/main/java/net/minecraft/core/Direction.java
+++ b/src/main/java/net/minecraft/core/Direction.java
@@ -192,7 +192,7 @@ public enum Direction implements StringRepresentable {
}
public Direction getOpposite() {
- return from3DDataValue(this.oppositeIndex);
+ return VALUES[this.oppositeIndex]; // JettPack - lithium: fast util
}
public Direction getClockWise(Direction.Axis axis) {
@@ -442,7 +442,7 @@ public enum Direction implements StringRepresentable {
}
public static Direction getRandom(RandomSource random) {
- return Util.getRandom(VALUES, random);
+ return VALUES[random.nextInt(VALUES.length)]; // JettPack - 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 ffc76354ead6937daf366c3d87bcb51d3e4c47f5..5be83bcfc719db1a71b00dc4a88fd794476a8ad9 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -16,6 +16,15 @@ public class AABB {
public final double maxY;
public final double maxZ;
+ // JettPack 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;
+ }
+ // JettPack end
+
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);
@@ -81,11 +90,33 @@ public class AABB {
}
public double min(Direction.Axis axis) {
- return axis.choose(this.minX, this.minY, this.minZ);
+ // JettPack 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();
+ // JettPack end
}
public double max(Direction.Axis axis) {
- return axis.choose(this.maxX, this.maxY, this.maxZ);
+ // JettPack 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();
+ // JettPack end
}
@Override