21 lines
1.2 KiB
MCFunction
21 lines
1.2 KiB
MCFunction
# Simpan jumlah item sebelum slot 26 dikosongkan.
|
|
execute store result score @s trashslot_count run data get entity @s Inventory[{Slot:35b}].Count
|
|
|
|
# Flag internal agar item hanya dipindahkan satu kali.
|
|
scoreboard players set @s trashslot_success 0
|
|
tag @s remove ts_moved
|
|
tag @s remove ts_slot26_protected
|
|
|
|
# Coba pindahkan item dari slot 26 ke slot kosong pertama.
|
|
function trashslot:move_slot_26_to_empty
|
|
|
|
# Beri pesan jika berhasil. Nama item ditampilkan sebagai item id agar selalu muncul, termasuk item tanpa custom name.
|
|
execute if entity @s[tag=ts_moved] run title @s actionbar [{"score":{"name":"@s","objective":"trashslot_count"}},{"text":" "},{"nbt":"Inventory[{Slot:35b}].id","entity":"@s"},{"text":" telah dipindahkan.","color":"green"}]
|
|
|
|
# Kosongkan slot 26 setelah item berhasil disalin ke slot kosong.
|
|
execute if entity @s[tag=ts_moved] run item replace entity @s inventory.26 with air
|
|
|
|
# Kalau inventory penuh, jangan timpa item. Trash Slot akan aktif setelah player mengosongkan/memindahkan slot 26.
|
|
execute unless entity @s[tag=ts_moved] run tag @s add ts_slot26_protected
|
|
execute unless entity @s[tag=ts_moved] run title @s actionbar {"text":"Trash Slot belum aktif: inventory penuh, item di slot 26 tidak dipindahkan.","color":"red"}
|