-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: shift-click into inventory, only refill if going from Count:1…
… to none
- Loading branch information
Showing
15 changed files
with
156 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
# say do_refill | ||
function call_stack:push | ||
|
||
data modify storage call_stack: this.this_user set from storage call_stack: this.arg0 | ||
data modify storage call_stack: this.user set from storage call_stack: this.arg0 | ||
data modify storage call_stack: this.item set from storage call_stack: this.arg1 | ||
|
||
data modify storage call_stack: this.original_slot set from storage call_stack: this.item.Slot | ||
data modify storage call_stack: this.item.Slot set from storage call_stack: this.this_user.data.selected.slot | ||
data modify storage call_stack: this.slot_from_inventory set from storage call_stack: this.item.Slot | ||
data modify storage call_stack: this.item.Slot set from storage call_stack: this.user.data.selected.Slot | ||
|
||
# Replace the inventory item | ||
execute unless data entity @s SelectedItem run data modify storage call_stack: call.arg0 set from storage call_stack: this.slot_from_inventory | ||
execute unless data entity @s SelectedItem run function dt.inventory:api/player/slot/remove | ||
# execute if data entity @s SelectedItem run data modify storage call_stack: call.arg0 set from entity @s SelectedItem | ||
# execute if data entity @s SelectedItem run data modify storage call_stack: call.arg0.Slot set from storage call_stack: this.slot_from_inventory | ||
# execute if data entity @s SelectedItem run function dt.inventory:api/player/slot/replace | ||
|
||
# Replace the hotbar item | ||
data modify storage call_stack: call.arg0 set from storage call_stack: this.item | ||
function dt.inventory:api/player/slot/replace | ||
|
||
data modify storage call_stack: call.arg0 set from storage call_stack: this.original_slot | ||
function dt.inventory:api/player/slot/remove | ||
data modify storage call_stack: call.arg0 set from storage call_stack: this.slot_from_inventory | ||
function dt.refill:internal/output/print_did_refill | ||
|
||
function call_stack:pop |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
refill/data/dt.refill/functions/internal/database/fetch_or_init.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function call_stack:push | ||
|
||
# get or create empty | ||
data modify storage call_stack: call.arg0 set from storage dt.refill: users | ||
function dt.user_util:get_or_create | ||
data modify storage call_stack: this.user set from storage call_stack: call.result | ||
|
||
# Default object | ||
function dt.refill:internal/database/get_init_data | ||
data modify storage call_stack: this.default_data set from storage call_stack: call.result | ||
|
||
# Merge with actual data | ||
data modify storage call_stack: this.default_data merge from storage call_stack: this.user.data | ||
data modify storage call_stack: this.user.data set from storage call_stack: this.default_data | ||
data modify storage call_stack: this.result set from storage call_stack: this.user | ||
function call_stack:pop |
3 changes: 3 additions & 0 deletions
3
refill/data/dt.refill/functions/internal/database/get_init_data.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function call_stack:push | ||
data modify storage call_stack: this.result set value {inventory:[], settings:{min_durability:1}} | ||
function call_stack:pop |
24 changes: 24 additions & 0 deletions
24
refill/data/dt.refill/functions/internal/do_refill.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# say do_refill | ||
function call_stack:push | ||
|
||
data modify storage call_stack: this.user set from storage call_stack: this.arg0 | ||
data modify storage call_stack: this.item set from storage call_stack: this.arg1 | ||
|
||
data modify storage call_stack: this.slot_from_inventory set from storage call_stack: this.item.Slot | ||
data modify storage call_stack: this.item.Slot set from storage call_stack: this.user.data.selected.Slot | ||
|
||
# Replace the inventory item | ||
execute unless data entity @s SelectedItem run data modify storage call_stack: call.arg0 set from storage call_stack: this.slot_from_inventory | ||
execute unless data entity @s SelectedItem run function dt.inventory:api/player/slot/remove | ||
# execute if data entity @s SelectedItem run data modify storage call_stack: call.arg0 set from entity @s SelectedItem | ||
# execute if data entity @s SelectedItem run data modify storage call_stack: call.arg0.Slot set from storage call_stack: this.slot_from_inventory | ||
# execute if data entity @s SelectedItem run function dt.inventory:api/player/slot/replace | ||
|
||
# Replace the hotbar item | ||
data modify storage call_stack: call.arg0 set from storage call_stack: this.item | ||
function dt.inventory:api/player/slot/replace | ||
|
||
data modify storage call_stack: call.arg0 set from storage call_stack: this.slot_from_inventory | ||
function dt.refill:internal/output/print_did_refill | ||
|
||
function call_stack:pop |
4 changes: 4 additions & 0 deletions
4
refill/data/dt.refill/functions/internal/output/print_did_refill.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function call_stack:push | ||
execute store result score $slot dt.tmp run data get storage call_stack: this.arg0 | ||
title @a actionbar ["",{"text":"Refilled from slot ","color":"white"},{"score":{"name":"$slot","objective":"dt.tmp"}}] | ||
function call_stack:pop |
34 changes: 34 additions & 0 deletions
34
refill/data/dt.refill/functions/internal/refill_from_inventory.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# say from_inventory | ||
function call_stack:push | ||
|
||
data modify storage call_stack: this.user set from storage call_stack: this.arg0 | ||
|
||
# find in stored inventory first | ||
data modify storage call_stack: call.arg0 set from storage call_stack: this.user.data.inventory | ||
data modify storage call_stack: call.arg1 set value {id:""} | ||
data modify storage call_stack: call.arg1.id set from storage call_stack: this.user.data.selected.id | ||
data modify storage call_stack: call.arg2 set value 1 | ||
function dt.array:api/split_by_key_limit_n | ||
data modify storage call_stack: this.data_item_found set from storage call_stack: call.result[0][0] | ||
|
||
# if found in inventory data, match with actual inventory | ||
execute if data storage call_stack: this.data_item_found.id run function dt.inventory:api/player/get/inventory | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: this.items set from storage call_stack: call.result | ||
|
||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: call.arg0 set from storage call_stack: this.items | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: call.arg1 set value {id:"",Slot:""} | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: call.arg1.id set from storage call_stack: this.data_item_found.id | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: call.arg1.Slot set from storage call_stack: this.data_item_found.Slot | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: call.arg2 set value 1 | ||
execute if data storage call_stack: this.data_item_found.id run function dt.array:api/split_by_key_limit_n | ||
execute if data storage call_stack: this.data_item_found.id run data modify storage call_stack: this.actual_item_found set from storage call_stack: call.result[0][0] | ||
|
||
|
||
# execute if data storage call_stack: this.actual_item_found.id store result | ||
# TODO check that new items durability is greater than current | ||
execute if data storage call_stack: this.actual_item_found.id run data modify storage call_stack: call.arg0 set from storage call_stack: this.user | ||
execute if data storage call_stack: this.actual_item_found.id run data modify storage call_stack: call.arg1 set from storage call_stack: this.actual_item_found | ||
execute if data storage call_stack: this.actual_item_found.id run function dt.refill:do_refill | ||
# execute unless data storage call_stack: this.actual_item_found.id run data remove storage call_stack: this.user.data.selected | ||
|
||
function call_stack:pop |
24 changes: 24 additions & 0 deletions
24
refill/data/dt.refill/functions/internal/set_user_item_data.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# say store selected | ||
function call_stack:push | ||
|
||
data modify storage call_stack: this.this_user set from storage call_stack: this.arg0 | ||
|
||
data remove storage call_stack: this.this_user.data | ||
data modify storage call_stack: this.this_user.data.selected set from entity @s SelectedItem | ||
data modify storage call_stack: this.this_user.data.selected.Slot set from entity @s SelectedItemSlot | ||
|
||
data modify storage call_stack: this.this_user.data.inventory set from entity @s Inventory | ||
|
||
# remove hotbar slots | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:0b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:1b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:2b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:3b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:4b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:5b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:6b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:7b}] | ||
data remove storage call_stack: this.this_user.data.inventory[{Slot:8b}] | ||
|
||
data modify storage call_stack: this.result set from storage call_stack: this.this_user | ||
function call_stack:pop |
20 changes: 20 additions & 0 deletions
20
refill/data/dt.refill/functions/internal/try_refill.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# say try_refill | ||
function call_stack:push | ||
|
||
data modify storage call_stack: this.user set from storage call_stack: this.arg0 | ||
# Check that the slots are the same, if so continue | ||
execute store result score $slot_from_data dt.tmp run data get storage call_stack: this.user.data.selected.Slot | ||
execute store result score $slot_from_player dt.tmp run data get entity @s SelectedItemSlot | ||
execute store result score $item_count dt.tmp run data get storage call_stack: this.user.data.selected.Count | ||
# scoreboard players set $item_uses_left dt.tmp -1 | ||
# execute store result score $min_durability dt.tmp run data get storage call_stack: this.user.data.settings.min_durability | ||
# data modify storage call_stack: this.user.data.settings.min_durability set value 0 | ||
# execute if data entity @s SelectedItem.tag.Damage run function dt.refill:internal/calculate_remaining_durability | ||
# execute if data entity @s SelectedItem.tag.Damage run scoreboard players operation $item_uses_left dt.tmp = @s dt.tmp | ||
|
||
# if score $item_uses_left dt.tmp <= $min_durability dt.tmp | ||
execute if score $slot_from_data dt.tmp = $slot_from_data dt.tmp if score $item_count dt.tmp matches 1 run data modify storage call_stack: call.arg0 set from storage call_stack: this.user | ||
execute if score $slot_from_data dt.tmp = $slot_from_data dt.tmp if score $item_count dt.tmp matches 1 run function dt.refill:internal/refill_from_inventory | ||
|
||
|
||
function call_stack:pop |
6 changes: 6 additions & 0 deletions
6
refill/data/dt.refill/functions/internal/try_tool_refill.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function call_stack:push | ||
data modify storage call_stack: this.user set from storage call_stack: this.arg0 | ||
|
||
|
||
|
||
function call_stack:pop |
15 changes: 0 additions & 15 deletions
15
refill/data/dt.refill/functions/refill_if_same_slot.mcfunction
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
refill/data/dt.refill/functions/store_selected_item.mcfunction
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters