From 6a4c021b8b097b3073308fcfdbc30ae9bb9b90b3 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 6 Mar 2026 20:40:38 +0100 Subject: [PATCH] Fix DynamicRegion.updateNeighbours --- .../region/dynamic/DynamicRegion.java | 17 +++++++--- .../region/dynamic/path/PathRegion.java | 33 +++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/DynamicRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/DynamicRegion.java index 30e488d9..6c367825 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/DynamicRegion.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/DynamicRegion.java @@ -23,9 +23,12 @@ import de.steamwar.bausystem.region.DynamicRegionSystem; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionData; +import de.steamwar.bausystem.region.dynamic.path.PathRegion; +import de.steamwar.bausystem.shared.Pair; import lombok.Getter; import lombok.NonNull; +import java.util.List; import java.util.UUID; public abstract class DynamicRegion implements Region { @@ -49,14 +52,18 @@ public abstract class DynamicRegion implements Region { public abstract void init(); public final void updateNeighbours() { - DynamicRegionSystem.INSTANCE.getNeighbours(this) - .forEach(data -> { - data.getKey().update(this, data.getValue().opposite()); - }); + List> list = DynamicRegionSystem.INSTANCE.getNeighbours(this).toList(); + list.forEach(data -> { + if (data.getKey() instanceof PathRegion pathRegion) { + pathRegion.calculateGardenState(); + } + }); + list.forEach(data -> { + data.getKey().update(this, data.getValue().opposite()); + }); } public void update(DynamicRegion updateFrom, NeighbourDirection direction) { - // TODO: Implement further } public void setRegionData(@NonNull RegionData regionData) { diff --git a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java index 3235853a..fbe78c7e 100644 --- a/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java +++ b/BauSystem/BauSystem_RegionDynamic/src/de/steamwar/bausystem/region/dynamic/path/PathRegion.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.region.dynamic.path; import de.steamwar.bausystem.region.*; import de.steamwar.bausystem.region.dynamic.*; import de.steamwar.sql.GameModeConfig; +import lombok.Getter; import lombok.NonNull; import org.bukkit.Material; @@ -50,7 +51,6 @@ public class PathRegion extends DynamicRegion { @Override public void update(DynamicRegion updateFrom, NeighbourDirection direction) { - gardenCache = null; for (PathSide side : direction.getSideUpdates()) { area.reset(side); } @@ -59,27 +59,24 @@ public class PathRegion extends DynamicRegion { } } - private Boolean gardenCache = null; + @Getter + private boolean garden = false; - public boolean isGarden() { - if (gardenCache == null) { - 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) { - gardenCache = false; - return false; - } - if (!DynamicRegionSystem.INSTANCE.get(t).getType().isPath()) { - gardenCache = false; - return false; - } + 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; } } - gardenCache = true; } - return gardenCache; + garden = true; } @Override