mojira.dev
MC-179815

Data command doesn't remove leash from a mob

By adding a lead to a mob (with item or with command) a leash appears.

What I expected to happen was...:

By removing the leash with data, The leash is removed

What actually happened was...:
But when I remove it with the following command the leash is always here (in data of the entity and visually)

Steps to Reproduce:

✔ add the leash (or with item):

execute as @e[type=!player,distance=..10] at @s run data modify entity @s Leash.UUID set from entity @p[distance=..40] UUID

❌ remove the leash:

execute as @e[type=!player,distance=..10] run data remove entity @s Leash

Update 1.16: the UUID system has changed in 1.16

Related issues

Attachments

Comments

migrated
[media]
Avoma

Can confirm in 20w51a.

EchoBlade

I apologize for the edit spam, the formatting keeps getting messed up by all the brackets.

Can confirm in 1.18.1 and 1.18.2-pre3. This seems to be a larger issue with the /data command, I cannot remove data tags or replace them at all, and sometimes it copies tags or changes unrelated tags in unexpected ways. I suggest renaming the ticket to "/data command does not behave properly when modifying or removing tags".

I summoned a villager using the command /summon villager ~ ~ ~ {Inventory:[{id:"minecraft:potato",Count:7b}],NoAI:1}, and tried modifying its entity data using several commands. After each one, I checked its data using the command /data get entity @e[type=villager,limit=1,sort=nearest] Inventory. Here are my results:

Replacing the Inventory array with an empty array: /data modify entity @e[type=villager,limit=1,sort=nearest] Inventory set value [] (Villager has the following entity data: [{id:"minecraft:potato",Count:7b}], No change)

Removing the first item in the Inventory array: /data remove entity @e[type=villager,limit=1,sort=nearest] Inventory[0] (Villager has the following entity data: [{id:"minecraft:potato",Count:7b}], No change)

Removing the Inventory tag: /data remove entity @e[type=villager,limit=1,sort=nearest] Inventory (Villager has the following entity data: [{id:"minecraft:potato",Count:7b}], No change)

Replacing the id of the item with wheat seeds: /data modify entity @e[type=villager,limit=1,sort=nearest] Inventory[0].id set value "minecraft:wheat_seeds" (Villager has the following entity data: [{id:"minecraft:potato",Count:7b},{id:"minecraft:wheat_seeds",Count:7b}]), Somehow duplicated the first array item with a changed id instead)

Changing the Count of the first item to 1b: /data modify entity @e[type=villager,limit=1,sort=nearest] Inventory[0].Count set value 1b (Villager has the following entity data: [{id:"minecraft:potato",Count:8b},{id:"minecraft:wheat_seeds",Count:14b}]), Somehow the Count of both array items changed by random amounts)

tryashtar

Please revert your changes to make this report only about leads again. The issue with villager inventories has already been addressed in MC-112826

migrated

Until this gets fixed, you can leash the wanted mob to itself and it will act as a non-leashed mob in every way except dropping the lead on death.

Command:

/execute as <entity> run data modify entity @s Leash.UUID set from entity @s UUID

migrated

Can confirm for 1.19.2.

migrated
migrated

Can confirm for 1.19.4.

Until this is fixed, another possible solution is to set the Leash UUID to a faraway entity (in a forceloaded chunk, for example) which will automatically break the Lead.

migrated

slicedlime

Confirmed

Platform

Normal

Commands

/data, data, lead, leash

1.15.2, 1.16.2, 1.16.4, 20w51a, 1.17.1, ..., 1.18.2 Pre-release 3, 1.19.1, 1.19.2, 1.19.4, 1.20.2

1.21.4 Pre-Release 1

Retrieved