mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
89d51d5f29
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable.
40 lines
2 KiB
Diff
40 lines
2 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 a5a889d40228a0d6c7259caf8cb2554588d9aaf9..5009192046e5e083d14cef3f448b98b978dd54bf 100644
|
|
--- a/src/main/java/com/mojang/math/OctahedralGroup.java
|
|
+++ b/src/main/java/com/mojang/math/OctahedralGroup.java
|
|
@@ -111,6 +111,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() {
|
|
@@ -139,7 +140,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();
|
|
@@ -154,6 +155,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);
|
|
}
|
|
|