@@ -2773,6 +2773,9 @@ public int hollowOutRegion(Region region, int thickness, Pattern pattern, boolea
27732773 // The set of blocks that were seen
27742774 final Set <BlockVector3 > visible = new HashSet <>(startingPositions );
27752775
2776+ // The set of blocks that were not only seen, but entered
2777+ final Set <BlockVector3 > entered = new HashSet <>(startingPositions );
2778+
27762779 // Do BFS to find more visible blocks
27772780 final Queue <BlockVector3 > queue = new ArrayDeque <>(startingPositions );
27782781 while (!queue .isEmpty ()) {
@@ -2814,9 +2817,30 @@ public int hollowOutRegion(Region region, int thickness, Pattern pattern, boolea
28142817 continue ;
28152818 }
28162819
2817- // Mark the block as visible, abort if it already was
2818- if (!visible .add (neighbor )) {
2819- continue ;
2820+ if (useBlockGeometry ) {
2821+ // Mark neighbor as visible
2822+ visible .add (neighbor );
2823+
2824+ // If the neighbor was already entered, we can skip the expensive blocked calculation
2825+ if (entered .contains (neighbor )) {
2826+ continue ;
2827+ }
2828+
2829+ // Check if we can actually enter the block from here
2830+ Direction oppositeDirection = Direction .findClosest (direction .toVector ().multiply (-1 ), Direction .Flag .ALL );
2831+ for (Direction blockedDirection : getBlockedDirections (neighbor )) {
2832+ if (blockedDirection == oppositeDirection ) {
2833+ continue outer ; // skip this direction
2834+ }
2835+ }
2836+
2837+ // Mark neighbor as entered
2838+ entered .add (neighbor );
2839+ } else {
2840+ // Mark the block as visible, abort if it already was
2841+ if (!visible .add (neighbor )) {
2842+ continue ;
2843+ }
28202844 }
28212845
28222846 // And queue it
0 commit comments