mojira.dev
MC-178742

Villager doesn't work correctly after summoning

When I try to spawn a villager with custom trades and profession, the villager spawns with no profession at all. When I try to trade with it, it will sometimes deny the action and sometimes show the trading popup, but hide it immediately afterward. Once the villager gets a profession these problems are fixed, but the custom trades don't persist and new trades are generated. Interestingly, none of this appears to be a problem when I summon the villager with the "NoAI" tag set to true.

Comments 5

What is the exact command you used?

/summon minecraft:villager ~ ~1 ~ {VillagerData:{profession:"minecraft:farmer"},Offers:{Recipes:[{rewardExp:1b,maxUses:5,buy:{id:"minecraft:wheat",Count:20b},sell:{id:"minecraft:emerald",Count:5b}},{rewardExp:1b,maxUses:10,buy:{id:"minecraft:carrot",Count:10b},buyB:{id:"minecraft:emerald",Count:1b},sell:{id:"minecraft:golden_carrot",Count:1b}}]}}

I have confirmed this problem is also present in the latest 1.16 pre-release.

The entity data of the summoned villager does not match the data specified in the command, indicating there was some kind of error while parsing it. Running "data get entity @s" on that villager gives me the following:

 

Villager has the following entity data: {Brain: {memories: {}}, HurtByTimestamp: 0, Attributes: [{Base: 20.0d, Name: "generic.maxHealth"}, {Base: 0.0d, Name: "generic.knockbackResistance"}, {Base: 0.5d, Name: "generic.movementSpeed"}, {Base: 0.0d, Name: "generic.armor"}, {Base: 0.0d, Name: "generic.armorToughness"}, {Base: 48.0d, Name: "generic.followRange"}, {Base: 0.0d, Name: "generic.attackKnockback"}], FoodLevel: 0b, Invulnerable: 0b, FallFlying: 0b, ForcedAge: 0, Gossips: [], PortalCooldown: 0, AbsorptionAmount: 0.0f, LastRestock: 0L, FallDistance: 0.0f, DeathTime: 0s, Xp: 0, LastGossipDecay: 2349L, HandDropChances: [0.085f, 0.085f], PersistenceRequired: 0b, Age: 0, Motion: [-0.052086220830443966d, -0.0784000015258789d, 0.052086220831976296d], UUIDLeast: -7688459738001797146L, Health: 20.0f, LeftHanded: 0b, Air: 300s, OnGround: 1b, Dimension: 0, Rotation: [45.00099f, 0.0f], HandItems: [{}, {}], RestocksToday: 0, ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], UUIDMost: -1815837619462124136L, Pos: [129.93286505644107d, 4.0d, -73.93284670756347d], Fire: -1s, ArmorItems: [{}, {}, {}, {}], CanPickUpLoot: 1b, VillagerData: {profession: "minecraft:none", level: 1, type: "minecraft:plains"}, HurtTime: 0s, Inventory: []}

Villagers who have not been traded with do not keep their profession or trades if they do not have a workstation. If you would like to summon a villager that keeps its trades, set it to apprentice level or higher using VillagerData:{profession:farmer,level:2} or similar.

Ptolemy Henson

(Unassigned)

Unconfirmed

(Unassigned)

1.15.2

Retrieved