From 07936857f58e1799ba62a5b2b9ae20493fd19ad3 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. --- .../mojang/math/OctahedralGroup.java.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch new file mode 100644 index 0000000000..64c7d5d058 --- /dev/null +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -0,0 +1,30 @@ +--- a/com/mojang/math/OctahedralGroup.java ++++ b/com/mojang/math/OctahedralGroup.java +@@ -110,6 +110,7 @@ + this.permutation = axisTransformation; + this.transformation = new Matrix3f().scaling(flipX ? -1.0F : 1.0F, flipY ? -1.0F : 1.0F, flipZ ? -1.0F : 1.0F); + this.transformation.mul(axisTransformation.transformation()); ++ this.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields + } + + private BooleanList packInversions() { +@@ -138,7 +139,7 @@ + return this.name; + } + +- public Direction rotate(Direction direction) { ++ public void initializeRotationDirections() { // Paper - Avoid Lazy Initialization for Enum Fields + if (this.rotatedDirections == null) { + this.rotatedDirections = Maps.newEnumMap(Direction.class); + Direction.Axis[] axiss = Direction.Axis.values(); +@@ -153,6 +154,10 @@ + } + } + ++ // Paper start - Avoid Lazy Initialization for Enum Fields ++ } ++ public Direction rotate(Direction direction) { ++ // Paper end - Avoid Lazy Initialization for Enum Fields + return this.rotatedDirections.get(direction); + } +