The bug
Sculk catalysts bloom upon destroying armor stands near them.
To reproduce
Place a Sculk Catalyst and an armor stand and destroy the armor stand.
Observed result
The catalyst blooms.
Expected result
The catalyst would not bloom.
Code analysis
Code analysis by @unknown can be found in this comment and a potential fix by @unknown can be found in this comment.
Linked issues
relates to 1
Attachments
Comments 4
Code analysis (Mojang mappings, 22w17a): SculkCatalystBlockEntity#handleGameEvent(...)
controls the sculk catalyst activation, and checks if the game event is an entity dying and if the entity is a LivingEntity
. Armor stands are LivingEntity
s, so the sculk catalyst is activated.
I'm aware that a code analysis has already been conducted but I've done another one that is basically the same as @unknown's for the purpose of reinforcing and providing context for my proposed fix.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.
net.minecraft.world.level.block.entity.SculkCatalystBlockEntity.java
public class SculkCatalystBlockEntity extends BlockEntity implements GameEventListener {
...
public boolean handleGameEvent(ServerLevel serverLevel, GameEvent.Message message) {
if (this.isRemoved()) {
return false;
} else {
GameEvent.Context gameevent$context = message.context();
if (message.gameEvent() == GameEvent.ENTITY_DIE) {
Entity $$4 = gameevent$context.sourceEntity();
if ($$4 instanceof LivingEntity) {
LivingEntity livingentity = (LivingEntity)$$4;
if (!livingentity.wasExperienceConsumed()) {
...
livingentity.skipDropExperience();
SculkCatalystBlock.bloom(serverLevel, this.worldPosition, this.getBlockState(), serverLevel.getRandom());
}
return true;
}
}
return false;
}
}
...
If we look at the above class, we can see that are three necessary checks that are carried out before allowing a sculk catalyst to bloom. One of these checks is to see if the game event is an entity dying; the next is to check if the entity dying is a living entity, and the final one is to check if their experience was consumed. If these three requirements are met, the sculk catalyst blooms. The game doesn't check to see if the living entity is an armor stand before allowing a sculk catalyst to bloom, therefore resulting in this problem occurring.
Fix:
Simply altering the existing "if" statement within this piece of code to check if the living entity is an armor stand before allowing a sculk catalyst to bloom will resolve this problem.
Current "if" statement:
if (!livingentity.wasExperienceConsumed())
Fixed "if" statement:
if (!livingentity.wasExperienceConsumed() && !(livingentity instanceof ArmorStand))
I can confirm this behavior. This doesn't seem to affect other non-biological entities such as boats, minecarts, item frames, etc...