From 342a195ba8d25d74043b1c63d9c0aefa333dc626 Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Fri, 3 Apr 2026 19:40:17 +0300 Subject: [PATCH] fix(wither): move livingEntitySelector from static to per-instance Withers were previously using the same static LES pointer (which gets destroyed on death) causing a segfault when another wither is spawned after the first one is dead --- targets/minecraft/world/entity/boss/wither/WitherBoss.cpp | 4 ++-- targets/minecraft/world/entity/boss/wither/WitherBoss.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp b/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp index 2a4dc4b5a..55ada0747 100644 --- a/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp +++ b/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp @@ -51,9 +51,9 @@ bool LivingEntitySelector::matches(std::shared_ptr entity) const { } } -EntitySelector* WitherBoss::livingEntitySelector = new LivingEntitySelector(); - WitherBoss::WitherBoss(Level* level) : Monster(level) { + // 4jcraft: moved to per-instance + livingEntitySelector = new LivingEntitySelector(); // 4J Stu - This function call had to be moved here from the Entity ctor to // ensure that the derived version of the function is called this->defineSynchedData(); diff --git a/targets/minecraft/world/entity/boss/wither/WitherBoss.h b/targets/minecraft/world/entity/boss/wither/WitherBoss.h index 69b1876be..f5880334f 100644 --- a/targets/minecraft/world/entity/boss/wither/WitherBoss.h +++ b/targets/minecraft/world/entity/boss/wither/WitherBoss.h @@ -43,7 +43,8 @@ private: int idleHeadUpdates[IDLE_HEAD_UPDATES_SIZE]; int destroyBlocksTick; - static EntitySelector* livingEntitySelector; + // 4jcraft: moved to per-instance + EntitySelector* livingEntitySelector; public: WitherBoss(Level* level);