2023-05-15 02:46:17 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
|
|
Date: Sun, 14 May 2023 00:47:28 -0400
|
|
|
|
Subject: [PATCH] Avoid Lazy Initialization for Enum Fields
|
|
|
|
|
|
|
|
This patch is meant to get rid of any instances of lazy initialization that Minecraft introduces for enums.
|
|
|
|
This has the possibility to create race condition issues, and generally don't make sense to be lazily done anyways.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/mojang/math/OctahedralGroup.java b/src/main/java/com/mojang/math/OctahedralGroup.java
|
2024-04-23 19:02:08 +02:00
|
|
|
index 05d28a08c1fdf75221f5d774fe49d905840ae472..207f424b2bf5e0c48f33e4553c7c6019ef2dd009 100644
|
2023-05-15 02:46:17 +02:00
|
|
|
--- a/src/main/java/com/mojang/math/OctahedralGroup.java
|
|
|
|
+++ b/src/main/java/com/mojang/math/OctahedralGroup.java
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -110,6 +110,7 @@ public enum OctahedralGroup implements StringRepresentable {
|
2023-05-15 02:46:17 +02:00
|
|
|
this.permutation = axisTransformation;
|
2024-04-12 21:14:06 +02:00
|
|
|
this.transformation = new Matrix3f().scaling(flipX ? -1.0F : 1.0F, flipY ? -1.0F : 1.0F, flipZ ? -1.0F : 1.0F);
|
2023-05-15 02:46:17 +02:00
|
|
|
this.transformation.mul(axisTransformation.transformation());
|
2024-01-15 12:38:39 +01:00
|
|
|
+ this.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields
|
2023-05-15 02:46:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private BooleanList packInversions() {
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -138,7 +139,7 @@ public enum OctahedralGroup implements StringRepresentable {
|
2023-05-15 02:46:17 +02:00
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
- public Direction rotate(Direction direction) {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ public void initializeRotationDirections() { // Paper - Avoid Lazy Initialization for Enum Fields
|
2023-05-15 02:46:17 +02:00
|
|
|
if (this.rotatedDirections == null) {
|
|
|
|
this.rotatedDirections = Maps.newEnumMap(Direction.class);
|
|
|
|
Direction.Axis[] axiss = Direction.Axis.values();
|
2024-04-12 21:14:06 +02:00
|
|
|
@@ -153,6 +154,10 @@ public enum OctahedralGroup implements StringRepresentable {
|
2023-05-15 02:46:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper start - Avoid Lazy Initialization for Enum Fields
|
2023-05-15 02:46:17 +02:00
|
|
|
+ }
|
|
|
|
+ public Direction rotate(Direction direction) {
|
2024-01-15 12:38:39 +01:00
|
|
|
+ // Paper end - Avoid Lazy Initialization for Enum Fields
|
2023-05-15 02:46:17 +02:00
|
|
|
return this.rotatedDirections.get(direction);
|
|
|
|
}
|
|
|
|
|