Skip to content

Commit

Permalink
fix crash with empty structures
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Jul 31, 2024
1 parent 9d4bce5 commit 70369cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.gradle.configureondemand=true
# Enable advanced multi-module optimizations (share tiny-remaper instance between projects)
fabric.loom.multiProjectOptimisation=true
# Mod Properties
baseVersion = 0.6.17
baseVersion = 0.6.18
defaultBranch = 1.20
branch = 1.20
2 changes: 1 addition & 1 deletion src/main/java/folk/sisby/surveyor/Surveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void checkStructureExploration(ServerWorld world, ServerPlayerEnti
Structure structure = structureRegistry.get(structureKey);
StructureStart start = world.getChunk(startPos.x, startPos.z, ChunkStatus.STRUCTURE_STARTS).getStructureStart(structure);
boolean found = false;
if (start.getBoundingBox().contains(pos)) {
if (start.hasChildren() && start.getBoundingBox().contains(pos)) {
for (StructurePiece piece : start.getChildren()) {
if (piece.getBoundingBox().expand(2).contains(pos)) {
exploration.addStructure(world.getRegistryKey(), structureKey, start.getPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public void put(ServerWorld world, StructureStart start) {
ChunkPos rPos = regionPosOf(start.getPos());
RegistryKey<Structure> key = world.getRegistryManager().get(RegistryKeys.STRUCTURE).getKey(start.getStructure()).orElseThrow();
Optional<RegistryKey<StructureType<?>>> type = world.getRegistryManager().get(RegistryKeys.STRUCTURE_TYPE).getKey(start.getStructure().getType());
if (!start.hasChildren()) {
Surveyor.LOGGER.error("Cowardly refusing to save structure {} as it has no pieces! Report this to the structure mod author!", key.getValue());
return;
}
if (type.isEmpty()) {
Surveyor.LOGGER.error("Cowardly refusing to save structure {} as it has no structure type! Report this to the structure mod author!", key.getValue());
return;
Expand Down

0 comments on commit 70369cd

Please # to comment.