mojira.dev
MC-110424

Vexes do not actively attack iron golems when vexes are spawned by spawn egg, monster spawner, trial spawner or "/summon" command

Vexes do not actively attack iron golems when vexes are spawned by spawn egg, monster spawner, trial spawner or "/summon" command.
But will take the active to attack the players.

Code Analysis

Code Analysis done by @unknown
Currently the Vex has no NearestAttackableTargetGoal for villager. wandering trader and iron golem. Addind a goel for each fixes this bug.

Current Code

net/minecraft/world/entity/monster/Vex.java

protected void registerGoals() {
      super.registerGoals();
      this.goalSelector.addGoal(0, new FloatGoal(this));
      this.goalSelector.addGoal(4, new Vex.VexChargeAttackGoal());
      this.goalSelector.addGoal(8, new Vex.VexRandomMoveGoal());
      this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 3.0F, 1.0F));
      this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F));
      this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, Raider.class)).setAlertOthers());
      this.targetSelector.addGoal(2, new Vex.VexCopyOwnerTargetGoal(this));
      this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, true));

   }

Fixed Code

net/minecraft/world/entity/monster/Vex.java

protected void registerGoals() {
      super.registerGoals();
      this.goalSelector.addGoal(0, new FloatGoal(this));
      this.goalSelector.addGoal(4, new Vex.VexChargeAttackGoal());
      this.goalSelector.addGoal(8, new Vex.VexRandomMoveGoal());
      this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 3.0F, 1.0F));
      this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F));
      this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, Raider.class)).setAlertOthers());
      this.targetSelector.addGoal(2, new Vex.VexCopyOwnerTargetGoal(this));
      this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, true));
      //Add an attackable target goal for iron golem to fix MC-110424
      this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
   }

Linked issues

Attachments

Comments 6

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 21w06a.

Can confirm in 21w07a.

The instance with the Iron Golem is probably a bug, however Vexes not attacking Villagers and Wandering Traders is absolutely intended so that raids are not impossible because Vexes can attack the Villagers through walls, because that would make it extremely difficult to hide them and keep the raid going.

[Mod]Les3awe

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour

attack, command, spawn, spawn_egg, vex, villager

Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13a, ..., 1.21.5, 25w17a, 1.21.6 Pre-Release 3, 1.21.8, 25w34b

Retrieved