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
This commit is contained in:
Sally Knight 2026-04-03 19:40:17 +03:00
parent 63ab8d1b20
commit 342a195ba8
2 changed files with 4 additions and 3 deletions

View file

@ -51,9 +51,9 @@ bool LivingEntitySelector::matches(std::shared_ptr<Entity> 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();

View file

@ -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);