move jiggy map

This commit is contained in:
George Paton 2025-08-08 16:53:13 +10:00
parent 3877a666a6
commit 7213b9b84d
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package com.hbm.world.gen.nbt;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
@ -8,6 +9,9 @@ import net.minecraft.world.gen.structure.StructureComponent.BlockSelector;
// Assigned to a Component to build
public class JigsawPiece {
// Translates a given name into a jigsaw piece, for serialization
protected static Map<String, JigsawPiece> jigsawMap = new HashMap<>();
public final String name;
public final NBTStructure structure;
@ -23,11 +27,11 @@ public class JigsawPiece {
public JigsawPiece(String name, NBTStructure structure, int heightOffset) {
if(name == null) throw new IllegalStateException("A severe error has occurred in NBTStructure! A jigsaw piece has been registered without a valid name!");
if(NBTStructure.jigsawMap.containsKey(name)) throw new IllegalStateException("A severe error has occurred in NBTStructure! A jigsaw piece has been registered with the same name as another: " + name);
if(jigsawMap.containsKey(name)) throw new IllegalStateException("A severe error has occurred in NBTStructure! A jigsaw piece has been registered with the same name as another: " + name);
this.name = name;
this.structure = structure;
NBTStructure.jigsawMap.put(name, this);
jigsawMap.put(name, this);
this.heightOffset = heightOffset;
}

View File

@ -59,9 +59,6 @@ public class NBTStructure {
protected static Map<Integer, List<SpawnCondition>> weightedMap = new HashMap<>();
protected static Map<Integer, List<SpawnCondition>> customSpawnMap = new HashMap<>();
// serialization data
protected static Map<String, JigsawPiece> jigsawMap = new HashMap<>();
private String name;
private boolean isLoaded;
@ -761,7 +758,7 @@ public class NBTStructure {
// Load from NBT
@Override
protected void func_143011_b(NBTTagCompound nbt) {
piece = jigsawMap.get(nbt.getString("piece"));
piece = JigsawPiece.jigsawMap.get(nbt.getString("piece"));
minHeight = nbt.getInteger("min");
maxHeight = nbt.getInteger("max");
heightUpdated = nbt.getBoolean("hasHeight");