function crate(p: player, t: string, n: string): loop {crate.%{_t}%::*}: add {crate.%{_t}%::%loop-index%} to {_roll::*} open chest with 3 rows named {_n} to {_p} wait a tick set {_speedFinal} to 1 set {_Selector1} to 4 set {_Selector2} to 22 loop 9 times: set slot loop-number - 1 of {_p}'s current inventory to black stained glass pane named " " set slot loop-number + 17 of {_p}'s current inventory to black stained glass pane named " " set slot {_Selector1} of {_p}'s current inventory to shiny light green stained glass pane named " " set slot {_Selector2} of {_p}'s current inventory to shiny light green stained glass pane named " " loop random integer between 10 and 30 times: if inventory name of {_p}'s current inventory is {_n}: set {_run} to true else: set {_run} to false if {_run} is true: set {_sel} to 9 loop 8 times: set {_sel2} to {_sel} - 1 set {_item::%{_sel}%} to {_item::%{_sel2}%} subtract 1 from {_sel} set {_item::1} to a random element out of {_roll::*} loop 9 times: set slot 8 + loop-number-2 of {_p}'s current inventory to {_item::%loop-number-2%} play "BLOCK_NOTE_HAT" to {_p} at volume 1 play "ENTITY_EXPERIENCE_ORB_PICKUP" to {_p} at volume 0.5 add 1 to {_speed} if {_speed} is 5: set {_speed} to 0 add 1 to {_speedFinal} loop {_speedFinal} times: wait a tick else: exit loop if {_run} is true: message "%{_n}% &a「%{_item::5}%&a」 &fGet!" to {_p} give {_p} slot 13 of {_p}'s current inventory remove 1 of {_p}'s tool from {_p}'s tool function color(s: string) :: string: replace all "&" with "§" in {_s} return {_s} command /crate [] [] []: permission: * trigger: if arg 1 isn't set: send "&6【Crate Data Manager】" send "&a/crate list &b- Show crate list." send "&a/crate item &b- Show the item in the crate." send "&a/crate add &b- Add item to crate." send "&a/crate remove [] &b- Remove item from the crate." send "&a/crate get &b- Get the crate" send "&c※ Item index - &e/crate item &cUse this command." if arg 1 is "list": send "&b【Crate List】" loop {crate.type::*}: send "&r%loop-index%" if arg 1 is "item": if arg 2 is set: send "&aItem of &r%arg 2%" loop {crate.%arg 2%::*}: send "[%loop-index%] %loop-value%" if arg 1 is "add": if arg 2 is set: add player's tool to {crate.%arg 2%::*} set {crate.type::%arg 2%} to true send "&aAdd &e%player's tool% &ato &r%arg 2%" if arg 1 is "remove": if arg 2 is set: if arg 3 is set: send "&cRemoved the item. &r%{crate.%arg 2%::%arg 3%}% &cin &r%arg 2%" delete {crate.%arg 2%::%arg 3%} delete {crate.type::%arg 2%} else: delete {crate.%arg 2%::*} delete {crate.type::%arg 2%} send "&cRemoved the crate. &r%arg 2%" if arg 1 is "get": if arg 2 is set: give 1 chest named "%arg 2%" to player inventory click: loop {crate.type::*}: if inventory name of player's current inventory is color("%loop-index%"): cancel event right click: loop {crate.type::*}: if color("%loop-index%") is name of player's tool: crate(player, "%loop-index%", color("%loop-index%"))