From 0202f1788d3ac67262a4bee397ce6482c1dfcb12 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Mon, 12 Jul 2021 12:28:29 +0100 Subject: [PATCH] Use a CHM for StructureTemplate.Pallete cache fixes a CME due to this collection being shared across threads --- .../templatesystem/StructureTemplate.java.patch | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index d03bc0207c..8c376045ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -18,18 +18,18 @@ public class StructureTemplate { -@@ -73,6 +77,11 @@ - public final List entityInfoList = Lists.newArrayList(); +@@ -74,6 +78,11 @@ private Vec3i size; private String author; -+ + + // CraftBukkit start - data containers + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); + // CraftBukkit end - ++ public StructureTemplate() { this.size = Vec3i.ZERO; + this.author = "?"; @@ -147,7 +156,7 @@ } @@ -141,6 +141,15 @@ } private void loadPalette(HolderGetter blockLookup, ListTag palette, ListTag blocks) { +@@ -840,7 +889,7 @@ + public static final class Palette { + + private final List blocks; +- private final Map> cache = Maps.newHashMap(); ++ private final Map> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads + @Nullable + private List cachedJigsaws; + @@ -924,7 +973,7 @@ public BlockState stateFor(int id) { BlockState iblockdata = (BlockState) this.ids.byId(id);