import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import com.irtimaled.bbor.common.models.Coords;
import com.irtimaled.bbor.mixin.access.IStructureStart;
+import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
+import it.unimi.dsi.fastutil.objects.ObjectSets;
import net.minecraft.structure.StructurePiece;
import net.minecraft.structure.StructureStart;
import net.minecraft.util.math.BlockBox;
import java.util.Map;
import java.util.Set;
-class StructureProcessor {
- private static final Set<BoundingBoxType> supportedStructures = new HashSet<>();
+public class StructureProcessor {
+ private static final Map<String, BoundingBoxType> supportedStructures = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>());
+ public static final Set<String> supportedStructureIds = ObjectSets.synchronize(new ObjectOpenHashSet<>());
- static void registerSupportedStructure(BoundingBoxType type) {
- supportedStructures.add(type);
+ public static void registerSupportedStructure(BoundingBoxType type) {
+ supportedStructures.put(type.getName(), type);
}
StructureProcessor(BoundingBoxCache boundingBoxCache) {
private final BoundingBoxCache boundingBoxCache;
- private void addStructures(BoundingBoxType type, StructureStart<?> structureStart) {
+ private void addStructures(BoundingBoxType type, StructureStart structureStart) {
if (structureStart == null) return;
try {
return BoundingBoxCuboid.from(min, max, type);
}
- void process(Map<String, StructureStart<?>> structures) {
- if (structures.size() > 0) {
- supportedStructures.forEach(type -> addStructures(type, structures.get(type.getName())));
+ void process(Map<String, StructureStart> structures) {
+ for (Map.Entry<String, StructureStart> entry : structures.entrySet()) {
+ final BoundingBoxType type = supportedStructures.get("structure:" + entry.getKey());
+ if (type != null) {
+ addStructures(type, entry.getValue());
+ }
}
}
}