Improve PathRegion.calculateGardenState

This commit is contained in:
2026-03-25 14:06:12 +01:00
parent ef3d1b3c95
commit 5211ad0e6b
2 changed files with 12 additions and 14 deletions
@@ -1,6 +1,9 @@
{ {
"region_identifier": "SpawnRegion", "region_identifier": "SpawnRegion",
"tiles": [ "tiles": [
{ "tile_x": 0, "tile_z": 0 } {
"tile_x": 0,
"tile_z": 0
}
] ]
} }
@@ -29,7 +29,9 @@ import lombok.NonNull;
import org.bukkit.Material; import org.bukkit.Material;
import java.io.IOException; import java.io.IOException;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@RegionConstructorData( @RegionConstructorData(
identifier = "path", identifier = "path",
@@ -81,19 +83,12 @@ public class PathRegion extends DynamicRegion {
public void calculateGardenState() { public void calculateGardenState() {
garden = false; garden = false;
for (int x = -1; x <= 1; x++) { Set<Tile> neighbours = tile.neighboursRing().collect(Collectors.toSet());
for (int z = -1; z <= 1; z++) { if (neighbours.size() == 8) return;
if (x == 0 && z == 0) continue; garden = neighbours.stream()
Tile t = tile.add(x, z).orElse(null); .map(DynamicRegionSystem.INSTANCE::get)
if (t == null) { .map(Region::getType)
return; .allMatch(RegionType::isPath);
}
if (!DynamicRegionSystem.INSTANCE.get(t).getType().isPath()) {
return;
}
}
}
garden = true;
} }
@Override @Override