Skip to content

Commit

Permalink
Merge pull request #1578 from ProjectTSB/future/inventory-change
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenCMD authored Oct 20, 2024
2 parents 29eee2d + 1099b43 commit 3aa985b
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,63 +1,8 @@
#> api:inventory/core/clear/remove/
# @within function api:inventory/clear

# 処理
# 処理 (lib: Array -> api: Inventory)
execute if data storage lib: Array[0] run function api:inventory/core/clear/remove/map
# 0-26
data modify block 10000 0 10000 Items set from storage api: NewInv
loot replace entity @s hotbar.0 27 mine 10000 0 10000 debug_stick
# 27-35
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:27b}]
data modify storage api: Items[{Slot:27b}].Slot set value 0b
data modify storage api: Items append from storage api: NewInv[{Slot:28b}]
data modify storage api: Items[{Slot:28b}].Slot set value 1b
data modify storage api: Items append from storage api: NewInv[{Slot:29b}]
data modify storage api: Items[{Slot:29b}].Slot set value 2b
data modify storage api: Items append from storage api: NewInv[{Slot:30b}]
data modify storage api: Items[{Slot:30b}].Slot set value 3b
data modify storage api: Items append from storage api: NewInv[{Slot:31b}]
data modify storage api: Items[{Slot:31b}].Slot set value 4b
data modify storage api: Items append from storage api: NewInv[{Slot:32b}]
data modify storage api: Items[{Slot:32b}].Slot set value 5b
data modify storage api: Items append from storage api: NewInv[{Slot:33b}]
data modify storage api: Items[{Slot:33b}].Slot set value 6b
data modify storage api: Items append from storage api: NewInv[{Slot:34b}]
data modify storage api: Items[{Slot:34b}].Slot set value 7b
data modify storage api: Items append from storage api: NewInv[{Slot:35b}]
data modify storage api: Items[{Slot:35b}].Slot set value 8b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s inventory.18 9 mine 10000 0 10000 debug_stick
# 足
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:100b}]
data modify storage api: Items[{Slot:100b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.feet 1 mine 10000 0 10000 debug_stick
# 脚
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:101b}]
data modify storage api: Items[{Slot:101b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.legs 1 mine 10000 0 10000 debug_stick
# 胸
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:102b}]
data modify storage api: Items[{Slot:102b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.chest 1 mine 10000 0 10000 debug_stick
# 頭
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:103b}]
data modify storage api: Items[{Slot:103b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.head 1 mine 10000 0 10000 debug_stick
# オフハンド
data modify storage api: Items set value []
data modify storage api: Items append from storage api: NewInv[{Slot:-106b}]
data modify storage api: Items[{Slot:-106b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s weapon.offhand 1 mine 10000 0 10000 debug_stick
# リセット
data remove storage api: NewInv
data remove storage api: Items

# インベントリ上書き
function api:inventory/set
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# api:inventory/core/clear/remove/map

# 末尾データを新しいインベントリに追加する
data modify storage api: NewInv append from storage lib: Array[-1]
data modify storage api: Argument.Inventory append from storage lib: Array[-1]
# Count削除
data remove storage lib: Array[-1].Count
data remove storage lib: Array[-1].Slot
Expand All @@ -18,5 +18,5 @@
scoreboard players reset $notEqual Temporary
# まだアイテムがある場合は再帰
execute if score $Amount Temporary matches ..0 if data storage lib: Array[0] run function lib:array/reverse
execute if score $Amount Temporary matches ..0 if data storage lib: Array[0] run data modify storage api: NewInv append from storage lib: Array[]
execute if score $Amount Temporary matches 1.. if data storage lib: Array[0] run function api:inventory/core/clear/remove/map
execute if score $Amount Temporary matches ..0 if data storage lib: Array[0] run data modify storage api: Argument.Inventory append from storage lib: Array[]
execute if score $Amount Temporary matches 1.. if data storage lib: Array[0] run function api:inventory/core/clear/remove/map
79 changes: 79 additions & 0 deletions TheSkyBlessing/data/api/functions/inventory/set.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#> api:inventory/set
#
# 実行者のインベントリを与えられた Inventory データに書き換えます。
#
# この API は元のインベントリを一切維持しません。
#
# ただし、カーソルで保持するアイテムに付いてはその限りではなく、残ったままとなります。
#
# 明示的にカーソルに保持するアイテムを削除したい場合は、事前に clear @s を実行してください。
#
# @input
# as player
# storage
# Argument.Inventory: [SlottedItem]
# @api

# Validation
execute unless data storage api: Argument.Inventory run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Inventory","color":"red"}]
execute unless data storage api: Argument.Inventory run return fail

# 0-26
data modify block 10000 0 10000 Items set from storage api: Argument.Inventory
loot replace entity @s hotbar.0 27 mine 10000 0 10000 debug_stick
# 27-35
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:27b}]
data modify storage api: Items[{Slot:27b}].Slot set value 0b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:28b}]
data modify storage api: Items[{Slot:28b}].Slot set value 1b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:29b}]
data modify storage api: Items[{Slot:29b}].Slot set value 2b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:30b}]
data modify storage api: Items[{Slot:30b}].Slot set value 3b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:31b}]
data modify storage api: Items[{Slot:31b}].Slot set value 4b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:32b}]
data modify storage api: Items[{Slot:32b}].Slot set value 5b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:33b}]
data modify storage api: Items[{Slot:33b}].Slot set value 6b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:34b}]
data modify storage api: Items[{Slot:34b}].Slot set value 7b
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:35b}]
data modify storage api: Items[{Slot:35b}].Slot set value 8b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s inventory.18 9 mine 10000 0 10000 debug_stick
# 足
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:100b}]
data modify storage api: Items[{Slot:100b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.feet 1 mine 10000 0 10000 debug_stick
# 脚
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:101b}]
data modify storage api: Items[{Slot:101b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.legs 1 mine 10000 0 10000 debug_stick
# 胸
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:102b}]
data modify storage api: Items[{Slot:102b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.chest 1 mine 10000 0 10000 debug_stick
# 頭
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:103b}]
data modify storage api: Items[{Slot:103b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s armor.head 1 mine 10000 0 10000 debug_stick
# オフハンド
data modify storage api: Items set value []
data modify storage api: Items append from storage api: Argument.Inventory[{Slot:-106b}]
data modify storage api: Items[{Slot:-106b}].Slot set value 0b
execute if data storage api: Items[0] run data modify block 10000 0 10000 Items set from storage api: Items
execute if data storage api: Items[0] run loot replace entity @s weapon.offhand 1 mine 10000 0 10000 debug_stick

# リセット
data remove storage api: Argument.Inventory
data remove storage api: Items
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# 下ごしらえ
data modify storage lib: Array set from storage api: Inventory
data remove storage lib: Array[].Slot
data remove storage player_manager:lost_item Temp[{tag:{Enchantments:[{id:"minecraft:vanishing_curse"}]}}]
data remove storage lib: Array[{tag:{Enchantments:[{id:"minecraft:vanishing_curse"}]}}]
data remove storage lib: Array[{tag:{TSB:{SoulBound:true}}}]

# 一回目
function lib:array/packing_chest
Expand All @@ -33,5 +34,9 @@
execute positioned ~ ~1 ~ as @e[type=item,distance=..0.5] run function player_manager:lost_item/drop/motion_multiple


# SoulBound のアイテムをインベントリに戻す
execute if data storage api: Inventory[{tag:{TSB:{SoulBound:true}}}] run function player_manager:lost_item/regive_soulbound


# リセット
function lib:array/session/close
function lib:array/session/close
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> player_manager:lost_item/regive_soulbound
#
#
#
# @within function
# player_manager:lost_item/drop/
# player_manager:lost_item/take

data modify storage api: Argument.Inventory append from storage api: Inventory[{tag:{TSB:{SoulBound:true}}}]
function api:inventory/set
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
data modify storage player_manager:lost_item Temp set from storage api: Inventory
# Slotを削除
data remove storage player_manager:lost_item Temp[].Slot
# 消滅の呪い付きアイテムを削除
# 消滅の呪い付きアイテムを削除する
data remove storage player_manager:lost_item Temp[{tag:{Enchantments:[{id:"minecraft:vanishing_curse"}]}}]
# SoulBound 付きのアイテムを削除する (手元に残すので)
data remove storage player_manager:lost_item Temp[{tag:{TSB:{SoulBound:true}}}]
# UserStorage呼び出し
function oh_my_dat:please
# IDをIDSetに追加
Expand All @@ -22,4 +24,7 @@
execute unless data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Name run function lib:get_name/
execute unless data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Name run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Name set from storage lib: Return.Name
# インベントリclear
clear @s
clear @s

# SoulBound のアイテムをインベントリに戻す
execute if data storage api: Inventory[{tag:{TSB:{SoulBound:true}}}] run function player_manager:lost_item/regive_soulbound

0 comments on commit 3aa985b

Please sign in to comment.