mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-20 07:19:23 +00:00
87 lines
3.1 KiB
Diff
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 a3bbebcdaea9e0dfddd9825272f84fc76cd13e89..ee725b972d3d5fb22538aaff9c72e47c6bad0cea 100644
|
|
--- a/src/main/java/net/minecraft/core/Direction.java
|
|
+++ b/src/main/java/net/minecraft/core/Direction.java
|
|
@@ -196,7 +196,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) {
|
|
@@ -446,7 +446,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 68cc6f2a78a06293a29317fda72ab3ee79b3533a..c5ff387a78693b0d5b18653dae67eb4a03324ff7 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
|