When wolves are leashed, their NBT home_pos and home_radius properties are set. When the player unleashes them, these properties are cleared.
When they are dragged into a nether portal, however, the leash breaks but these properties are not cleared, making them stop reacting and attacking all other monsters until they are edited with /data remove entity @e[type=wolf,limit=1,sort=nearest] home_radius, or they are leashed and unleashed by the player.
How to replicate, step by step:
Build a nether portal
Spawn a wolf and tame it
Use
/data get entity @e[type=wolf,sort=nearest,limit=1] home_radiusto confirm the entity does not have this property.Attack a nearby enemy. The wolf will attack as expected.
Leash the wolf.
/data get entity @e[type=wolf,sort=nearest,limit=1] home_radiusnow returns 5Pass through the portal so the wolf follows you, teleporting to the nether while still being leashed. The leash breaks, but the property is not cleared.
Access the nether through the same portal
/data get entity @e[type=wolf,sort=nearest,limit=1] home_radiusstill returns 5.Attack a nearby enemy. The wolf will NOT attack.
Leash and unleash the wolf, or use
/data remove entity @e[type=wolf,limit=1,sort=nearest] home_radiusto reset its home position.The wolf AI starts working again, attacking the mob as expected.
/data get entity @e[type=wolf,sort=nearest,limit=1] home_radiusnow returns “not found” as it should.
Linked issues
Comments 3
@Vyoejp I don’t think they are the same bug.
In MC-307069, despite the wolf stops attacking mobs after a world reload, they’ll attack again if you hit another mob. They simply forget the target.
In this bug, however, hitting another mob will not make the wolf attack. It is a persistent AI behaviour flag that can only be solved by changing the NBT fields or leash+unleashing them.
More technical information and why the bug is happening:
The reason wolves do not attack seems to be caused by
net.minecraft.world.entity.ai.goal.target.TargetGoal.canAttackchecking ifthis.mob.isWithinHome(target).
If the target (the enemy) is not within the bounding boxes defined by its home and radius position (and after travelling to the nether, it’s highly unlikely), the wolf simply does nothing.The reason why their
home_radiusandhome_posare not unset despite being unleashed is the order of operations in which the teleport occurs innet.minecraft.world.entity.Entity.teleportCrossDimension:A new Entity
copyis created in the destination worldcopy.restoreFrom(this)is called, which copies all NBT properties of the entity. At this point the entity still has the home position set.this.removeAfterChangingDimensions()is called which unleashes the entity and clears the home position.
The solution is very simple: the unleash operation should be performed in the teleportCrossDimension method BEFORE calling copy.restoreFrom(this).
Refers to https://report.bugs.mojang.com/servicedesk/customer/portal/2/MC-307069