Skip to content

Commit

Permalink
Check if a chunk is loaded while replacing. May fix crash 2 in #22
Browse files Browse the repository at this point in the history
  • Loading branch information
DaFuqs committed Nov 4, 2021
1 parent fb31e52 commit bdccb37
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit bdccb37

Please sign in to comment.