-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.8, Minecraft 1.8.8, Minecraft 15w43a, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.4, Minecraft 16w21a, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12 Pre-Release 2, Minecraft 1.12.2, Minecraft 18w16a, Minecraft 1.13, Minecraft 18w30b, Minecraft 1.13.2, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w08b, Minecraft 19w09a, 1.14.4, 19w34a, 19w44a, 1.15 Pre-release 1, 1.15.2, 20w12a, 20w13b, 20w15a, 20w17a, 20w19a, 20w20b, 20w21a, 20w22a, 1.16 Pre-release 3, 1.16 Pre-release 5, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4 Pre-release 2, 20w46a, 20w48a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w06a, 21w07a, 21w08b, 21w11a, 21w17a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 3, 1.17 Pre-release 4, 1.17 Pre-release 5, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1 Pre-release 3, 1.17.1 Release Candidate 1, 1.17.1 Release Candidate 2, 1.17.1, 21w38a, 21w39a, 21w40a, 21w41a, 21w42a, 21w43a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 7, 1.18, 1.18.1, 22w03a, 22w05a, 22w06a, 22w07a, 1.18.2 Release Candidate 1, 1.18.2, 22w12a, 22w14a, 22w17a, 22w18a, 1.19, 1.19.1, 1.19.2, 22w42a, 22w43a, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2 Pre-release 2, 1.20.4, 23w51b, 24w11a, 1.20.6, 24w19b, 1.21, 1.21.1, 24w35a, 1.21.3
-
Confirmed
-
Mob behaviour
-
Normal
-
Gameplay
The Bug:
Snow golems attack creepers.
Steps to Reproduce:
- Summon a snow golem and a creeper by using the commands provided below.
/summon minecraft:snow_golem ~-3 ~ ~
/summon minecraft:creeper ~3 ~ ~
- Wait around ten seconds or so for the snow golem to notice the creeper.
- Take note as to whether or not snow golems attack creepers.
Observed Behavior:
Snow golems attack creepers.
Expected Behavior:
Snow golems would not be able to attack creepers.
Code Analysis:
Code analysis by Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.
public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { ... protected void registerGoals() { ... this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, (livingEntity) -> { return livingEntity instanceof Enemy; })); } ...
If we look at the above class, we can see that snow golems are designed to attack any living entity that is considered an enemy. A creeper is considered a monster and a monster is considered an enemy, therefore allowing snow golems to attack creepers. The game doesn't check if the said entity is a creeper before allowing a snow golem to attack it, therefore resulting in this problem occurring.
Fix:
Simply allowing snow golems to override the canAttackType() method located within the Mob.java class to make it so that they cannot attack creepers will resolve this problem. The following lines of code can be added somewhere within the SnowGolem.java class to fix this issue.
public boolean canAttackType(EntityType<?> entityType) { return entityType != EntityType.CREEPER && super.canAttackType(entityType); }
- is duplicated by
-
MC-201890 Snow Golems Attack Creepers
- Resolved
-
MC-248924 Snow Golems fighting Creepers
- Resolved
-
MC-263649 Creepers explode from snow golems
- Resolved
- relates to
-
MCPE-102634 Snow golems attack creepers
- Open
-
MC-61844 Creepers target Iron Golems, causing terrain damage without interaction of a player
- Resolved