3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/server/0863-Avoid-Lazy-Initialization-for-Enum-Fields.patch
Jake Potrebic 526795bacd
Update patches to handle vineflower decompiler (#10406)
* Update patches to handle vineflower decompiler

* update patches again to handle inlined simple lambdas

* update vf again and re-apply/rebuild patches

* update patches after removal of verify-merges flag

* fix compile issue

* remove maven local

* fix some issues

* address more issues

* fix collision patch

* use paperweight release

* more fixes

* update fineflower and fix patches again

* add missing comment descriptor

---------

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2024-04-12 12:14:06 -07:00

41 Zeilen
2.0 KiB
Diff

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
index 8af12b383bb80d1c0a12e1151030ab6e21c27e79..d2efe5e4f767f8316bc3915573bd1efcbcf20968 100644
--- a/src/main/java/com/mojang/math/OctahedralGroup.java
+++ b/src/main/java/com/mojang/math/OctahedralGroup.java
@@ -110,6 +110,7 @@ public enum OctahedralGroup implements StringRepresentable {
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 @@ public enum OctahedralGroup implements StringRepresentable {
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 @@ public enum OctahedralGroup implements StringRepresentable {
}
}
+ // 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);
}