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",
"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 java.io.IOException;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@RegionConstructorData(
identifier = "path",
@@ -81,19 +83,12 @@ public class PathRegion extends DynamicRegion {
public void calculateGardenState() {
garden = false;
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
if (x == 0 && z == 0) continue;
Tile t = tile.add(x, z).orElse(null);
if (t == null) {
return;
}
if (!DynamicRegionSystem.INSTANCE.get(t).getType().isPath()) {
return;
}
}
}
garden = true;
Set<Tile> neighbours = tile.neighboursRing().collect(Collectors.toSet());
if (neighbours.size() == 8) return;
garden = neighbours.stream()
.map(DynamicRegionSystem.INSTANCE::get)
.map(Region::getType)
.allMatch(RegionType::isPath);
}
@Override