Mojira Archive
MC-80956

/entitydata outputs success message on invalid NBT tags

When trying to change an invalid tag of an entity via the /entitydata command, it won't output an error message, but instead display the alleged new NBT data, including the invalid tag.

/entitydata @e[type=!Player,c=1] {SomeInvalidTag:1}

However, executing

/entitydata @e[type=!Player,c=1] {}

afterwards will show that the tag wasn't actually applied (because entities aren't capable of actually storing it).

Solution

net.minecraft.command.CommandEntityData.processCommand(ICommandSender, String[])
NBTTagCompound nbttagcompound = new NBTTagCompound();
entity.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttagcompound.copy();
NBTTagCompound nbttagcompound2;

try {
    nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 1).getUnformattedText());
}
catch(NBTException nbtexception) {
    throw new CommandException("commands.entitydata.tagError", new Object[] {nbtexception.getMessage()});
}

nbttagcompound2.removeTag("UUIDMost");
nbttagcompound2.removeTag("UUIDLeast");
nbttagcompound.merge(nbttagcompound2);

if(nbttagcompound.equals(nbttagcompound1)) {
    throw new CommandException("commands.entitydata.failed", new Object[] {nbttagcompound.toString()});
}
else {
    entity.readFromNBT(nbttagcompound);
    // The following lines were changed
    NBTTagCompound nbttagcompound3 = new NBTTagCompound();
    entity.writeToNBT(nbttagcompound3);
    if(nbttagcompound3.equals(nbttagcompound1)) {
        throw new CommandException("commands.entitydata.failed", new Object[] {nbttagcompound3.toString()});
    }
    notifyOperators(sender, this, "commands.entitydata.success", new Object[] {nbttagcompound3.toString()});
}

Works As Intended

Mario Welzig

[Mojang] Searge (Michael Stoyke)

2015-06-04, 05:32 AM

2017-05-09, 10:19 PM

2016-01-13, 03:54 PM

0

5

Confirmed

/entitydata, NBT

Minecraft 1.8.6, Minecraft 15w51b

-