Initial import
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
# Cari slot kosong pertama, lalu salin item dari inventory.26 ke slot tersebut.
|
||||
# Patch: ts_moved hanya dipasang jika command item replace benar-benar sukses,
|
||||
# bukan sekadar karena slot target terdeteksi berisi item. Ini mencegah false-positive
|
||||
# yang membuat actionbar muncul tetapi item asli kemudian hilang.
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:9b}] store success score @s trashslot_success run item replace entity @s inventory.0 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:10b}] store success score @s trashslot_success run item replace entity @s inventory.1 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:11b}] store success score @s trashslot_success run item replace entity @s inventory.2 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:12b}] store success score @s trashslot_success run item replace entity @s inventory.3 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:13b}] store success score @s trashslot_success run item replace entity @s inventory.4 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:14b}] store success score @s trashslot_success run item replace entity @s inventory.5 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:15b}] store success score @s trashslot_success run item replace entity @s inventory.6 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:16b}] store success score @s trashslot_success run item replace entity @s inventory.7 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:17b}] store success score @s trashslot_success run item replace entity @s inventory.8 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:18b}] store success score @s trashslot_success run item replace entity @s inventory.9 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:19b}] store success score @s trashslot_success run item replace entity @s inventory.10 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:20b}] store success score @s trashslot_success run item replace entity @s inventory.11 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:21b}] store success score @s trashslot_success run item replace entity @s inventory.12 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:22b}] store success score @s trashslot_success run item replace entity @s inventory.13 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:23b}] store success score @s trashslot_success run item replace entity @s inventory.14 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:24b}] store success score @s trashslot_success run item replace entity @s inventory.15 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:25b}] store success score @s trashslot_success run item replace entity @s inventory.16 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:26b}] store success score @s trashslot_success run item replace entity @s inventory.17 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:27b}] store success score @s trashslot_success run item replace entity @s inventory.18 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:28b}] store success score @s trashslot_success run item replace entity @s inventory.19 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:29b}] store success score @s trashslot_success run item replace entity @s inventory.20 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:30b}] store success score @s trashslot_success run item replace entity @s inventory.21 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:31b}] store success score @s trashslot_success run item replace entity @s inventory.22 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:32b}] store success score @s trashslot_success run item replace entity @s inventory.23 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:33b}] store success score @s trashslot_success run item replace entity @s inventory.24 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:34b}] store success score @s trashslot_success run item replace entity @s inventory.25 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:0b}] store success score @s trashslot_success run item replace entity @s hotbar.0 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:1b}] store success score @s trashslot_success run item replace entity @s hotbar.1 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:2b}] store success score @s trashslot_success run item replace entity @s hotbar.2 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:3b}] store success score @s trashslot_success run item replace entity @s hotbar.3 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:4b}] store success score @s trashslot_success run item replace entity @s hotbar.4 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:5b}] store success score @s trashslot_success run item replace entity @s hotbar.5 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:6b}] store success score @s trashslot_success run item replace entity @s hotbar.6 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:7b}] store success score @s trashslot_success run item replace entity @s hotbar.7 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
execute unless entity @s[tag=ts_moved] unless data entity @s Inventory[{Slot:8b}] store success score @s trashslot_success run item replace entity @s hotbar.8 from entity @s inventory.26
|
||||
execute unless entity @s[tag=ts_moved] if score @s trashslot_success matches 1.. run tag @s add ts_moved
|
||||
scoreboard players set @s[tag=!ts_moved] trashslot_success 0
|
||||
@@ -0,0 +1,20 @@
|
||||
# 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"}
|
||||
@@ -0,0 +1,41 @@
|
||||
# Objective untuk menampilkan jumlah item yang dipindahkan dari slot 26.
|
||||
# Aman walaupun dijalankan berulang; jika objective sudah ada, command ini hanya gagal diam-diam.
|
||||
scoreboard objectives add trashslot_count dummy
|
||||
scoreboard objectives add trashslot_success dummy
|
||||
|
||||
# Tandai player yang sedang berada di mode bebas.
|
||||
# Tag ini dipakai untuk mendeteksi transisi dari creative/spectator ke survival/adventure.
|
||||
tag @a[gamemode=creative] add ts_free_mode
|
||||
tag @a[gamemode=spectator] add ts_free_mode
|
||||
tag @a[gamemode=creative] remove ts_transition_checked
|
||||
tag @a[gamemode=spectator] remove ts_transition_checked
|
||||
tag @a[gamemode=creative] remove ts_slot26_protected
|
||||
tag @a[gamemode=spectator] remove ts_slot26_protected
|
||||
|
||||
# Hapus hanya icon Trash Slot saat player masuk creative/spectator.
|
||||
# Jangan pakai item replace inventory.26 with air tanpa kondisi, karena itu akan
|
||||
# menghapus item apa pun yang ditaruh player di slot 26 setiap tick.
|
||||
clear @a[gamemode=creative] minecraft:barrier{CustomModelData:87274} 1
|
||||
clear @a[gamemode=spectator] minecraft:barrier{CustomModelData:87274} 1
|
||||
|
||||
# Bersihkan item trash lama dari player survival/adventure.
|
||||
clear @a[gamemode=!creative,gamemode=!spectator] minecraft:barrier{CustomModelData:87274}
|
||||
|
||||
# Saat baru pindah dari creative/spectator ke survival/adventure, selamatkan item asli di slot 26 satu kali saja.
|
||||
# NBT Slot 35b = command slot inventory.26.
|
||||
execute as @a[gamemode=!creative,gamemode=!spectator,tag=ts_free_mode,tag=!ts_transition_checked] at @s if predicate trashslot:allowed_dimension if data entity @s Inventory[{Slot:35b}] unless data entity @s Inventory[{Slot:35b,id:"minecraft:barrier",tag:{CustomModelData:87274}}] run function trashslot:save_slot_26
|
||||
tag @a[gamemode=!creative,gamemode=!spectator,tag=ts_free_mode,tag=!ts_transition_checked] add ts_transition_checked
|
||||
tag @a[gamemode=!creative,gamemode=!spectator,tag=ts_free_mode,tag=ts_transition_checked] remove ts_free_mode
|
||||
|
||||
# Jika player survival/adventure memang membuang item ke slot 26 saat Trash Slot aktif, hapus diam-diam.
|
||||
# Ini tidak menampilkan actionbar, dan tidak menjalankan fungsi pemindahan item.
|
||||
execute as @a[gamemode=!creative,gamemode=!spectator,tag=!ts_slot26_protected] at @s if predicate trashslot:allowed_dimension if data entity @s Inventory[{Slot:35b}] unless data entity @s Inventory[{Slot:35b,id:"minecraft:barrier",tag:{CustomModelData:87274}}] run item replace entity @s inventory.26 with air
|
||||
|
||||
# Jika sebelumnya slot 26 dilindungi karena inventory penuh, lepaskan proteksi setelah slot 26 kosong.
|
||||
execute as @a[gamemode=!creative,gamemode=!spectator,tag=ts_slot26_protected] unless data entity @s Inventory[{Slot:35b}] run tag @s remove ts_slot26_protected
|
||||
|
||||
# Pasang trash slot hanya kalau slot 26 kosong, supaya item asli tidak tertimpa.
|
||||
execute as @a[gamemode=!creative,gamemode=!spectator] at @s if predicate trashslot:allowed_dimension unless data entity @s Inventory[{Slot:35b}] run item replace entity @s inventory.26 with minecraft:barrier{CustomModelData:87274,HideFlags:32,display:{Name:'{"text":"Trash Slot","color":"dark_red","italic":false}',Lore:['{"text":"ZombiiAttack","color":"gray","italic":true}']}}
|
||||
|
||||
# Hancurkan item trash yang terlempar ke world jika berupa item icon Trash Slot.
|
||||
kill @e[type=item,nbt={Item:{tag:{display:{Name:'{"extra":[{"italic":false,"color":"dark_red","text":"Trash Slot"}],"text":""}'}}}}]
|
||||
Reference in New Issue
Block a user