From 83b1a01c96f781eca59ca900caf660e1b83ba29e Mon Sep 17 00:00:00 2001 From: covers1624 Date: Thu, 19 Sep 2024 00:07:58 +0930 Subject: [PATCH] Make AttributeKey and VertexOperation registration synchronized. --- .../codechicken/lib/render/pipeline/IVertexOperation.java | 6 +++++- .../lib/render/pipeline/attribute/AttributeKey.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/codechicken/lib/render/pipeline/IVertexOperation.java b/src/main/java/codechicken/lib/render/pipeline/IVertexOperation.java index a8a4c247..00b74a87 100644 --- a/src/main/java/codechicken/lib/render/pipeline/IVertexOperation.java +++ b/src/main/java/codechicken/lib/render/pipeline/IVertexOperation.java @@ -8,7 +8,7 @@ public interface IVertexOperation { static int registerOperation() { - return VertexOperationRegistry.nextOperationIndex++; + return VertexOperationRegistry.nextOperationIndex(); } static int operationCount() { @@ -35,5 +35,9 @@ static int operationCount() { class VertexOperationRegistry { static int nextOperationIndex; + + private static synchronized int nextOperationIndex() { + return VertexOperationRegistry.nextOperationIndex++; + } } } diff --git a/src/main/java/codechicken/lib/render/pipeline/attribute/AttributeKey.java b/src/main/java/codechicken/lib/render/pipeline/attribute/AttributeKey.java index 6c35d681..2cc2a4a3 100644 --- a/src/main/java/codechicken/lib/render/pipeline/attribute/AttributeKey.java +++ b/src/main/java/codechicken/lib/render/pipeline/attribute/AttributeKey.java @@ -93,7 +93,7 @@ public static class AttributeKeyRegistry { private static final Map> nameMap = new HashMap<>(); private static final List> attributeKeys = new ArrayList<>(); - private static int registerAttributeKey(AttributeKey attr) { + private static synchronized int registerAttributeKey(AttributeKey attr) { if (nameMap.containsKey(attr.name)) { throw new IllegalArgumentException("Duplicate registration of attribute with name: " + attr.name); }