mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Make BlockData creation thread safe again (#6876)
This commit is contained in:
parent
fc1c86477e
commit
a671db9b96
@ -20,20 +20,12 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -0,0 +0,0 @@ public class CraftBlockData implements BlockData {
|
||||
Preconditions.checkState(CraftBlockData.MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
|
||||
}
|
||||
|
||||
+ // Paper start - cache block data strings
|
||||
+ private static Map<String, CraftBlockData> stringDataCache = new HashMap<>();
|
||||
+ private static Map<String, CraftBlockData> stringDataCache = new java.util.concurrent.ConcurrentHashMap<>();
|
||||
+
|
||||
+ static {
|
||||
+ // cache all of the default states at startup, will not cache ones with the custom states inside of the
|
||||
@ -54,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ if (material != null) {
|
||||
+ Block block = CraftMagicNumbers.getBlock(material);
|
||||
+ if (block != null) {
|
||||
+ ResourceLocation key = Registry.BLOCK.getKey(block);
|
||||
+ net.minecraft.resources.ResourceLocation key = Registry.BLOCK.getKey(block);
|
||||
+ data = data == null ? key.toString() : key + data;
|
||||
+ }
|
||||
+ }
|
||||
|
Loading…
Reference in New Issue
Block a user