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

/entitydata outputs success message on invalid NBT tags

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Works As Intended
    • Affects Version/s: Minecraft 1.8.6, Minecraft 15w51b
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows 7 Home Premium
      Java 1.8.0_25 64bit
    • Confirmation Status:
      Confirmed

      Description

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

        Attachments

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

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: