mojira.dev
MC-179072

Creepers do not defuse when switching from Survival to Creative/Spectator

The bug

So whenever I go into creative mode and there is a creeper nearby it explodes. I was just testing an automated music disc farm, and when I went back into creative mode to get my stuff the creepers that weren't killed exploded for some reason. I am very confused right now..... ._.

Code analysis

Code analyses can be found in this comment by @unknown and this comment by @unknown.

Linked issues

Attachments

Comments 7

They were ignited, and continued to try to explode you

I died in creative mode for some reason, but it only happened once though.

thcrafter06 And I died in spectator mode after switching from survival to spectator mode right when I falled from too high in Survival

Can confirm in 21w03a.

Can confirm in 1.17.

Can confirm on 1.18.2

Code analysis

Based on 1.18.2 yarn mappings

CreeperIgniteGoal

@Override
public void tick() {
    if (this.target == null) { 
        this.creeper.setFuseSpeed(-1);
    } else if (this.creeper.squaredDistanceTo(this.target) > 49.0) {
        this.creeper.setFuseSpeed(-1);
    } else if (!this.creeper.getVisibilityCache().canSee(this.target)) {
        this.creeper.setFuseSpeed(-1);
    } else {
        this.creeper.setFuseSpeed(-1);
    }

This function does not check if the target can take damage.

 

This can be easily fixed by adding a `canContinueToUse()` override to `SwellGoal` pathfinder goal.

Using mojang's 1.19.2 mappings.

@Override
public boolean canContinueToUse() {
    return !EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(this.creeper.getTarget()) && canUse();
}

Sam k

(Unassigned)

Confirmed

Mob behaviour

1.15.2, 1.16 Pre-release 2, 1.16.1, 1.16.3, 1.16.4 Pre-release 2, ..., 1.19.4, 1.20 Release Candidate 1, 1.20, 1.20.1, 1.21.3

Retrieved