Skip to content

Commit 03477a0

Browse files
committed
Check again virtual wild when querying properties
1 parent f6bd7d9 commit 03477a0

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/main/java/org/teacon/areacontrol/api/AreaControlAPI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public Area findBy(String dimKey, double x, double y, double z) {
2525
public Area findBy(String dimKey, int x, int y, int z) {
2626
throw new IllegalStateException("Not initialized yet!");
2727
}
28+
29+
@Override
30+
public @Nullable Area getVirtualWild() {
31+
throw new IllegalStateException("Not initialized yet!");
32+
}
2833
};
2934

3035
public static GroupProvider groupProvider = new GroupProvider() {

src/main/java/org/teacon/areacontrol/api/AreaLookup.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ public interface AreaLookup {
1414

1515
@Nullable
1616
Area findBy(String dimKey, int x, int y, int z);
17+
18+
@Nullable
19+
Area getVirtualWild();
1720
}

src/main/java/org/teacon/areacontrol/api/AreaProperties.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ public static Optional<Boolean> getBoolOptional(@Nullable Area area, String key)
8282
}
8383

8484
public static Optional<Boolean> getBoolOptional(@Nullable Area area, String key, boolean recursive) {
85-
if (area == null) return Optional.empty();
85+
if (area == null) {
86+
Area virtualWild = AreaControlAPI.areaLookup.getVirtualWild();
87+
if (virtualWild == null) {
88+
return Optional.empty();
89+
}
90+
area = virtualWild;
91+
recursive = false;
92+
}
8693
Object o = area.properties.get(key);
8794
if (o == null || "null".equals(o)) {
8895
if (recursive) {

src/main/java/org/teacon/areacontrol/impl/AreaLookupImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.resources.ResourceKey;
66
import net.minecraft.resources.ResourceLocation;
77
import net.minecraft.world.level.Level;
8+
import org.jetbrains.annotations.Nullable;
89
import org.teacon.areacontrol.AreaManager;
910
import org.teacon.areacontrol.api.Area;
1011
import org.teacon.areacontrol.api.AreaLookup;
@@ -39,4 +40,10 @@ public Area findBy(String dimKey, int x, int y, int z) {
3940
var dimResKey = this.getOrCreate(dimKey);
4041
return AreaManager.INSTANCE.findBy(dimResKey, new BlockPos(x, y, z));
4142
}
43+
44+
@Override
45+
public @Nullable Area getVirtualWild() {
46+
return AreaManager.INSTANCE.getVirtualWild();
47+
}
48+
4249
}

0 commit comments

Comments
 (0)