mojira.dev
MC-249454

Sculk Catalysts will spread sculk if a baby mob that does not drop experience dies around it

The bug

While I was testing things with the sculk catalyst, I had noticed that killing baby animals caused the catalyst to spread sculk even though they don't drop any experience.

Expected result

Baby mobs dying wouldn't spread sculk, since they don't drop experience.

Code analysis

Code analysis can be found in this comment.

Attachments

Comments 3

Code analysis (Mojang mappings, 22w12a):
The logic for sculk catalysts spreading sculk can be found in SculkCatalystBlockEntity#handleGameEvent(...). In order to spread sculk, it gets the mob's experience reward, but there is no check to see if the entity should drop experience (that is, if it is not a baby):

if ($$1 == GameEvent.ENTITY_DYING && $$2 instanceof LivingEntity) {
            LivingEntity $$4 = (LivingEntity)$$2;
            if (!$$4.wasExperienceConsumed()) {
                this.sculkSpreader.addCursors(new BlockPos($$3), $$4.getExperienceReward());
                $$4.skipDropExperience();
                SculkCatalystBlock.bloom($$0, this.worldPosition, this.getBlockState(), $$0.getRandom());
            }
            return true;
        }
        return false;
if ($$1 == GameEvent.ENTITY_DYING && $$2 instanceof LivingEntity) {
            LivingEntity $$4 = (LivingEntity)$$2;
            if (!$$4.wasExperienceConsumed()) {
                this.sculkSpreader.addCursors(new BlockPos($$3), $$4.getExperienceReward());
                $$4.skipDropExperience();
                SculkCatalystBlock.bloom($$0, this.worldPosition, this.getBlockState(), $$0.getRandom());
            }
            return true;
        }
        return false;

A flawed fix would be replacing

if (!$$4.wasExperienceConsumed())
if (!$$4.wasExperienceConsumed())

with

if (!$$4.wasExperienceConsumed() && $$4.shouldDropExperience())
if (!$$4.wasExperienceConsumed() && $$4.shouldDropExperience())

However, this would cause a new issue: baby zombies drop 2.5 times more experience than regular zombies, and they would not cause sculk conversion with this change.

Isn't this consistent with other deaths that don't drop XP, such as non-player kills and frogs eating slimes (MC-249255)?

Yes, but in those cases if the player killed them they would have dropped experience, whereas most baby mobs don't drop experience when the player kills them.

matthewdog6

migrated

Confirmed

Normal

Block states

sculk-catalyst

22w12a, 22w13a, 22w14a, 22w16b, 22w17a

22w18a

Retrieved