13
0
geforkt von Mirrors/Paper

Use a CHM for StructureTemplate.Pallete cache

fixes a CME due to this collection being shared across threads
Dieser Commit ist enthalten in:
Shane Freeder 2021-07-12 12:28:29 +01:00
Ursprung cf0525cba8
Commit 0202f1788d

Datei anzeigen

@ -18,18 +18,18 @@
public class StructureTemplate { public class StructureTemplate {
@@ -73,6 +77,11 @@ @@ -74,6 +78,11 @@
public final List<StructureTemplate.StructureEntityInfo> entityInfoList = Lists.newArrayList();
private Vec3i size; private Vec3i size;
private String author; private String author;
+
+ // CraftBukkit start - data containers + // CraftBukkit start - data containers
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
+ public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); + public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY);
+ // CraftBukkit end + // CraftBukkit end
+
public StructureTemplate() { public StructureTemplate() {
this.size = Vec3i.ZERO; this.size = Vec3i.ZERO;
this.author = "?";
@@ -147,7 +156,7 @@ @@ -147,7 +156,7 @@
} }
@ -141,6 +141,15 @@
} }
private void loadPalette(HolderGetter<Block> blockLookup, ListTag palette, ListTag blocks) { private void loadPalette(HolderGetter<Block> blockLookup, ListTag palette, ListTag blocks) {
@@ -840,7 +889,7 @@
public static final class Palette {
private final List<StructureTemplate.StructureBlockInfo> blocks;
- private final Map<Block, List<StructureTemplate.StructureBlockInfo>> cache = Maps.newHashMap();
+ private final Map<Block, List<StructureTemplate.StructureBlockInfo>> cache = Maps.newConcurrentMap(); // Paper - Fix CME due to this collection being shared across threads
@Nullable
private List<StructureTemplate.JigsawBlockInfo> cachedJigsaws;
@@ -924,7 +973,7 @@ @@ -924,7 +973,7 @@
public BlockState stateFor(int id) { public BlockState stateFor(int id) {
BlockState iblockdata = (BlockState) this.ids.byId(id); BlockState iblockdata = (BlockState) this.ids.byId(id);