mojira.dev
MCPE-46240

Player-made iron golems run away from villages

Updated description by @unknown

Steps to reproduce

  1. Stand in a village (1 villager and 1 claimed bed is enough).

  2. Spawn an iron golem using iron blocks and a carved pumpkin/Jack-o-Lantern.

  3. Observer the iron golem for a while.

Expected result

The iron golem patrols the village, staying within a certain distance of its center.

Actual result

The iron golem wanders without regard for the village and eventually wanders far away.


Original description
Iron Golems are constantly running away from the villages I spawn them in. It seems their AI doesn't recognize the new villages, because instead of guarding and patrolling the new village, they run, somewhat erratically, all over the place until they leave the village and get lost. This has happened on multiple occasions, in different worlds I've created.

Other than this, the iron golems seem to behave perfectly normal. They kill mobs as normal, avoid water and everything else. It just seems they can't recognize the new villages as places they are supposed to protect. Also, every iron golem this has happened to has been spawned by myself, and I've only played in creative mode, if that means something.

Linked issues

MCPE-163209 The considerable remoteness of the Iron Golems from the villages. Resolved MCPE-45510 Iron Golems not returning to village center. Resolved MCPE-46132 Iron golems leaving Resolved MCPE-48894 Iron golem not staying in artificial village Resolved MCPE-50909 Village Iron Golems Wander off/despawn after a few minutes Resolved

Attachments

Comments 20

1 tip, you may need a bell to indicate the 'village center.' I think technically it's not a village without a bell.

I thought that too, but it turns out the presence of a bell doesn't make any difference in this situation. I tested this both with and without bells present in the village, and the iron golem always ran away. 

In fact, in those pictures I posted there is a bell present at the house, though it was obstructed from view. This seems to happen in every village of mine, and these villages do meet the parameters of at least 1 villager, 1 workstation, 1 bed, and 1 bell. Iron golems have even ran away from villages with around 14 villagers and 2 bells present. 

I've just added a picture of the aforementioned village, notice how I've leashed the iron golems to fence posts to keep them from running away.

Seems problematic. One thing I could suggest, try ringing the bell. If you can't interact with it, it's not valid.

The bells ring correctly, and villagers do respond to them. All of the villages this happens in do seem to be recognized as true villages. I used the locate command to find a village, it takes me to that village. 

Bad Omen effects also cause raids when I enter these villages, so they are true legitimate villages. 

The problem seems based in the Iron Golems AI. I don't recall this being a problem before the release of 1.11, "Village and Pillage." Perhaps the Iron Golems weren't correctly updated to recognize the new villages.   

I've been wondering, has anyone experienced something similar to this, or been able to reproduce this bug? 

Or is this a local, isolated bug?

10 more comments

Hi. Could you please explain why is this expected behavior?

Questions like that should be addressed to Mojang community mangers or developers, whom you might be able to find on Twitter or in various Discord servers. The moderators on the bug tracker are volunteers and do not have access to Mojang's internal deliberations and design decisions.

Can Confirm for the lastest 1.21.130 Release

I don't know why this is marked as WAI which is not supposed to happen as Player-built Iron Golems DO NOT wander away on Java Edition but I found the core Issue, and it is an easy fix.

},

"component_groups": {

"minecraft:player_created": {

"minecraft:behavior.hurt_by_target": {

"priority": 2,

"entity_types": {

"filters": {

"all_of": [

{ "test": "is_family", "subject": "other", "operator": "not", "value": "player" },

{ "test": "is_family", "subject": "other", "operator": "not", "value": "creeper" }

]

}

}

}

},

"minecraft:village_created": {

"minecraft:behavior.defend_village_target": {

"priority": 1,

"must_reach": true,

"attack_chance": 0.05,

"entity_types": {

"filters": {

"any_of": [

{ "test": "is_family", "subject": "other", "value": "mob" },

{ "test": "is_family", "subject": "other", "value": "player" }

]

}

}

},

"minecraft:dweller": {

"dwelling_type": "village",

"dweller_role": "defender",

"update_interval_base": 60,

"update_interval_variant": 40,

"can_find_poi": false,

"can_migrate": true,

"first_founding_reward": 0

}

}

See how the “minecraft:village_created” block contains this portion:

},

"minecraft:dweller": {

"dwelling_type": "village",

"dweller_role": "defender",

"update_interval_base": 60,

"update_interval_variant": 40,

"can_find_poi": false,

"can_migrate": true,

"first_founding_reward": 0

}

}

This block of code is what keeps the Village-created Iron Golems from wandering away from villages. This is what registers them to any Villages they spawn at and also the very code that makes them search for a nearest Village. Now take a look at the block just above the “minecraft:village_created” called “minecraft:player_created”.

},
"component_groups": {
"minecraft:player_created": {
"minecraft:behavior.hurt_by_target": {
"priority": 2,
"entity_types": {
"filters": {
"all_of": [
{ "test": "is_family", "subject": "other", "operator": "not", "value": "player" },
{ "test": "is_family", "subject": "other", "operator": "not", "value": "creeper" }
]
}
}
}

As you can see, The “minecraft:dweller” block is missing. Which is the root-cause of Player-created Iron Golems to wander off from Villages. In short, Player-created Iron Golems do not have the code that automatically registers it to any Village it is spawned in.

The fix is easy, All you need to do is remove the default “minecraft:player_created” block and replace it with this:

},
"component_groups": {
"minecraft:player_created": {
"minecraft:behavior.hurt_by_target": {
"priority": 2,
"entity_types": {
"filters": {
"all_of": [
{ "test": "is_family", "subject": "other", "operator": "not", "value": "player" },
{ "test": "is_family", "subject": "other", "operator": "not", "value": "creeper" }
]
}
}
},
"minecraft:dweller": {
"dwelling_type": "village",
"dweller_role": "defender",
"update_interval_base": 60,
"update_interval_variant": 40,
"can_find_poi": false,
"can_migrate": true,
"first_founding_reward": 0
}

I provided a fix which should stop the Player-created Iron Golems from wandering away from villages or any structures that contains a bell, beds, and villagers.

Sydney Layne

(Unassigned)

201586

Confirmed

Multiple

Android Verson 8.1.0

iron-golem

1.14.2.50 Beta, 1.14.1 Hotfix, 1.11.1, 1.11.3, 1.11.4, 1.12.0, 1.13.0, 1.14.0, 1.14.60 Hotfix

Retrieved