mojira.dev
MC-165516

Snow Golem, Witch, Llama, Drowned, and Wither will keep attacking after its target is gone if `generic.movement_speed` is 0

Snow Golems will continuously shoot snowballs when its target is dead. Though it can be difficult to replicate it, I have managed to do so in the video attached to this issue.

(The video shows the zombie being teleported instead of dying. In 1.17c1 the snow golem stopped shooting when zombie was teleported away. But when they die they continue to shoot. So video is a little outdated now.) [VIDEO|

[media]

]

 

First Command Block: (note that giving the Snow Golem slowness 150 gets the same results)

/summon minecraft:snow_golem ~ ~1 ~ {Attributes:[{Name:generic.movement_speed,Base:0}]}

Second Command Block:

/summon minecraft:zombie ~ ~1 ~ {Attributes:[{Name:generic.movement_speed,Base:0}]}

Then the zombie gets pushed into a pressure plate that kills him:

execute as @e[type=minecraft:zombie,sort=nearest] run kill @s

 

CODE ANALYSIS

See comment by @unknown here.

Attachments

Comments 7

This is a big issue with my custom game Ive been making. Honestly Snow Golems just need a rework in general.

I would like to take ownership of this bug, as the reporter does not update it as much as they should.

⚠️ Please do not mark Unreleased Versions as affected. You don't have access to them yet.

-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit

⚠️ Please do not mark Unreleased Versions as affected. You don't have access to them yet.

-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit

I am only able to recreate it when using {Name:generic.movement_speed,Base:0}

This code analysis is related to this code analysis
I recommend you read the other one first since I'm not going to repeat myself on some of these points.

This bug is the same problem, the target entity is not set to null, and the snow golem does not check if the entity is still alive. Although the fix for MC-183990 would not fix this bug report.

The reason that this one is different is due to the goal ProjectileAttackGoal having its own target instead of using the entity's target. This is fine, and there is probably a reason for that (Doubt it), although the issue is the fact that when the entity is not idle, it will not check if the target is alive anymore, so it just keeps shooting it.

Code Analysis - (Yarn 22w17a)

net.minecraft.entity.ai.goal.ProjectileAttackGoal.java

public boolean canStart() {
	LivingEntity livingEntity = this.mob.getTarget(); // We get the target from the entity
	if (livingEntity != null && livingEntity.isAlive()) { // Make sure its alive
		this.target = livingEntity;
		return true;
	} else {
		return false;
	}
}

public boolean shouldContinue() {
	// canStart can be false, but if isIdle() is false also, it wont end
	return this.canStart() || !this.mob.getNavigation().isIdle();
}

Working Fix

This affects the following entities:

  • Snow Golem

  • Witch

  • Llama

  • Drowned

  • Wither

Dale Dale

_BOBE

(Unassigned)

Confirmed

Normal

Mob behaviour

drowned, llama, mob-behavior, movementSpeed, snow_golem, targeting, witch, wither

1.14.4, 1.15.2, 20w19a, 1.16.2 Release Candidate 2, 1.16.2, ..., 1.19 Pre-release 1, 1.19 Pre-release 2, 1.19 Pre-release 3, 1.19 Pre-release 4, 1.19

22w24a

Retrieved