Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-80956

/entitydata outputs success message on invalid NBT tags

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • Minecraft 1.8.6, Minecraft 15w51b
    • Windows 7 Home Premium
      Java 1.8.0_25 64bit
    • Confirmed

      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()});
      }
      

        1. 2015-06-04_04.23.27.png
          595 kB
          Mario Welzig
        2. 2015-06-04_04.23.37.png
          595 kB
          Mario Welzig
        3. NBTbug.png
          792 kB
          Mario Welzig

            searge [Mojang] Searge (Michael Stoyke)
            Mario Welzig Mario Welzig
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: