mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-23 11:06:51 +01:00
61 lines
2.9 KiB
Diff
61 lines
2.9 KiB
Diff
From d11412bce648de5b88ce3000dcea73eb43832e37 Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Mon, 11 May 2020 21:00:44 +0200
|
|
Subject: [PATCH] lithium MixinDirection
|
|
|
|
---
|
|
.../java/net/minecraft/server/EnumDirection.java | 16 ++++++++++++----
|
|
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EnumDirection.java b/src/main/java/net/minecraft/server/EnumDirection.java
|
|
index 3b7bb296dc..b4258ec78a 100644
|
|
--- a/src/main/java/net/minecraft/server/EnumDirection.java
|
|
+++ b/src/main/java/net/minecraft/server/EnumDirection.java
|
|
@@ -17,13 +17,13 @@ public enum EnumDirection implements INamable {
|
|
DOWN(0, 1, -1, "down", EnumDirection.EnumAxisDirection.NEGATIVE, EnumDirection.EnumAxis.Y, new BaseBlockPosition(0, -1, 0)), UP(1, 0, -1, "up", EnumDirection.EnumAxisDirection.POSITIVE, EnumDirection.EnumAxis.Y, new BaseBlockPosition(0, 1, 0)), NORTH(2, 3, 2, "north", EnumDirection.EnumAxisDirection.NEGATIVE, EnumDirection.EnumAxis.Z, new BaseBlockPosition(0, 0, -1)), SOUTH(3, 2, 0, "south", EnumDirection.EnumAxisDirection.POSITIVE, EnumDirection.EnumAxis.Z, new BaseBlockPosition(0, 0, 1)), WEST(4, 5, 1, "west", EnumDirection.EnumAxisDirection.NEGATIVE, EnumDirection.EnumAxis.X, new BaseBlockPosition(-1, 0, 0)), EAST(5, 4, 3, "east", EnumDirection.EnumAxisDirection.POSITIVE, EnumDirection.EnumAxis.X, new BaseBlockPosition(1, 0, 0));
|
|
|
|
private final int g;
|
|
- private final int h;
|
|
+ private final int h; // YAPFA this is idOpposit(yarn)
|
|
private final int i;
|
|
private final String j;
|
|
private final EnumDirection.EnumAxis k;
|
|
private final EnumDirection.EnumAxisDirection l;
|
|
private final BaseBlockPosition m;
|
|
- private static final EnumDirection[] n = values();
|
|
+ private static final EnumDirection[] n = values(); private static final EnumDirection[] ALL = n;// YAPFA OBF HELPER
|
|
private static final Map<String, EnumDirection> o = (Map) Arrays.stream(EnumDirection.n).collect(Collectors.toMap(EnumDirection::l, (enumdirection) -> {
|
|
return enumdirection;
|
|
}));
|
|
@@ -95,8 +95,12 @@ public enum EnumDirection implements INamable {
|
|
return this.l;
|
|
}
|
|
|
|
+ /**
|
|
+ * @reason Avoid the modulo/abs operations
|
|
+ * @author JellySquid
|
|
+ */
|
|
public EnumDirection opposite() {
|
|
- return fromType1(this.h);
|
|
+ return ALL[this.h];
|
|
}
|
|
|
|
public EnumDirection f() {
|
|
@@ -182,8 +186,12 @@ public enum EnumDirection implements INamable {
|
|
return (float) ((this.i & 3) * 90);
|
|
}
|
|
|
|
+ /**
|
|
+ * @reason Do not allocate an excessive number of Direction arrays
|
|
+ * @author JellySquid
|
|
+ */
|
|
public static EnumDirection a(Random random) {
|
|
- return values()[random.nextInt(values().length)];
|
|
+ return ALL[random.nextInt(ALL.length)];
|
|
}
|
|
|
|
public static EnumDirection a(double d0, double d1, double d2) {
|
|
--
|
|
2.25.1.windows.1
|
|
|