#Saving storage

1 messages · Page 1 of 1 (latest)

wintry latch
#

I want to place down a shulker box with a command, then when the player puts stuff inside and walks away, it deletes the shulker box and saves the items, the next time the shulker box is put down it has the items again, kinda like an ender chest.

Is there any way to do that with commands?

delicate portal
#

if the shulker box is deleted, how will the player place it again?
like - does the item drop? Are all shulker boxes of a certain color linked?

wintry latch
#

it's a datapack with magic wands, one of the abilities places down a "Null Storage" (the shulker box)

delicate portal
#

ah okay, then it's probably easiest to store the item's in the wand item

wintry latch
#

how would I do that?

delicate portal
#

If a player casts the spell

  1. summon a marker at that location
  2. setblock a shulker box
  3. copy the contents from your wand item to the shulker box using data modify (empty on the first go)
    If the player leaves the vicinity of the shulker box (probably easiest to track with id)
  4. copy the contents of the box into the item using an item modifier
  5. also break the shulker box
  6. you might have to kill the shulker box item that drops (not sure)
  7. then you kill the marker
wintry latch
#

what's the command for storing/putting in the items

#

im not good with the data command

delicate portal
#

copying from item to shulker box, executed as the player with the wand in the mainhand and at the shulker box

data modify block ~ ~ ~ Items set from entity @s SelectedItem.tag.<NAMESPACE>.Items

copying items from the box to the player, again as player and at box
the commands:

item modify entity @s weapon.mainhand <YOUR_ITEM_MODIFIER>

the item modifier (<YOUR_ITEM_MODIFIER>) is something like:

{
    "function": "minecraft:copy_nbt",
    "source": "block_entity",
    "ops": [
        {
            "source": "Items",
            "target": "<NAMESPACE>.Items",
            "op": "replace"
        }
    ]
}
#

so yea, it's just copying. Both are doing the same in reverse - it's just more complicated doing it for players since we can't edit their NBT directly