#Chest pickup

1 messages · Page 1 of 1 (latest)

scenic gulch
#

I've been trying to replicate the ctrl + middle mouse click function from creative mode using Skript but I can't get the NBT data from the chest block to the chest item since the nbt structure is different.
The goal is that people could you a custom item I already have then ctrl rightclick a chest. It would then disapear and be picked up in their inventory with the proper NBT data with inventory.

I am looking at this the wrong way ?

restive schooner
#

You can try looping the items in the (block) chest’s inv, then add them to NBT of (item) chest

scenic gulch
#

`on rightclick on chest:
if name of player's tool is "Pick it up":
cancel event
set {_inventory} to serialized inventory of event-block
delete event-block
give player 1 chest with nbt "{StoredInventory:'%{_inventory}%'}" named "&6Stored Chest"
send "&aYou picked up a chest with its contents!" to player
else:
send "&cYou need the special tool named 'Pick it up' to pick up this chest!" to player

on place of chest:
set {_nbt} to nbt of player's held item
if {_nbt} contains "StoredInventory":
wait 1 tick
set {_contents} to {_nbt}["StoredInventory"] parsed as inventory
set inventory of event-block to {_contents}
send "&aThe chest's inventory has been restored!" to player`

#

this is what I have, but I always get an error while trying to write a custom nbt

#

"{StoredInventory: '%{_inventory}%'}" is not an nbt compound

restive schooner
#

Is this AI code?

scenic gulch
#

busted, second part for placing is, first part not.
I can't get my head around creating custom nbt or just converting (block)chest content nbt to (item) chest nbt

#

i've switch to this
`on rightclick on chest:
if name of player's tool is "Pick it up":
if {schest.%UUID of player%::} is set:
cancel event
send "&aYou're already moving a chest" to player
else:
cancel event
set {schest.%UUID of player%::
} to items in event-block's inventory
#delete event-block
give player 1 chest with lore "StoredInventory"
send "&aYou picked up a chest with its contents!" to player

on place of chest:
set {_nbt.%player%::} to lore of player's held item
if {_nbt.%player%::
} contains "StoredInventory":
{schest.%UUID of player%::} is set:
wait 1 tick
add {schest.%UUID of player%::
} to inventory of event-block
delete {schest.%UUID of player%::*}
send "&aThe chest's inventory has been restored!" to player`

#

it works, but it limits the usage. You can only move 1 chest at a time

scenic gulch
restive schooner
#

See Shane’s inventory serialse snippets

#

I can send u mine in about 10min

restive schooner
#

oh wait definitely check out shane's. Mine's modified from that as a starting point
(i forgot I broke mine yesterday lol)

scenic gulch
#

So from what I can see on his, he's adding a custom nbt tag to the player with the information of the inventory ?

restive schooner
#

yup, you'll just add that to the item

scenic gulch
#

MMMMH that's smart ! imma go try that. Thanks for the help

scenic gulch
# restive schooner See Shane’s inventory serialse snippets

sad trumpet sound
invalid item ?

on rightclick on chest: if name of player's tool is "Pick it up": cancel event set {_key} to "backup" loop inventory of event-block: set {_s} to index of loop-slot set {_i} to full nbt of loop-slot set int tag "Slot" of {_i} to {_s} add {_i} to {_i::*} set {_p} to chest set compound list tag "custom;SavedInv;%{_key}%" of nbt of {_p} to {_i::*} give player {_p}

#

works fine if _p is the player

restive schooner
#

try items in (event-block's inventory)

#

(for the loop)

scenic gulch
restive schooner
#

try set {_NBT} to (custom nbt compound of ITEM) set (compound list tag "SavedInv;%{_key}%" of {_NBT}) to {_i::*}

scenic gulch
restive schooner
#

yup

scenic gulch
# restive schooner yup

okkk ! yes, the error is gone and when I check the NBT data, the info is there, now I just need to figure the other part ahaha

scenic gulch
# restive schooner yup

Last help, I swear, so i'm reading the nbt data from the player's tool and then using that data to fill the chest, but I get no broadcast on the loop and the chest is empty

`on rightclick on chest:
if name of player's tool is "Pick it up":
cancel event
set {_key} to "backup"
loop items in (event-block's inventory):
set {_s} to index of loop-slot
set {_i} to full nbt of loop-slot
set int tag "Slot" of {_i} to {_s}
add {_i} to {_i::}
set {_p} to chest with lore "Contains Inventory"
set {_NBT} to (custom nbt compound of {_p})
set (compound list tag "SavedInv;%{_key}%" of {_NBT}) to {_i::
}
give player {_p}

on place of chest:
if lore of player's tool contains "Contains Inventory":
broadcast "test"
set {_key} to "backup"
set {_o} to player's tool
set {_p} to event-block
set {_i::} to compound list tag "custom;SavedInv;%{_key}%" of nbt of {_o}
loop {_i::
}:
set {_s} to int tag "Slot" of loop-value
set {_i} to nbt item from loop-value
set slot {_s} of {_p} to {_i}
broadcast "%{_p}% %{_s}% %{_i}%"
#delete tag "custom;SavedInv;%{_key}%" of nbt of {_p}`

#

I really appreciate ur help btw !

restive schooner
#

get the csutom nbt compound, then set a list to the tag