From bdccb376124b9f90d3ec7afa9fc473e00fd76e6a Mon Sep 17 00:00:00 2001 From: DaFuqs Date: Thu, 4 Nov 2021 09:30:25 +0100 Subject: [PATCH] Check if a chunk is loaded while replacing. May fix crash 2 in #22 --- .../lootcrates/worldgen/LootCratesWorldgenReplacer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dafuqs/lootcrates/worldgen/LootCratesWorldgenReplacer.java b/src/main/java/de/dafuqs/lootcrates/worldgen/LootCratesWorldgenReplacer.java index 00fa75c..60fce6d 100644 --- a/src/main/java/de/dafuqs/lootcrates/worldgen/LootCratesWorldgenReplacer.java +++ b/src/main/java/de/dafuqs/lootcrates/worldgen/LootCratesWorldgenReplacer.java @@ -283,7 +283,7 @@ public static void tick(MinecraftServer server) { for (LootCrateReplacementPosition replacementPosition : list) { try { ServerWorld serverWorld = server.getWorld(replacementPosition.worldKey); - if (serverWorld != null) { + if (serverWorld != null && serverWorld.isChunkLoaded(replacementPosition.blockPos)) { BlockEntity blockEntity; try { blockEntity = serverWorld.getBlockEntity(replacementPosition.blockPos); @@ -339,6 +339,8 @@ public static void tick(MinecraftServer server) { } } } + } else { + LootCrates.LOGGER.error("[LootCrates] Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "' ). The chunk at that pos is not loaded."); } } catch (Exception e) { LootCrates.LOGGER.error("[LootCrates] Error while replacing a container with loot table '" + replacementPosition.lootTable + "' in the world '" + replacementPosition.worldKey + "' at '" + replacementPosition.blockPos + "' ) + " + e.getLocalizedMessage());