]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/common/StructureProcessor.java
Get 1.17.1 building
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / common / StructureProcessor.java
index b63e0ebdf033040cd71cd50af270c5e3f2dd49ec..29ba726df909f57699058e5c37df1515deb44b36 100644 (file)
@@ -24,11 +24,12 @@ class StructureProcessor {
 
     private final BoundingBoxCache boundingBoxCache;
 
-    private void addStructures(BoundingBoxType type, Map<String, StructureStart> structureMap) {
-        StructureStart structureStart = structureMap.get(type.getName());
+    private void addStructures(BoundingBoxType type, StructureStart<?> structureStart) {
         if (structureStart == null) return;
 
-        BlockBox bb = structureStart.getBoundingBox();
+        if (structureStart.hasNoChildren()) return;
+
+        BlockBox bb = structureStart.setBoundingBoxFromChildren();
         if (bb == null) return;
 
         AbstractBoundingBox boundingBox = buildStructure(bb, type);
@@ -42,14 +43,14 @@ class StructureProcessor {
     }
 
     private AbstractBoundingBox buildStructure(BlockBox bb, BoundingBoxType type) {
-        Coords min = new Coords(bb.minX, bb.minY, bb.minZ);
-        Coords max = new Coords(bb.maxX, bb.maxY, bb.maxZ);
+        Coords min = new Coords(bb.getMinX(), bb.getMinY(), bb.getMinZ());
+        Coords max = new Coords(bb.getMaxX(), bb.getMaxY(), bb.getMaxZ());
         return BoundingBoxCuboid.from(min, max, type);
     }
 
-    void process(Map<String, StructureStart> structures) {
+    void process(Map<String, StructureStart<?>> structures) {
         if (structures.size() > 0) {
-            supportedStructures.forEach(type -> addStructures(type, structures));
+            supportedStructures.forEach(type -> addStructures(type, structures.get(type.getName())));
         }
     }
 }