Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Modify Player Data Wiki › Guides › Editing Another Player's Inventory and Health Data

Editing Another Player's Inventory and Health Data

Targeting the Right Player

Player data lives under the player entity's root NBT. Inventory contents, health, hunger, XP, and effects are all stored as tags inside that tree. To edit someone else's inventory you need operator permissions and you must target them by name or selector.

Run the get form of the command on the player first and look for the inventory list tag. Each entry in that list represents a slot and holds the item's id, count, and any component or tag data. Note the exact structure before you touch it.

Changing Values Safely

To give or replace an item, use the modify form with the inventory path and set or merge the slot entry. Merge is safer than set when you only want to change one field, because set replaces the whole entry and can wipe enchantments or custom names you did not intend to remove.

For health and hunger, find the corresponding numeric tags and set them to your desired value. Keep values within the normal range the game expects — extreme numbers can behave oddly.

After any change, have the player relog or trigger a sync so the client reflects the new data. If the client shows stale values, the server data is still correct; a relog usually fixes the display.