We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

195

/data merge modifying player data

15 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 7
    Registered User commented
    Comment actions Permalink

    this should modify the player data not create a new player

  • 25
    Registered User commented
    Comment actions Permalink

    Totally annoying you can't change player nbt.
    This throws so many ideas right into the trash...

  • 8
    Registered User commented
    Comment actions Permalink

    Earlier I was trying to modify player items, and I found a neat way to do it in 1 command, but it didn't work because of this. I really want Mojang to change this. 

  • 4
    Registered User commented
    Comment actions Permalink

    still can't modify player data in MC Java 1.15.

    I want to transfer my items into a chest, and items from chest into player using command blocks,. 

  • 7
    Registered User commented
    Comment actions Permalink

    There are a few important things:

    1. You should be able to use /data modify and /execute store too. They can do much more useful things than /data merge.
    2. You should be able to modify the player's inventory using these commands. The only option we currently have is to use /replaceitem, but you could do much more with /data, like modifying NBT data of items in the player's inventory (you could use that to add/remove some durability, add enchantments, etc.). You could theoretically transfer the player's items into a container, modify its NBT there, and then using the /loot command with the "mine" option to mine the container and transfer the items back into the player's inventory, but this is currently not possible because of https://bugs.mojang.com/browse/MC-138299 
    3. NBT data that can be modified by other commands, like teams, tags or attribute modifiers, should also be modified by /data, since it can do many things other commands can't, like taking a tag from one entity and assigning it to another entity
  • 5
    Registered User commented
    Comment actions Permalink

    can confirm, this is really annoying. I wanted to make a simple (well, relatively simple) datapack to give players a /fly command, but since I'm "not allowed" to modify player data (for whatever reason?? I can think of a max of 2 possible reasons it's not already writable, and neither of them are very good), my update command fails.

    /data merge entity Twisted_Code {abilities:{mayfly:0b}}
    Unable to modify player data
    <Twisted_Code> rip
  • 4
    Registered User commented
    Comment actions Permalink

    Comment from Dinnerbone on Reddit detailing why player data modification isn't possible:

    So let me preface this with the hopefully clear message that NBT is internals and will never officially be supported, you're mostly on your own for what it can and cannot do. That said, we try to be nice and make it works where it can because hey you can do some really neat things with it.

    The whole idea behind editing NBT isn't that you're editing the entity, or the item, or the block - you're saving it, editing the save data, and loading it again. NBT isn't what we are using in memory, we have more efficient in-memory structures for things. It's 100% just save data.

    Players can't really be saved and reloaded. There's a person attached and having to kick them out and tell them to reconnect would suck. Almost everything you'd want to modify would either just not work, or would be totally inconsistent with the clients state. You'd end up being able to modify a couple of things, and the rest would just break stuff outright.

    Continued in next comment…

  • 3
    Registered User commented
    Comment actions Permalink

    Continuation from the previous comment:

    There's no security issue here, it's entirely a matter of "our engine isn't built this way". Players are people too. We could let it happen and spend a year fixing all the places it'll break... But again, NBT editing isn't officially supported. We'll let you do it where we're confident it'll mostly work, and we don't let you do it where we're confident it mostly won't. We're a pretty small team and we'd rather make proper, well definitely interfaces to do what you're doing instead of figuring out how to make save-file editing work for things that it doesn't make sense for.

    I hope this helps explain things better, and I'm really sorry that this is the case - but it is.

    <3

    And there you have it. This explains why it isn't possible to modify player NBT.

  • 3
    Registered User commented
    Comment actions Permalink

    ExpertCoder2306, can you provide an pemalink to that comment? I'd like to reply to it if it hasn't been archived yet. The closest I've been able to get to finding it is dinnerbone's Reddit profile and I don't feel like scrolling and scrolling and scrolling

    Okay, then it would be nice if they added commands to more directly access the in-memory objects. Granted, the exact representation is going to be different between platforms (bedrock vs. JE, for instance), but I can't imagine it's so complicated that adding a /fly command as I was trying to do would be completely impossible without mods.

    My understanding is that, by expanding the capabilities of data packs, they are trying to slowly reduce or eliminate the number of cases in which people need full-fledged modloaders to support their tweaks. if that's the case, I feel like there ought to be at least some way for commands to access player data like "can fly" "Max health", etc.

  • 3
    Registered User commented
    Comment actions Permalink

    this would be very great, for server and maps. i want it, mojang add it please.

  • 3
    Registered User commented
    Comment actions Permalink

    This would be immensely helpful for many datapack creators such as myself. I'd most specifically use this to edit the {fire} tag and the {FallFlying} tag so I could make players fly without elytra in certain cases

  • 2
    Registered User commented
    Comment actions Permalink

    Please Mojang, this is not a huge thing to do, but it would allow so much more possibilities and creativity to manage the player behavior

  • 1
    Registered User commented
    Comment actions Permalink

    I would use this a lot, with the motion capability. This would be amazing, good idea!

  • 1
    Registered User commented
    Comment actions Permalink

    I agree with this completely. Being able to modify the Motion tag would be a huge help in making mobility datapacks, like trying to add Celeste-style abilities like dashing and climbing.

  • 1
    Registered User commented
    Comment actions Permalink

    About the whole Dinnerbone post, I think they're replacing NBT with Components for 1.21. That may be just for items, but still. The command community has grown so much that it's a core part of Minecraft, and it would be so useful to them to add this.