9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-22 00:09:15 +00:00
Files
DivineMC/patches/server/0057-lithium-fast_util.patch
NONPLAYT 16f429723b Updated Upstream (Purpur)
Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@998a4e6 [ci skip] add a good chunk of patch identifying comments
PurpurMC/Purpur@e440784 [ci skip] a couple more patch identifying comments
PurpurMC/Purpur@c33391b Updated Upstream (Paper)
PurpurMC/Purpur@8d7fab1 [ci skip] small patch comment cleanup
2024-12-16 20:56:44 +03:00

87 lines
3.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Mon, 16 Dec 2024 20:52:48 +0300
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 928f38fd6beb00753c92ae9f4678f7507519a39b..4c53995d6d173ff6f544d52f11b675015efde26e 100644
--- a/src/main/java/net/minecraft/core/Direction.java
+++ b/src/main/java/net/minecraft/core/Direction.java
@@ -217,7 +217,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
}
public Direction getOpposite() {
- return this.opposite; // Paper - optimise collisions
+ return VALUES[this.oppositeIndex]; // DivineMC - lithium: fast_util
}
public Direction getClockWise(Direction.Axis axis) {
@@ -350,7 +350,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)]; // DivineMC - lithium: fast_util
}
public static Direction getApproximateNearest(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 e74866e5195a5eeae7666ad7be750edac5947094..25d7e7116282ec4b2cf85fe0b8e920af77fe4206 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -18,6 +18,15 @@ public class AABB {
public final double maxY;
public final double maxZ;
+ // DivineMC 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;
+ }
+ // DivineMC 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);
@@ -86,11 +95,33 @@ public class AABB {
}
public double min(Direction.Axis axis) {
- return axis.choose(this.minX, this.minY, this.minZ);
+ // DivineMC 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();
+ // DivineMC end
}
public double max(Direction.Axis axis) {
- return axis.choose(this.maxX, this.maxY, this.maxZ);
+ // DivineMC 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();
+ // DivineMC end
}
@Override