#Saving and restoring player inventories on multiplayer server

1 messages · Page 1 of 1 (latest)

round sierra
#

Hi, I'm new here. Been running Minecraft servers for the last 2 years for a group of homeschooled kids. I'm currently working on a new server and I've been looking into datapacks to create some custom games. At the moment I'm trying to write some mcfunctions to save and restore player inventories. The intention would be to run these commands as players enter and exit certain areas of spawn, using Worldgaurd Extra Flags.

I've been trying to follow this guide: https://minecraftcommands.github.io/wiki/questions/storeinventory.html#putting-things-in-the-original-slot-from-storage

I'm testing the datapacks in vanilla Java 1.21.4.

At the moment I have a scoreboard player ID system setup, I'm also able to use a storage object to store each players inventory along with an ID value from their scoreboard. I'm currently just running the functions from the in-game console.

I've been stuck trying to restore player inventories from the storage object. The guide I've been following mentions using an inline loot table with macros, but I've not been able to find any practical examples of this. I've been avoiding the loot table solution for the moment and have just been trying to populate a chest directly from a storage object, but obviously the Slot data needs to be wrangled in order to accommodate armour and other inventory items that are outside of the chest's slot range (e.g. armour.chest being in slot 102).

Aside from not being able to implement the loot table solution, here's an example of where I'm going wrong:

data modify block ~ ~ ~ Items append from storage mcm:inv temp.Inventory[{Slot:102b}]

I've attached a zip of my datapack so far, if I can get any help with this, me and the kids at our minecraft group would be super apreciative!

jovial juniperBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

round sierra
#

Although I'm all up for learning this stuff and writing the datapack myself, I'm also open to just adoptiong someone elses solution, as I would just like something that "does the job". I'm a one person team and I do everything for free, so the kids can have a safe place to play together and meet other Minecrafters.

jovial juniperBOT
# jovial juniper <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

cursive jungle
#

Have you checked the wiki for info on macros?

round sierra
cursive jungle
#

What about it is confusing?

round sierra
#

well, i have not idea how to write one, the example given in on the wiki does not give a working example

cursive jungle
#

Do you know how to make a normal loot table?

round sierra
#

Not really, I've not used them before, I did look at some examples on the wiki, but there's no exaamples of how to write one inline

cursive jungle
#

Writing one in-line is just pasting the JSON loot table without line skips directly into the loot command, where the loot table ID would otherwise go

round sierra
#

the example on the wiki:

{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "$(id)",
"functions": [
{
"function": "minecraft:set_count",
"count": $(count)
},
{
"function": "minecraft:set_components",
"components": $(components)
}
]
}
]
}
]
}

cursive jungle
#

Then you just replace the item and the count in a set_count function with the macro keys

round sierra
#

ok, that gives me somewhere to start, thank you very much!

cursive jungle
round sierra
#

ok, great, i'll give that a go and see how i get on

round sierra
jovial juniperBOT
#
Question Closed

Your question, #1337784447503962292 (Saving and restoring player inventories on multiplayer server), was resolved!

Original Message

#1337784447503962292 message

Duration open

6h37m

jovial juniperBOT