Yatopia/patches/server/0019-lithium-MixinAxisCycleDirection.patch
2020-07-17 18:21:30 +02:00

65 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Mon, 11 May 2020 21:50:18 +0200
Subject: [PATCH] lithium MixinAxisCycleDirection
diff --git a/src/main/java/net/minecraft/server/EnumAxisCycle.java b/src/main/java/net/minecraft/server/EnumAxisCycle.java
index a7c2543fdd4d5f6a04c45ec42472837ccaea9619..d05cddcc90e220c42548b2eb7b190fc63e9d51f5 100644
--- a/src/main/java/net/minecraft/server/EnumAxisCycle.java
+++ b/src/main/java/net/minecraft/server/EnumAxisCycle.java
@@ -24,14 +24,27 @@ public enum EnumAxisCycle {
return enumdirection_enumaxis.a(k, i, j);
}
+ /**
+ * The JVM has difficulty optimizing these functions due to the use of dynamic dispatch. They can trivially be
+ * implemented as a simple switch lookup table.
+ */
@Override
public EnumDirection.EnumAxis a(EnumDirection.EnumAxis enumdirection_enumaxis) {
- return null.d[Math.floorMod(enumdirection_enumaxis.ordinal() + 1, 3)];
+ switch (enumdirection_enumaxis) {
+ case X:
+ return EnumDirection.EnumAxis.Y;
+ case Y:
+ return EnumDirection.EnumAxis.Z;
+ case Z:
+ return EnumDirection.EnumAxis.X;
+ }
+
+ throw new IllegalArgumentException();
}
@Override
public EnumAxisCycle a() {
- return null.BACKWARD;
+ return BACKWARD;
}
},
BACKWARD {
@@ -42,12 +55,21 @@ public enum EnumAxisCycle {
@Override
public EnumDirection.EnumAxis a(EnumDirection.EnumAxis enumdirection_enumaxis) {
- return null.d[Math.floorMod(enumdirection_enumaxis.ordinal() - 1, 3)];
+ switch (enumdirection_enumaxis) {
+ case X:
+ return EnumDirection.EnumAxis.Z;
+ case Y:
+ return EnumDirection.EnumAxis.X;
+ case Z:
+ return EnumDirection.EnumAxis.Y;
+ }
+
+ throw new IllegalArgumentException();
}
@Override
public EnumAxisCycle a() {
- return null.FORWARD;
+ return FORWARD;
}
};