From da87ada3d5b35fce47da128baa917e7ace0a9191 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 14 Oct 2024 19:24:49 +0200 Subject: [PATCH] Prevent BEs that get removed by other mods in-between being loaded and the end of the tick from crashing the game. --- .../java/appeng/hooks/ticking/ServerBlockEntityRepo.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/appeng/hooks/ticking/ServerBlockEntityRepo.java b/src/main/java/appeng/hooks/ticking/ServerBlockEntityRepo.java index cc858ce172f..4e645b74cf0 100644 --- a/src/main/java/appeng/hooks/ticking/ServerBlockEntityRepo.java +++ b/src/main/java/appeng/hooks/ticking/ServerBlockEntityRepo.java @@ -40,7 +40,10 @@ class ServerBlockEntityRepo { record FirstTickInfo(T blockEntity, Consumer initFunction) { void callInit() { - initFunction.accept(blockEntity); + // It's possible the BE has already been removed after it was loaded. We skip initialization in that case. + if (!blockEntity.isRemoved()) { + initFunction.accept(blockEntity); + } } }