[Suggestion] Allow Modifications to Player NBT Data
WaffleTraits opened this issue ยท 10 comments
Title says it all, add an option in carpet that enables player data modification either through vanilla commands (eg., /data merge) or through a new command (although scripts exist so this part may not be necessary).
Not possible, even in vanilla, which is why it's not added. There are other commands to affect indovidual bits, but not overall NBT cos it's hardcoded not to be possible
What is player NBT data? Inventory is part of nbt, right? you can modify it. What else?
What is player NBT data? Inventory is part of nbt, right? you can modify it. What else?
Inventory is part of it yeah, but vanilla commands have limited influence over it unfortunately. I was creating a system for modifying item counts of particular items that met a specified criteria when I ran in the the barrier of player data being unmodifiable. Commands such as /replaceitem and /give can do limited forms of inventory modification, but not to a great extent. "EnderItems" are also a part of the player NBT data, which could prove very useful for modifying in some cases.
Some other things you could change are the player's XPSeed, selected item, food level, saturation, and basically everything else from what "/data get entity @s" outputs. Yeah you can modify the player's .dat file outside of the game (when the files are not in use by the server), but there would be so many possibilities if it could be modified in game. Below is just a screenshot of NBTExplorer with a player file open.
XpP could also be changed to some arbitrary floating-point number using just Minecraft commands, though that requires that you set your XP level via to a very high number (triggering some XP level based advancements), then set your XP points, then revert your XP level to what it should be.
you can modify player inventories with scarpet, and you can do that as well with enderchest content, so that's checked off.
You can modify via entity API a few more things - food / saturation things, air, fire, health, spawn_point (pos and dimension), all the position thingies (motion, location etc)
Some of these items on this list will be updated by the game on the tick basis, so there is no point in manipulating them in game even if you can like fallflying, onground etc.
xp stuff should be something to consider (to provide the API for that, and not resorting to /xp command)
what else?
attributes? maxhealth?
Attributes can be modified with the vanilla /attribute
command, meaning that you can do something like run(str('attribute %s minecraft:generic.max_health base set %s', player~'command_name', value))
.
accessing attributes directly, skipping attribute command, is an obvious thing to add
The dedicated commands for interacting with player data work well if you have predetermined values, but don't help much otherwise. For example, if you have the position data saved in NBT somewhere else (think lodestone compass), you need a separate entity (and complicated chunk loading to go with it) to teleport to the position and you can't handle arbitrary dimension IDs at all afaik. If the /data
command could modify player NBT, you could simply do /data modify entity @s Dimension set from [NBT source]
The mod EqualNBT is supposed to achieve a similar effect (according to the summarized description), but that mod is closed-source (despite having MIT licence) and supported only up to 1.16.5.