From 24a9d14c0bd2c9c8bd6785e41fb8928fe4d10a10 Mon Sep 17 00:00:00 2001 From: David Thigpen Date: Sun, 6 Feb 2022 11:20:24 -0700 Subject: [PATCH] bugfix: inventory loot insert now works in nether, add WIP changes for array and inventory --- .../api/experimental/call_sum.mcfunction | 1 - .../api/helper/math/add_with_max.mcfunction | 19 ++++ .../helper/math/to_sum_components.mcfunction | 19 ++++ .../api/map/key_value/to_values.mcfunction | 1 - .../api/reduce/math/cumulative_add.mcfunction | 27 ++++++ ...mcfunction => value_difference.mcfunction} | 8 +- .../api/split/in_set_unique.mcfunction | 2 +- .../helper/math/test_add_with_max.mcfunction | 66 ++++++++++++++ .../math/test_to_sum_components.mcfunction | 50 +++++++++++ .../api/math/test_cumulative_add.mcfunction | 46 ++++++++++ .../api/reduce/set/test_difference.mcfunction | 75 ---------------- .../set/test_value_difference.mcfunction | 75 ++++++++++++++++ .../crafter/balance_items_loop.mcfunction | 2 +- .../functions/api/item/loot/insert.mcfunction | 36 ++++++++ .../functions/api/items/combine.mcfunction | 2 +- .../api/items/loot/insert.mcfunction | 12 +++ .../api/player/item/replace.mcfunction | 90 +++++++++---------- .../api/shulker/items/clear.mcfunction | 2 +- .../api/shulker/items/clear2.mcfunction | 2 +- .../api/shulker/items/get.mcfunction | 2 +- .../api/shulker/items/get2.mcfunction | 2 +- .../api/shulker/items/set.mcfunction | 3 +- .../api/shulker/items/set2.mcfunction | 2 +- .../api/shulker/loot/give/player.mcfunction | 2 +- .../api/shulker/loot/insert/block.mcfunction | 15 +++- .../api/shulker/loot/insert/block2.mcfunction | 14 ++- .../loot/replace/entity/hotbar.mcfunction | 2 +- .../loot/replace/entity/inventory.mcfunction | 2 +- .../item/get_item_data_from_name.mcfunction | 6 +- .../dt.inventory/functions/load.mcfunction | 2 +- .../functions/load_shulker.mcfunction | 15 ++-- .../test/api/item/loot/test_insert.mcfunction | 18 ++++ .../api/items/chest/test_set_get.mcfunction | 34 +++---- .../api/items/loot/test_insert.mcfunction | 18 ++++ .../shulker/loot/insert/test_block.mcfunction | 4 +- .../test/api/test_loot_to_block.mcfunction | 10 +-- 36 files changed, 513 insertions(+), 173 deletions(-) create mode 100644 array/data/dt.array/functions/api/helper/math/add_with_max.mcfunction create mode 100644 array/data/dt.array/functions/api/helper/math/to_sum_components.mcfunction create mode 100644 array/data/dt.array/functions/api/reduce/math/cumulative_add.mcfunction rename array/data/dt.array/functions/api/reduce/set/{difference.mcfunction => value_difference.mcfunction} (93%) create mode 100644 array/data/dt.array/functions/test/api/helper/math/test_add_with_max.mcfunction create mode 100644 array/data/dt.array/functions/test/api/helper/math/test_to_sum_components.mcfunction create mode 100644 array/data/dt.array/functions/test/api/math/test_cumulative_add.mcfunction delete mode 100644 array/data/dt.array/functions/test/api/reduce/set/test_difference.mcfunction create mode 100644 array/data/dt.array/functions/test/api/reduce/set/test_value_difference.mcfunction create mode 100644 inventory/data/dt.inventory/functions/api/item/loot/insert.mcfunction create mode 100644 inventory/data/dt.inventory/functions/api/items/loot/insert.mcfunction create mode 100644 inventory/data/dt.inventory/functions/test/api/item/loot/test_insert.mcfunction create mode 100644 inventory/data/dt.inventory/functions/test/api/items/loot/test_insert.mcfunction diff --git a/array/data/dt.array/functions/api/experimental/call_sum.mcfunction b/array/data/dt.array/functions/api/experimental/call_sum.mcfunction index 872488cc1..e09639322 100644 --- a/array/data/dt.array/functions/api/experimental/call_sum.mcfunction +++ b/array/data/dt.array/functions/api/experimental/call_sum.mcfunction @@ -1,5 +1,4 @@ function call_stack:push data modify storage call_stack: call.arg0 set value [1,2,3,4] function dt.array:api/experimental/sum -tellraw @p ["call_sum call.return: ",{"nbt":"call.return","storage":"call_stack:"}] function call_stack:pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/helper/math/add_with_max.mcfunction b/array/data/dt.array/functions/api/helper/math/add_with_max.mcfunction new file mode 100644 index 000000000..5c8a943ea --- /dev/null +++ b/array/data/dt.array/functions/api/helper/math/add_with_max.mcfunction @@ -0,0 +1,19 @@ +function call_stack:push +execute store result score #augend dt.tmp run data get storage call_stack: this.arg0 +execute store result score #addend dt.tmp run data get storage call_stack: this.arg1 +execute store result score #max dt.tmp run data get storage call_stack: this.arg2 +data modify storage call_stack: this.return set value [0] + +scoreboard players operation #sum dt.tmp = #augend dt.tmp +scoreboard players operation #sum dt.tmp += #addend dt.tmp + +scoreboard players set #remainder dt.tmp 0 +execute if score #sum dt.tmp > #max dt.tmp run scoreboard players operation #remainder dt.tmp = #sum dt.tmp +execute if score #sum dt.tmp > #max dt.tmp run scoreboard players operation #remainder dt.tmp %= #max dt.tmp +execute if score #sum dt.tmp > #max dt.tmp run scoreboard players operation #sum dt.tmp = #max dt.tmp + +execute store result storage call_stack: this.return[0] int 1 run scoreboard players get #sum dt.tmp +execute if score #remainder dt.tmp matches 1.. run data modify storage call_stack: this.return append value 0 +execute if score #remainder dt.tmp matches 1.. store result storage call_stack: this.return[1] int 1 run scoreboard players get #remainder dt.tmp + +function call_stack:pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/helper/math/to_sum_components.mcfunction b/array/data/dt.array/functions/api/helper/math/to_sum_components.mcfunction new file mode 100644 index 000000000..4f92c0621 --- /dev/null +++ b/array/data/dt.array/functions/api/helper/math/to_sum_components.mcfunction @@ -0,0 +1,19 @@ +function call_stack:push +execute store result score #total dt.tmp run data get storage call_stack: this.arg0 +execute store result score #max dt.tmp run data get storage call_stack: this.arg1 + +scoreboard players operation #remainder dt.tmp = #total dt.tmp +scoreboard players operation #remainder dt.tmp %= #max dt.tmp + +scoreboard players operation #num_max dt.tmp = #total dt.tmp +scoreboard players operation #num_max dt.tmp /= #max dt.tmp + +execute store result storage call_stack: call.arg0 int 1 run scoreboard players get #num_max dt.tmp +execute store result storage call_stack: call.arg1 int 1 run scoreboard players get #max dt.tmp +function dt.array:api/n_array_of +data modify storage call_stack: this.return set from storage call_stack: call.return + +execute if score #remainder dt.tmp matches 1.. run data modify storage call_stack: this.return append value 0 +execute if score #remainder dt.tmp matches 1.. store result storage call_stack: this.return[-1] int 1 run scoreboard players get #remainder dt.tmp + +function call_stack:pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/map/key_value/to_values.mcfunction b/array/data/dt.array/functions/api/map/key_value/to_values.mcfunction index 558547f7a..dcfa3e1a2 100644 --- a/array/data/dt.array/functions/api/map/key_value/to_values.mcfunction +++ b/array/data/dt.array/functions/api/map/key_value/to_values.mcfunction @@ -8,6 +8,5 @@ # array of values function call_stack:push data modify storage call_stack: this.return set value [] -tellraw @p ["to_values this.arg0: ",{"nbt":"this.arg0","storage":"call_stack:"}] data modify storage call_stack: this.return append from storage call_stack: this.arg0[].value function call_stack:pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/reduce/math/cumulative_add.mcfunction b/array/data/dt.array/functions/api/reduce/math/cumulative_add.mcfunction new file mode 100644 index 000000000..16f186937 --- /dev/null +++ b/array/data/dt.array/functions/api/reduce/math/cumulative_add.mcfunction @@ -0,0 +1,27 @@ + +data modify storage call_stack: call.accumulator set value [] +function dt.array:api/func/reducer/push +# arg1 = amount +# arg2 = max +execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg0 set from storage call_stack: this.head +execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg1 set from storage call_stack: this.arg1 +execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg2 set from storage call_stack: this.arg2 +execute if data storage call_stack: this.continue run tellraw @p ["cumulative_addAA call: ",{"nbt":"call","storage":"call_stack:"}] +execute if data storage call_stack: this.continue run function dt.array:api/helper/math/add_with_max +execute if data storage call_stack: this.continue run tellraw @p ["cumulative_addAA call.return: ",{"nbt":"call.return","storage":"call_stack:"}] +execute if data storage call_stack: this.continue run data modify storage call_stack: this.accumulator append from storage call_stack: call.return[0] +execute if data storage call_stack: this.continue run data modify storage call_stack: this.arg1 set value 0 +execute if data storage call_stack: this.continue if data storage call_stack: call.return[1] run data modify storage call_stack: this.arg1 set from storage call_stack: call.return[1] +execute if data storage call_stack: this.continue unless data storage call_stack: call.return[1] run data modify storage call_stack: this.accumulator append from storage call_stack: this.tail[] +execute if data storage call_stack: this.continue unless data storage call_stack: call.return[1] run data modify storage call_stack: this.tail set value [] +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run data modify storage call_stack: call.arg0 set from storage call_stack: this.arg1 +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run data modify storage call_stack: call.arg1 set from storage call_stack: this.arg2 +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run tellraw @p ["cumulative_add call: ",{"nbt":"call","storage":"call_stack:"}] +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run function dt.array:api/helper/math/to_sum_components +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run tellraw @p ["cumulative_add call.return: ",{"nbt":"call.return","storage":"call_stack:"}] +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run data modify storage call_stack: this.accumulator append from storage call_stack: call.return[] +execute if data storage call_stack: this.continue unless data storage call_stack: this.tail[0] run data modify storage call_stack: this.tail set value [] + +execute if data storage call_stack: this.continue run function dt.array:api/func/reducer/args/set +execute if data storage call_stack: this.continue run function dt.array:api/reduce/math/cumulative_add +function dt.array:api/func/pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/reduce/set/difference.mcfunction b/array/data/dt.array/functions/api/reduce/set/value_difference.mcfunction similarity index 93% rename from array/data/dt.array/functions/api/reduce/set/difference.mcfunction rename to array/data/dt.array/functions/api/reduce/set/value_difference.mcfunction index 3a96b2f4c..64d5779c7 100644 --- a/array/data/dt.array/functions/api/reduce/set/difference.mcfunction +++ b/array/data/dt.array/functions/api/reduce/set/value_difference.mcfunction @@ -1,4 +1,4 @@ -#> dt.array:api/reduce/set/difference +#> dt.array:api/reduce/set/value_difference # the difference between two arrays. Elements common to both lists will not be included in the output. Elements only in the first will be included in the output. # @params # storage call_stack: call.arg0 @@ -10,11 +10,11 @@ # array data modify storage call_stack: call.accumulator set value [] function dt.array:api/func/reducer/push -execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg0 set from storage call_stack: this.head -execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg1 set from storage call_stack: this.arg1 +execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg0 set from storage call_stack: this.arg1 +execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg1 set from storage call_stack: this.head execute if data storage call_stack: this.continue run function dt.array:api/helper/is_in_set execute if data storage call_stack: this.continue unless data storage call_stack: call.return run data modify storage call_stack: this.accumulator append from storage call_stack: this.head execute if data storage call_stack: this.continue run function dt.array:api/func/reducer/args/set -execute if data storage call_stack: this.continue run function dt.array:api/reduce/set/difference +execute if data storage call_stack: this.continue run function dt.array:api/reduce/set/value_difference function dt.array:api/func/pop \ No newline at end of file diff --git a/array/data/dt.array/functions/api/split/in_set_unique.mcfunction b/array/data/dt.array/functions/api/split/in_set_unique.mcfunction index c4ea223fa..d7a6e23b7 100644 --- a/array/data/dt.array/functions/api/split/in_set_unique.mcfunction +++ b/array/data/dt.array/functions/api/split/in_set_unique.mcfunction @@ -24,7 +24,7 @@ execute unless data storage call_stack: this.continue run data modify storage ca execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg0 set from storage call_stack: this.set execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg1 set value [] execute if data storage call_stack: this.continue run data modify storage call_stack: call.arg1 append from storage call_stack: this.values[0] -execute if data storage call_stack: this.continue run function dt.array:api/difference +execute if data storage call_stack: this.continue run function dt.array:api/reduce/set/value_difference execute if data storage call_stack: this.continue run data modify storage call_stack: this.set_diff set from storage call_stack: call.return execute if data storage call_stack: this.continue run scoreboard players reset $size1 dt.tmp diff --git a/array/data/dt.array/functions/test/api/helper/math/test_add_with_max.mcfunction b/array/data/dt.array/functions/test/api/helper/math/test_add_with_max.mcfunction new file mode 100644 index 000000000..e8ced4110 --- /dev/null +++ b/array/data/dt.array/functions/test/api/helper/math/test_add_with_max.mcfunction @@ -0,0 +1,66 @@ +# function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "Test add_with_max" +function unittest:api/test_suite/setup + +data modify storage unittest:in name set value "Test over max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 2 +data modify storage call_stack: call.arg1 set value 15 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/helper/math/add_with_max +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16,1] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +data modify storage unittest:in name set value "Test below max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 9 +data modify storage call_stack: call.arg1 set value 1 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/helper/math/add_with_max +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [10] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + + +data modify storage unittest:in name set value "Test at max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 9 +data modify storage call_stack: call.arg1 set value 7 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/helper/math/add_with_max +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +data modify storage unittest:in name set value "Test already over max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 19 +data modify storage call_stack: call.arg1 set value 7 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/helper/math/add_with_max +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16,10] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +function unittest:api/test_suite/teardown \ No newline at end of file diff --git a/array/data/dt.array/functions/test/api/helper/math/test_to_sum_components.mcfunction b/array/data/dt.array/functions/test/api/helper/math/test_to_sum_components.mcfunction new file mode 100644 index 000000000..eb4e300ac --- /dev/null +++ b/array/data/dt.array/functions/test/api/helper/math/test_to_sum_components.mcfunction @@ -0,0 +1,50 @@ +function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "Test to_sum_components" +function unittest:api/test_suite/setup + +data modify storage unittest:in name set value "Test sum greater than max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 14 +data modify storage call_stack: call.arg1 set value 4 +function dt.array:api/helper/math/to_sum_components +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [4,4,4,2] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + + +data modify storage unittest:in name set value "Test sum equal to max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 14 +data modify storage call_stack: call.arg1 set value 14 +function dt.array:api/helper/math/to_sum_components +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [14] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + + + +data modify storage unittest:in name set value "Test sum less than to max" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value 14 +data modify storage call_stack: call.arg1 set value 19 +function dt.array:api/helper/math/to_sum_components +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [14] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +function unittest:api/test_suite/teardown \ No newline at end of file diff --git a/array/data/dt.array/functions/test/api/math/test_cumulative_add.mcfunction b/array/data/dt.array/functions/test/api/math/test_cumulative_add.mcfunction new file mode 100644 index 000000000..038e2527a --- /dev/null +++ b/array/data/dt.array/functions/test/api/math/test_cumulative_add.mcfunction @@ -0,0 +1,46 @@ +# function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "Test Cumulative Add" +function unittest:api/test_suite/setup + +data modify storage unittest:in name set value "Test 1" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value [16,2,4,9] +data modify storage call_stack: call.arg1 set value 15 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/reduce/math/cumulative_add +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16,16,5,9] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + +data modify storage unittest:in name set value "Test over" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value [16,15,14] +data modify storage call_stack: call.arg1 set value 5 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/reduce/math/cumulative_add +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16,16,16,2] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +data modify storage unittest:in name set value "Test over 2" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value [16,19,14] +data modify storage call_stack: call.arg1 set value 5 +data modify storage call_stack: call.arg2 set value 16 +function dt.array:api/reduce/math/cumulative_add +data modify storage unittest:in actual set from storage call_stack: call.return +data modify storage unittest:in expected set value [16,16,16,6] +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + +function unittest:api/test_suite/teardown \ No newline at end of file diff --git a/array/data/dt.array/functions/test/api/reduce/set/test_difference.mcfunction b/array/data/dt.array/functions/test/api/reduce/set/test_difference.mcfunction deleted file mode 100644 index ef0db2d92..000000000 --- a/array/data/dt.array/functions/test/api/reduce/set/test_difference.mcfunction +++ /dev/null @@ -1,75 +0,0 @@ -function unittest:api/config/enable/detailed_results -data modify storage unittest:in name set value "array difference" -function unittest:api/test_suite/setup - - -data modify storage unittest:in name set value "b_subset_a" -function unittest:api/test_case/setup -data modify storage unittest:in expected set value [1,3,4] -function call_stack:push -data modify storage call_stack: call.arg0 set value [1,2,3,4,5] -data modify storage call_stack: call.arg1 set value [2,5] -function dt.array:api/reduce/set/difference -data modify storage unittest:in actual set from storage call_stack: call.return -function call_stack:pop -function unittest:api/assert/equal -function unittest:api/test_case/teardown - - - -data modify storage unittest:in name set value "a_subset_b" -function unittest:api/test_case/setup -data modify storage unittest:in expected set value [] -function call_stack:push -data modify storage call_stack: call.arg0 set value [2,5] -data modify storage call_stack: call.arg1 set value [1,2,3,4,5] -function dt.array:api/reduce/set/difference -data modify storage unittest:in actual set from storage call_stack: call.return -function call_stack:pop -function unittest:api/assert/equal -function unittest:api/test_case/teardown - - - -data modify storage unittest:in name set value "between_objects" -function unittest:api/test_case/setup -data modify storage unittest:in expected set value [{id:"c", value:456},{id:"d", value:789}] -function call_stack:push -data modify storage call_stack: call.arg0 set value [{id:"a", value:123},{id:"c", value:456},{id:"a", value:123},{id:"d", value:789}] -data modify storage call_stack: call.arg1 set value [{id:"a", value:123}] -function dt.array:api/reduce/set/difference -data modify storage unittest:in actual set from storage call_stack: call.return -function call_stack:pop -function unittest:api/assert/equal -function unittest:api/test_case/teardown - - - -data modify storage unittest:in name set value "first_is_empty_list" -function unittest:api/test_case/setup -data modify storage unittest:in expected set value [] -function call_stack:push -data modify storage call_stack: call.arg0 set value [] -data modify storage call_stack: call.arg1 set value [2,5] -function dt.array:api/reduce/set/difference -data modify storage unittest:in actual set from storage call_stack: call.return -function call_stack:pop -function unittest:api/assert/equal -function unittest:api/test_case/teardown - - - -data modify storage unittest:in name set value "second_is_empty_list" -function unittest:api/test_case/setup -data modify storage unittest:in expected set value [2,5] -function call_stack:push -data modify storage call_stack: call.arg0 set value [2,5] -data modify storage call_stack: call.arg1 set value [] -function dt.array:api/reduce/set/difference -data modify storage unittest:in actual set from storage call_stack: call.return -function call_stack:pop -function unittest:api/assert/equal -function unittest:api/test_case/teardown - - -function unittest:api/test_suite/teardown diff --git a/array/data/dt.array/functions/test/api/reduce/set/test_value_difference.mcfunction b/array/data/dt.array/functions/test/api/reduce/set/test_value_difference.mcfunction new file mode 100644 index 000000000..68cbcb506 --- /dev/null +++ b/array/data/dt.array/functions/test/api/reduce/set/test_value_difference.mcfunction @@ -0,0 +1,75 @@ +function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "array difference" +function unittest:api/test_suite/setup + + +data modify storage unittest:in name set value "b_subset_a" +function unittest:api/test_case/setup +data modify storage unittest:in expected set value [1,3,4] +function call_stack:push +data modify storage call_stack: call.arg0 set value [1,2,3,4,5] +data modify storage call_stack: call.arg1 set value [2,5] +function dt.array:api/reduce/set/value_difference +data modify storage unittest:in actual set from storage call_stack: call.return +function call_stack:pop +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + +# data modify storage unittest:in name set value "a_subset_b" +# function unittest:api/test_case/setup +# data modify storage unittest:in expected set value [] +# function call_stack:push +# data modify storage call_stack: call.arg0 set value [2,5] +# data modify storage call_stack: call.arg1 set value [1,2,3,4,5] +# function dt.array:api/reduce/set/value_difference +# data modify storage unittest:in actual set from storage call_stack: call.return +# function call_stack:pop +# function unittest:api/assert/equal +# function unittest:api/test_case/teardown + + + +# data modify storage unittest:in name set value "between_objects" +# function unittest:api/test_case/setup +# data modify storage unittest:in expected set value [{id:"c", value:456},{id:"d", value:789}] +# function call_stack:push +# data modify storage call_stack: call.arg0 set value [{id:"a", value:123},{id:"c", value:456},{id:"a", value:123},{id:"d", value:789}] +# data modify storage call_stack: call.arg1 set value [{id:"a", value:123}] +# function dt.array:api/reduce/set/value_difference +# data modify storage unittest:in actual set from storage call_stack: call.return +# function call_stack:pop +# function unittest:api/assert/equal +# function unittest:api/test_case/teardown + + + +# data modify storage unittest:in name set value "first_is_empty_list" +# function unittest:api/test_case/setup +# data modify storage unittest:in expected set value [] +# function call_stack:push +# data modify storage call_stack: call.arg0 set value [] +# data modify storage call_stack: call.arg1 set value [2,5] +# function dt.array:api/reduce/set/value_difference +# data modify storage unittest:in actual set from storage call_stack: call.return +# function call_stack:pop +# function unittest:api/assert/equal +# function unittest:api/test_case/teardown + + + +# data modify storage unittest:in name set value "second_is_empty_list" +# function unittest:api/test_case/setup +# data modify storage unittest:in expected set value [2,5] +# function call_stack:push +# data modify storage call_stack: call.arg0 set value [2,5] +# data modify storage call_stack: call.arg1 set value [] +# function dt.array:api/reduce/set/value_difference +# data modify storage unittest:in actual set from storage call_stack: call.return +# function call_stack:pop +# function unittest:api/assert/equal +# function unittest:api/test_case/teardown + + +function unittest:api/test_suite/teardown diff --git a/crafting/data/dt.crafting/functions/internal/crafter/balance_items_loop.mcfunction b/crafting/data/dt.crafting/functions/internal/crafter/balance_items_loop.mcfunction index d43bad00c..f63d1f166 100644 --- a/crafting/data/dt.crafting/functions/internal/crafter/balance_items_loop.mcfunction +++ b/crafting/data/dt.crafting/functions/internal/crafter/balance_items_loop.mcfunction @@ -16,7 +16,7 @@ data modify storage call_stack: this.slots_existing_balanced set from storage ca # the true free slots are the free_slots - balanced_slots data modify storage call_stack: call.arg0 set from storage call_stack: this.free_slots data modify storage call_stack: call.arg1 set from storage call_stack: this.slots_existing_balanced -function dt.array:api/difference +function dt.array:api/reduce/set/value_difference data modify storage call_stack: this.free_slots set from storage call_stack: call.return execute store result score #num_free dt.tmp run data get storage call_stack: this.free_slots diff --git a/inventory/data/dt.inventory/functions/api/item/loot/insert.mcfunction b/inventory/data/dt.inventory/functions/api/item/loot/insert.mcfunction new file mode 100644 index 000000000..5f544ffee --- /dev/null +++ b/inventory/data/dt.inventory/functions/api/item/loot/insert.mcfunction @@ -0,0 +1,36 @@ +function call_stack:push +data modify storage call_stack: this.source_item set from storage call_stack: this.arg0 +data modify storage call_stack: this.dest_items set from storage call_stack: this.arg1 +data modify storage call_stack: this.max_slots set from storage call_stack: this.arg2 + +# turn dest items to key value pairs +# get items that are equal to it in the dest_items +# cumulative add the counts + +data modify storage call_stack: call.arg0 set from storage call_stack: this.dest_items +function dt.array:api/map/key_value/from_values +function call_stack:pipe +data remove storage call_stack: call.arg0[].key.Slot +data remove storage call_stack: call.arg0[].key.Count +data modify storage call_stack: call.arg1 set from storage call_stack: this.source_item +data remove storage call_stack: call.arg1.Slot +data remove storage call_stack: call.arg1.Count +function dt.array:api/reduce/subarray/equal_to +data modify storage call_stack: this.dest_items_of_same set value [] +data modify storage call_stack: this.dest_items_of_same append from storage call_stack: call.return[0][].value +data modify storage call_stack: this.dest_items_of_diff set value [] +data modify storage call_stack: this.dest_items_of_diff append from storage call_stack: call.return[1][].value + + +data modify storage call_stack: call.arg0 set value [] +data modify storage call_stack: call.arg0 append from storage call_stack: this.dest_items_of_same[].Count +data modify storage call_stack: call.arg1 set from storage call_stack: this.source_item.Count +data modify storage call_stack: call.arg2 set value 64 +# TODO: properly get the stackSize +function dt.array:api/reduce/math/cumulative_add +data modify storage call_stack: this.new_counts set from storage call_stack: call.return + +execute store result storage call_stack: call.arg0 int 1 run data get storage call_stack: this.new_counts +function dt.array:api/n_array_of + +function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/items/combine.mcfunction b/inventory/data/dt.inventory/functions/api/items/combine.mcfunction index d50ac3894..d8024552b 100644 --- a/inventory/data/dt.inventory/functions/api/items/combine.mcfunction +++ b/inventory/data/dt.inventory/functions/api/items/combine.mcfunction @@ -14,7 +14,7 @@ data modify storage call_stack: call.arg0 set from storage call_stack: this.item function dt.inventory:api/shulker/items/set2 function dt.inventory:api/shulker/items/clear -execute positioned 2999999 255 2999999 run function dt.inventory:api/shulker/loot/insert/block2 +execute in overworld positioned 2999999 255 2999999 run function dt.inventory:api/shulker/loot/insert/block2 function dt.inventory:api/shulker/items/get data modify storage call_stack: this.return set from storage call_stack: call.return diff --git a/inventory/data/dt.inventory/functions/api/items/loot/insert.mcfunction b/inventory/data/dt.inventory/functions/api/items/loot/insert.mcfunction new file mode 100644 index 000000000..ef3533d61 --- /dev/null +++ b/inventory/data/dt.inventory/functions/api/items/loot/insert.mcfunction @@ -0,0 +1,12 @@ +function call_stack:push +data modify storage call_stack: this.source_items set from storage call_stack: this.arg0 +data modify storage call_stack: this.dest_items set from storage call_stack: this.arg1 +data modify storage call_stack: this.max_slots set from storage call_stack: this.arg2 + +# +# +# +# +# + +function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/player/item/replace.mcfunction b/inventory/data/dt.inventory/functions/api/player/item/replace.mcfunction index 3eff60f9c..cf33d003a 100644 --- a/inventory/data/dt.inventory/functions/api/player/item/replace.mcfunction +++ b/inventory/data/dt.inventory/functions/api/player/item/replace.mcfunction @@ -18,61 +18,61 @@ execute if data storage call_stack: {this:{return:false}} if score $int1 dt.tmp execute if data storage call_stack: {this:{return:false}} if score $int1 dt.tmp matches -106 run data modify storage call_stack: this.return set value true data modify storage call_stack: this.item.Slot set value 0 -data modify block 2999999 255 2999999 Items set value [] -data modify block 2999999 255 2999999 Items append from storage call_stack: this.item +execute in overworld run data modify block 2999999 255 2999999 Items set value [] +execute in overworld run data modify block 2999999 255 2999999 Items append from storage call_stack: this.item #[[[cog # for slot in range(0,9): -# cog.outl(f'execute if score $int1 dt.tmp matches {slot} run loot replace entity @s hotbar.{slot} 1 mine 2999999 255 2999999 stick{{drop_contents:true}}') +# cog.outl(f'execute in overworld if score $int1 dt.tmp matches {slot} run loot replace entity @s hotbar.{slot} 1 mine 2999999 255 2999999 stick{{drop_contents:true}}') #]]] -execute if score $int1 dt.tmp matches 0 run loot replace entity @s hotbar.0 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 1 run loot replace entity @s hotbar.1 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 2 run loot replace entity @s hotbar.2 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 3 run loot replace entity @s hotbar.3 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 4 run loot replace entity @s hotbar.4 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 5 run loot replace entity @s hotbar.5 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 6 run loot replace entity @s hotbar.6 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 7 run loot replace entity @s hotbar.7 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 8 run loot replace entity @s hotbar.8 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 0 run loot replace entity @s hotbar.0 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 1 run loot replace entity @s hotbar.1 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 2 run loot replace entity @s hotbar.2 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 3 run loot replace entity @s hotbar.3 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 4 run loot replace entity @s hotbar.4 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 5 run loot replace entity @s hotbar.5 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 6 run loot replace entity @s hotbar.6 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 7 run loot replace entity @s hotbar.7 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 8 run loot replace entity @s hotbar.8 1 mine 2999999 255 2999999 stick{drop_contents:true} #[[[end]]] #[[[cog # for score in range(9,36): -# cog.outl(f'execute if score $int1 dt.tmp matches {score} run loot replace entity @s inventory.{score - 9} 1 mine 2999999 255 2999999 stick{{drop_contents:true}}') +# cog.outl(f'execute in overworld if score $int1 dt.tmp matches {score} run loot replace entity @s inventory.{score - 9} 1 mine 2999999 255 2999999 stick{{drop_contents:true}}') #]]] -execute if score $int1 dt.tmp matches 9 run loot replace entity @s inventory.0 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 10 run loot replace entity @s inventory.1 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 11 run loot replace entity @s inventory.2 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 12 run loot replace entity @s inventory.3 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 13 run loot replace entity @s inventory.4 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 14 run loot replace entity @s inventory.5 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 15 run loot replace entity @s inventory.6 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 16 run loot replace entity @s inventory.7 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 17 run loot replace entity @s inventory.8 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 18 run loot replace entity @s inventory.9 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 19 run loot replace entity @s inventory.10 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 20 run loot replace entity @s inventory.11 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 21 run loot replace entity @s inventory.12 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 22 run loot replace entity @s inventory.13 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 23 run loot replace entity @s inventory.14 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 24 run loot replace entity @s inventory.15 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 25 run loot replace entity @s inventory.16 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 26 run loot replace entity @s inventory.17 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 27 run loot replace entity @s inventory.18 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 28 run loot replace entity @s inventory.19 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 29 run loot replace entity @s inventory.20 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 30 run loot replace entity @s inventory.21 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 31 run loot replace entity @s inventory.22 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 32 run loot replace entity @s inventory.23 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 33 run loot replace entity @s inventory.24 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 34 run loot replace entity @s inventory.25 1 mine 2999999 255 2999999 stick{drop_contents:true} -execute if score $int1 dt.tmp matches 35 run loot replace entity @s inventory.26 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 9 run loot replace entity @s inventory.0 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 10 run loot replace entity @s inventory.1 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 11 run loot replace entity @s inventory.2 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 12 run loot replace entity @s inventory.3 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 13 run loot replace entity @s inventory.4 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 14 run loot replace entity @s inventory.5 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 15 run loot replace entity @s inventory.6 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 16 run loot replace entity @s inventory.7 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 17 run loot replace entity @s inventory.8 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 18 run loot replace entity @s inventory.9 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 19 run loot replace entity @s inventory.10 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 20 run loot replace entity @s inventory.11 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 21 run loot replace entity @s inventory.12 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 22 run loot replace entity @s inventory.13 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 23 run loot replace entity @s inventory.14 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 24 run loot replace entity @s inventory.15 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 25 run loot replace entity @s inventory.16 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 26 run loot replace entity @s inventory.17 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 27 run loot replace entity @s inventory.18 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 28 run loot replace entity @s inventory.19 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 29 run loot replace entity @s inventory.20 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 30 run loot replace entity @s inventory.21 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 31 run loot replace entity @s inventory.22 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 32 run loot replace entity @s inventory.23 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 33 run loot replace entity @s inventory.24 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 34 run loot replace entity @s inventory.25 1 mine 2999999 255 2999999 stick{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 35 run loot replace entity @s inventory.26 1 mine 2999999 255 2999999 stick{drop_contents:true} #[[[end]]] # Offhand and armor -execute if score $int1 dt.tmp matches -106 run loot replace entity @s weapon.offhand 1 mine 2999999 255 2999999 air{drop_contents:true} -execute if score $int1 dt.tmp matches 100 run loot replace entity @s armor.feet 1 mine 2999999 255 2999999 air{drop_contents:true} -execute if score $int1 dt.tmp matches 101 run loot replace entity @s armor.legs 1 mine 2999999 255 2999999 air{drop_contents:true} -execute if score $int1 dt.tmp matches 102 run loot replace entity @s armor.chest 1 mine 2999999 255 2999999 air{drop_contents:true} -execute if score $int1 dt.tmp matches 103 run loot replace entity @s armor.head 1 mine 2999999 255 2999999 air{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches -106 run loot replace entity @s weapon.offhand 1 mine 2999999 255 2999999 air{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 100 run loot replace entity @s armor.feet 1 mine 2999999 255 2999999 air{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 101 run loot replace entity @s armor.legs 1 mine 2999999 255 2999999 air{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 102 run loot replace entity @s armor.chest 1 mine 2999999 255 2999999 air{drop_contents:true} +execute in overworld if score $int1 dt.tmp matches 103 run loot replace entity @s armor.head 1 mine 2999999 255 2999999 air{drop_contents:true} function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/clear.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/clear.mcfunction index 684eecfd5..4020245b2 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/clear.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/clear.mcfunction @@ -1,3 +1,3 @@ #> dt.inventory:api/shulker/items/clear # clear the items in the shulker -data modify block 2999999 255 2999999 Items set value [] \ No newline at end of file +execute in overworld run data modify block 2999999 255 2999999 Items set value [] \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/clear2.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/clear2.mcfunction index b8561ffef..01506e530 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/clear2.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/clear2.mcfunction @@ -1,3 +1,3 @@ #> dt.inventory:api/shulker/items/clear2 # clear the items in the shulker2 -data modify block 2999999 254 2999999 Items set value [] \ No newline at end of file +execute in overworld run data modify block 2999999 254 2999999 Items set value [] \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/get.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/get.mcfunction index d9903f63c..0e7fb1f3c 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/get.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/get.mcfunction @@ -5,5 +5,5 @@ # list of items function call_stack:push data modify storage call_stack: this.return set value [] -data modify storage call_stack: this.return set from block 2999999 255 2999999 Items +execute in overworld run data modify storage call_stack: this.return set from block 2999999 255 2999999 Items function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/get2.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/get2.mcfunction index e535de02f..9216ae0a9 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/get2.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/get2.mcfunction @@ -5,5 +5,5 @@ # list of items function call_stack:push data modify storage call_stack: this.return set value [] -data modify storage call_stack: this.return set from block 2999999 254 2999999 Items +execute in overworld run data modify storage call_stack: this.return set from block 2999999 254 2999999 Items function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/set.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/set.mcfunction index 930fa0ad7..886b93133 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/set.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/set.mcfunction @@ -12,6 +12,7 @@ data modify storage call_stack: call.arg0 set from storage call_stack: this.item function dt.inventory:api/items/reset_slots data modify storage call_stack: this.items set from storage call_stack: call.return # set items -data modify block 2999999 255 2999999 Items set from storage call_stack: this.items +execute in overworld run data modify block 2999999 255 2999999 Items set value [] +execute in overworld run data modify block 2999999 255 2999999 Items set from storage call_stack: this.items function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/items/set2.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/items/set2.mcfunction index 79c63224e..0b4e17701 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/items/set2.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/items/set2.mcfunction @@ -12,6 +12,6 @@ function dt.inventory:api/items/reset_slots data modify storage call_stack: this.items set from storage call_stack: call.return # set items -data modify block 2999999 254 2999999 Items set from storage call_stack: this.items +execute in overworld run data modify block 2999999 254 2999999 Items set from storage call_stack: this.items function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/loot/give/player.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/loot/give/player.mcfunction index 340d86e97..6bc0c4180 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/loot/give/player.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/loot/give/player.mcfunction @@ -1,3 +1,3 @@ #> dt.inventory:api/shulker/loot/give/player # give the current player loot from the shulker -loot give @s mine 2999999 255 2999999 air{drop_contents:true} \ No newline at end of file +execute in overworld run loot give @s mine 2999999 255 2999999 air{drop_contents:true} \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block.mcfunction index 234fe09f9..e7e76eba3 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block.mcfunction @@ -1,3 +1,16 @@ #> dt.inventory:api/shulker/loot/insert/block # insert items from the shulker into the block -loot insert ~ ~ ~ mine 2999999 255 2999999 minecraft:air{drop_contents:true} \ No newline at end of file + +function call_stack:push + +# Temp block to hold items when doing cross dimension operations +data modify storage call_stack: call.arg0 set value [] +data modify storage call_stack: call.arg0 set from block ~ ~ ~ Items +function dt.inventory:api/shulker/items/set2 + +execute in overworld positioned 2999999 254 2999999 run loot insert ~ ~ ~ mine 2999999 255 2999999 minecraft:air{drop_contents:true} +execute in overworld positioned 2999999 254 2999999 run data modify storage call_stack: this.new_items set from block ~ ~ ~ Items + +data modify block ~ ~ ~ Items set from storage call_stack: this.new_items + +function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block2.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block2.mcfunction index b40dc46e6..80ed9522a 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block2.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/loot/insert/block2.mcfunction @@ -1,3 +1,15 @@ #> dt.inventory:api/shulker/loot/insert/block2 # insert items from the shulker2 into the block -loot insert ~ ~ ~ mine 2999999 254 2999999 minecraft:air{drop_contents:true} \ No newline at end of file +function call_stack:push + +# Temp block to hold items when doing cross dimension operations +data modify storage call_stack: call.arg0 set value [] +data modify storage call_stack: call.arg0 set from block ~ ~ ~ Items +function dt.inventory:api/shulker/items/set + +execute in overworld positioned 2999999 255 2999999 run loot insert ~ ~ ~ mine 2999999 254 2999999 minecraft:air{drop_contents:true} +execute in overworld positioned 2999999 255 2999999 run data modify storage call_stack: this.new_items set from block ~ ~ ~ Items + +data modify block ~ ~ ~ Items set from storage call_stack: this.new_items + +function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/hotbar.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/hotbar.mcfunction index a4dab0cca..a16a998dc 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/hotbar.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/hotbar.mcfunction @@ -1,3 +1,3 @@ #> dt.inventory:api/shulker/loot/replace/entity/hotbar # replace the current player's hotbar items with items in the shulker -loot replace entity @s hotbar.0 9 mine 2999999 255 2999999 minecraft:air{drop_contents:true} \ No newline at end of file +execute in overworld run loot replace entity @s hotbar.0 9 mine 2999999 255 2999999 minecraft:air{drop_contents:true} \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/inventory.mcfunction b/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/inventory.mcfunction index 539a3b805..81c7b98b2 100644 --- a/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/inventory.mcfunction +++ b/inventory/data/dt.inventory/functions/api/shulker/loot/replace/entity/inventory.mcfunction @@ -1,3 +1,3 @@ #> dt.inventory:api/shulker/loot/replace/entity/inventory # replace the current player's inventory with items in the shulker -loot replace entity @s inventory.0 27 mine 2999999 255 2999999 minecraft:air{drop_contents:true} \ No newline at end of file +execute in overworld run loot replace entity @s inventory.0 27 mine 2999999 255 2999999 minecraft:air{drop_contents:true} \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/internal/item/get_item_data_from_name.mcfunction b/inventory/data/dt.inventory/functions/internal/item/get_item_data_from_name.mcfunction index 420ab48c6..b5563b164 100644 --- a/inventory/data/dt.inventory/functions/internal/item/get_item_data_from_name.mcfunction +++ b/inventory/data/dt.inventory/functions/internal/item/get_item_data_from_name.mcfunction @@ -6,14 +6,14 @@ data modify storage call_stack: this.item.id set from storage call_stack: this.n data modify storage call_stack: this.item.tag.drop_contents set value true execute as @e[type=armor_stand,tag=dt_inventory,limit=1] run data modify entity @s HandItems[0] set from storage call_stack: this.item -data modify block 2999999 255 2999999 Items[] set from storage call_stack: this.item -execute unless data storage call_stack: {this:{item:{id:"minecraft:air"}}} as @e[type=armor_stand,tag=dt_inventory,limit=1] at @s run loot replace block 2999999 255 2999999 container.0 mine 2999999 255 2999999 mainhand +execute in overworld run data modify block 2999999 255 2999999 Items[] set from storage call_stack: this.item +execute in overworld unless data storage call_stack: {this:{item:{id:"minecraft:air"}}} as @e[type=armor_stand,tag=dt_inventory,limit=1] at @s run loot replace block 2999999 255 2999999 container.0 mine 2999999 255 2999999 mainhand execute unless data storage call_stack: {this:{item:{id:"minecraft:air"}}} run function dt.inventory:api/shulker/items/get execute unless data storage call_stack: {this:{item:{id:"minecraft:air"}}} run data modify storage call_stack: this.item set from storage call_stack: call.return[0] execute if data storage call_stack: {this:{item:{id:"minecraft:air"}}} run data modify storage call_stack: this.item merge value {tag:{dt:{id:0}}} data modify storage call_stack: this.return set from storage call_stack: this.item.tag.dt # clean up -execute as @e[type=armor_stand,tag=dt_inventory,limit=1] run data modify entity @s HandItems[0] set value {id:"minecraft:air"} +execute in overworld as @e[type=armor_stand,tag=dt_inventory,limit=1] run data modify entity @s HandItems[0] set value {id:"minecraft:air"} function call_stack:pop \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/load.mcfunction b/inventory/data/dt.inventory/functions/load.mcfunction index b5fb7051d..6661fa422 100644 --- a/inventory/data/dt.inventory/functions/load.mcfunction +++ b/inventory/data/dt.inventory/functions/load.mcfunction @@ -37,4 +37,4 @@ scoreboard players set #found dt.enum 0 scoreboard players set #not_found dt.enum 1 function dt.inventory:load_shulker -execute unless entity @e[type=armor_stand,tag=dt_inventory] run summon minecraft:armor_stand 2999999.5 256 2999999.5 {Invulnerable:1b,NoGravity:1b,Invisible:0b,Tags:["dt_inventory"]} \ No newline at end of file +execute in overworld unless entity @e[type=armor_stand,tag=dt_inventory] run summon minecraft:armor_stand 2999999.5 256 2999999.5 {Invulnerable:1b,NoGravity:1b,Invisible:0b,Tags:["dt_inventory"]} \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/load_shulker.mcfunction b/inventory/data/dt.inventory/functions/load_shulker.mcfunction index ad2251df3..0606cf112 100644 --- a/inventory/data/dt.inventory/functions/load_shulker.mcfunction +++ b/inventory/data/dt.inventory/functions/load_shulker.mcfunction @@ -1,7 +1,12 @@ #say load_shulker -forceload add 2999999 2999999 -setblock 2999999 255 2999999 pink_shulker_box replace -setblock 2999999 254 2999999 pink_shulker_box replace -setblock 2999999 253 2999999 chest[type=right, facing=north] replace -setblock 2999998 253 2999999 chest[type=left, facing=north] replace \ No newline at end of file +execute in overworld run forceload add 2999999 2999999 +execute in overworld run setblock 2999999 255 2999999 pink_shulker_box replace +execute in overworld run setblock 2999999 254 2999999 pink_shulker_box replace +execute in overworld run setblock 2999999 253 2999999 chest[type=right, facing=north] replace +execute in overworld run setblock 2999998 253 2999999 chest[type=left, facing=north] replace + + +execute in the_nether run forceload add 2999999 2999999 +execute in the_nether run setblock 2999999 253 2999999 chest[type=right, facing=north] replace +execute in the_nether run setblock 2999998 253 2999999 chest[type=left, facing=north] replace \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/test/api/item/loot/test_insert.mcfunction b/inventory/data/dt.inventory/functions/test/api/item/loot/test_insert.mcfunction new file mode 100644 index 000000000..2f637cb24 --- /dev/null +++ b/inventory/data/dt.inventory/functions/test/api/item/loot/test_insert.mcfunction @@ -0,0 +1,18 @@ +#function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "Test insert" +function unittest:api/test_suite/setup + + +data modify storage unittest:in name set value "Test 1" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value [{id:"minecraft:feather",Count:1b,Slot:0b}] +function call_stack:pop +data modify storage unittest:in expected set value ExpectedValue +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + + +function unittest:api/test_suite/teardown \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/test/api/items/chest/test_set_get.mcfunction b/inventory/data/dt.inventory/functions/test/api/items/chest/test_set_get.mcfunction index a530c1a2a..639d8a0d4 100644 --- a/inventory/data/dt.inventory/functions/test/api/items/chest/test_set_get.mcfunction +++ b/inventory/data/dt.inventory/functions/test/api/items/chest/test_set_get.mcfunction @@ -3,13 +3,13 @@ data modify storage unittest:in name set value "Test items/chest/get" function unittest:api/test_suite/setup -setblock 2999999 250 2999999 chest[type=right, facing=north] replace -setblock 2999998 250 2999999 chest[type=left, facing=north] replace +execute in overworld run setblock 2999999 250 2999999 chest[type=right, facing=north] replace +execute in overworld run setblock 2999998 250 2999999 chest[type=left, facing=north] replace data modify storage unittest:in name set value "Test set and get, right side" function unittest:api/test_case/setup -data modify block 2999999 250 2999999 Items set value [] -data modify block 2999998 250 2999999 Items set value [] +execute in overworld run data modify block 2999999 250 2999999 Items set value [] +execute in overworld run data modify block 2999998 250 2999999 Items set value [] function call_stack:push #[[[cog # from datapack_utils import * @@ -37,18 +37,18 @@ data modify storage call_stack: this.left_chest_items set value [{Slot: 27b, id: data modify storage call_stack: this.right_chest_items set value [{Slot: 0b, id: "minecraft:apple", Count: 1b}, {Slot: 1b, id: "minecraft:granite", Count: 64b}, {Slot: 2b, id: "minecraft:granite", Count: 64b}, {Slot: 3b, id: "minecraft:granite", Count: 64b}, {Slot: 4b, id: "minecraft:granite", Count: 64b}, {Slot: 5b, id: "minecraft:granite", Count: 64b}, {Slot: 6b, id: "minecraft:granite", Count: 64b}, {Slot: 7b, id: "minecraft:granite", Count: 64b}, {Slot: 8b, id: "minecraft:granite", Count: 64b}, {Slot: 9b, id: "minecraft:granite", Count: 64b}, {Slot: 10b, id: "minecraft:granite", Count: 64b}, {Slot: 11b, id: "minecraft:granite", Count: 64b}, {Slot: 12b, id: "minecraft:granite", Count: 64b}, {Slot: 13b, id: "minecraft:granite", Count: 64b}, {Slot: 14b, id: "minecraft:granite", Count: 64b}, {Slot: 15b, id: "minecraft:granite", Count: 64b}, {Slot: 16b, id: "minecraft:granite", Count: 64b}, {Slot: 17b, id: "minecraft:granite", Count: 64b}, {Slot: 18b, id: "minecraft:granite", Count: 64b}, {Slot: 19b, id: "minecraft:granite", Count: 64b}, {Slot: 20b, id: "minecraft:granite", Count: 64b}, {Slot: 21b, id: "minecraft:granite", Count: 64b}, {Slot: 22b, id: "minecraft:granite", Count: 64b}, {Slot: 23b, id: "minecraft:granite", Count: 64b}, {Slot: 24b, id: "minecraft:granite", Count: 64b}, {Slot: 25b, id: "minecraft:granite", Count: 64b}, {Slot: 26b, id: "minecraft:granite", Count: 64b}] #[[[end]]] data modify storage call_stack: call.arg0 set from storage call_stack: this.double_chest_items -execute positioned 2999999 250 2999999 run function dt.inventory:api/items/chest/set -execute positioned 2999999 250 2999999 run data modify storage unittest:in actual set from block ~ ~ ~ Items +execute in overworld positioned 2999999 250 2999999 run function dt.inventory:api/items/chest/set +execute in overworld positioned 2999999 250 2999999 run data modify storage unittest:in actual set from block ~ ~ ~ Items data modify storage unittest:in expected set from storage call_stack: this.right_chest_items function unittest:api/assert/equal # strip slots since those will be different -data modify storage unittest:in actual set from block 2999998 250 2999999 Items +execute in overworld run data modify storage unittest:in actual set from block 2999998 250 2999999 Items data remove storage unittest:in actual[].Slot data modify storage unittest:in expected set from storage call_stack: this.left_chest_items data remove storage unittest:in expected[].Slot function unittest:api/assert/equal -execute positioned 2999999 250 2999999 run function dt.inventory:api/items/chest/get +execute in overworld positioned 2999999 250 2999999 run function dt.inventory:api/items/chest/get data modify storage unittest:in actual set from storage call_stack: call.return data modify storage unittest:in expected set from storage call_stack: this.double_chest_items function unittest:api/assert/equal @@ -60,8 +60,8 @@ function unittest:api/test_case/teardown data modify storage unittest:in name set value "Test set and get, left side" function unittest:api/test_case/setup -data modify block 2999999 250 2999999 Items set value [] -data modify block 2999998 250 2999999 Items set value [] +execute in overworld run data modify block 2999999 250 2999999 Items set value [] +execute in overworld run data modify block 2999998 250 2999999 Items set value [] function call_stack:push #[[[cog # from datapack_utils import * @@ -88,19 +88,19 @@ data modify storage call_stack: this.double_chest_items set value [{Slot: 0b, id data modify storage call_stack: this.left_chest_items set value [{Slot: 27b, id: "minecraft:granite", Count: 64b},{Slot: 28b, id: "minecraft:granite", Count: 64b},{Slot: 29b, id: "minecraft:granite", Count: 64b},{Slot: 30b, id: "minecraft:granite", Count: 64b},{Slot: 31b, id: "minecraft:granite", Count: 64b},{Slot: 32b, id: "minecraft:granite", Count: 64b},{Slot: 33b, id: "minecraft:granite", Count: 64b},{Slot: 34b, id: "minecraft:granite", Count: 64b},{Slot: 35b, id: "minecraft:granite", Count: 64b},{Slot: 36b, id: "minecraft:granite", Count: 64b},{Slot: 37b, id: "minecraft:granite", Count: 64b},{Slot: 38b, id: "minecraft:granite", Count: 64b},{Slot: 39b, id: "minecraft:granite", Count: 64b},{Slot: 40b, id: "minecraft:granite", Count: 64b},{Slot: 41b, id: "minecraft:granite", Count: 64b},{Slot: 42b, id: "minecraft:granite", Count: 64b},{Slot: 43b, id: "minecraft:granite", Count: 64b},{Slot: 44b, id: "minecraft:granite", Count: 64b},{Slot: 45b, id: "minecraft:granite", Count: 64b},{Slot: 46b, id: "minecraft:granite", Count: 64b},{Slot: 47b, id: "minecraft:granite", Count: 64b},{Slot: 48b, id: "minecraft:granite", Count: 64b},{Slot: 49b, id: "minecraft:granite", Count: 64b},{Slot: 50b, id: "minecraft:granite", Count: 64b},{Slot: 51b, id: "minecraft:granite", Count: 64b},{Slot: 52b, id: "minecraft:granite", Count: 64b},{Slot: 53b, id: "minecraft:granite", Count: 64b}] data modify storage call_stack: this.right_chest_items set value [{Slot: 0b, id: "minecraft:apple", Count: 1b}, {Slot: 1b, id: "minecraft:granite", Count: 64b}, {Slot: 2b, id: "minecraft:granite", Count: 64b}, {Slot: 3b, id: "minecraft:granite", Count: 64b}, {Slot: 4b, id: "minecraft:granite", Count: 64b}, {Slot: 5b, id: "minecraft:granite", Count: 64b}, {Slot: 6b, id: "minecraft:granite", Count: 64b}, {Slot: 7b, id: "minecraft:granite", Count: 64b}, {Slot: 8b, id: "minecraft:granite", Count: 64b}, {Slot: 9b, id: "minecraft:granite", Count: 64b}, {Slot: 10b, id: "minecraft:granite", Count: 64b}, {Slot: 11b, id: "minecraft:granite", Count: 64b}, {Slot: 12b, id: "minecraft:granite", Count: 64b}, {Slot: 13b, id: "minecraft:granite", Count: 64b}, {Slot: 14b, id: "minecraft:granite", Count: 64b}, {Slot: 15b, id: "minecraft:granite", Count: 64b}, {Slot: 16b, id: "minecraft:granite", Count: 64b}, {Slot: 17b, id: "minecraft:granite", Count: 64b}, {Slot: 18b, id: "minecraft:granite", Count: 64b}, {Slot: 19b, id: "minecraft:granite", Count: 64b}, {Slot: 20b, id: "minecraft:granite", Count: 64b}, {Slot: 21b, id: "minecraft:granite", Count: 64b}, {Slot: 22b, id: "minecraft:granite", Count: 64b}, {Slot: 23b, id: "minecraft:granite", Count: 64b}, {Slot: 24b, id: "minecraft:granite", Count: 64b}, {Slot: 25b, id: "minecraft:granite", Count: 64b}, {Slot: 26b, id: "minecraft:granite", Count: 64b}] #[[[end]]] -data modify storage call_stack: call.arg0 set from storage call_stack: this.double_chest_items -execute positioned 2999998 250 2999999 run function dt.inventory:api/items/chest/set -execute positioned 2999999 250 2999999 run data modify storage unittest:in actual set from block ~ ~ ~ Items +data modify storage call_stack:zz call.arg0 set from storage call_stack: this.double_chest_items +execute in overworld positioned 2999998 250 2999999 run function dt.inventory:api/items/chest/set +execute in overworld positioned 2999999 250 2999999 run data modify storage unittest:in actual set from block ~ ~ ~ Items data modify storage unittest:in expected set from storage call_stack: this.right_chest_items function unittest:api/assert/equal # strip slots since those will be different -data modify storage unittest:in actual set from block 2999998 250 2999999 Items +execute in overworld run data modify storage unittest:in actual set from block 2999998 250 2999999 Items data remove storage unittest:in actual[].Slot data modify storage unittest:in expected set from storage call_stack: this.left_chest_items data remove storage unittest:in expected[].Slot function unittest:api/assert/equal -execute positioned 2999998 250 2999999 run function dt.inventory:api/items/chest/get +execute in overworld positioned 2999998 250 2999999 run function dt.inventory:api/items/chest/get data modify storage unittest:in actual set from storage call_stack: call.return data modify storage unittest:in expected set from storage call_stack: this.double_chest_items function unittest:api/assert/equal @@ -112,5 +112,5 @@ function unittest:api/test_case/teardown function unittest:api/test_suite/teardown -setblock 2999999 250 2999999 air replace -setblock 2999998 250 2999999 air replace \ No newline at end of file +execute in overworld run setblock 2999999 250 2999999 air replace +execute in overworld run setblock 2999998 250 2999999 air replace \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/test/api/items/loot/test_insert.mcfunction b/inventory/data/dt.inventory/functions/test/api/items/loot/test_insert.mcfunction new file mode 100644 index 000000000..2f637cb24 --- /dev/null +++ b/inventory/data/dt.inventory/functions/test/api/items/loot/test_insert.mcfunction @@ -0,0 +1,18 @@ +#function unittest:api/config/enable/detailed_results +data modify storage unittest:in name set value "Test insert" +function unittest:api/test_suite/setup + + +data modify storage unittest:in name set value "Test 1" +function unittest:api/test_case/setup +function call_stack:push +data modify storage call_stack: call.arg0 set value [{id:"minecraft:feather",Count:1b,Slot:0b}] +function call_stack:pop +data modify storage unittest:in expected set value ExpectedValue +function unittest:api/assert/equal +function unittest:api/test_case/teardown + + + + +function unittest:api/test_suite/teardown \ No newline at end of file diff --git a/inventory/data/dt.inventory/functions/test/api/shulker/loot/insert/test_block.mcfunction b/inventory/data/dt.inventory/functions/test/api/shulker/loot/insert/test_block.mcfunction index 1783223fd..252e6344d 100644 --- a/inventory/data/dt.inventory/functions/test/api/shulker/loot/insert/test_block.mcfunction +++ b/inventory/data/dt.inventory/functions/test/api/shulker/loot/insert/test_block.mcfunction @@ -11,7 +11,7 @@ function dt.inventory:api/shulker/items/clear function dt.inventory:api/shulker/items/clear2 data modify storage call_stack: call.arg0 set from storage call_stack: this.array function dt.inventory:api/shulker/items/set -execute positioned 2999999 254 2999999 run function dt.inventory:api/shulker/loot/insert/block +execute in overworld positioned 2999999 254 2999999 run function dt.inventory:api/shulker/loot/insert/block function dt.inventory:api/shulker/items/get2 data modify storage unittest:in actual set from storage call_stack: call.return function call_stack:pop @@ -29,7 +29,7 @@ function dt.inventory:api/shulker/items/clear function dt.inventory:api/shulker/items/clear2 data modify storage call_stack: call.arg0 set from storage call_stack: this.array function dt.inventory:api/shulker/items/set -execute positioned 2999999 254 2999999 run function dt.inventory:api/shulker/loot/insert/block +execute in overworld positioned 2999999 254 2999999 run function dt.inventory:api/shulker/loot/insert/block function dt.inventory:api/shulker/items/get2 data modify storage unittest:in actual set from storage call_stack: call.return function call_stack:pop diff --git a/inventory/data/dt.inventory/functions/test/api/test_loot_to_block.mcfunction b/inventory/data/dt.inventory/functions/test/api/test_loot_to_block.mcfunction index 5a9d617ce..72e70fbd0 100644 --- a/inventory/data/dt.inventory/functions/test/api/test_loot_to_block.mcfunction +++ b/inventory/data/dt.inventory/functions/test/api/test_loot_to_block.mcfunction @@ -1,21 +1,21 @@ function call_stack:push # Set some container block with items -setblock 2999999 250 2999999 hopper -data modify block 2999999 250 2999999 Items set value [{Slot:0b,id:"minecraft:feather",Count:1b},{Slot:3b,id:"minecraft:feather",Count:1b}] +execute in overworld run setblock 2999999 250 2999999 hopper +execute in overworld run data modify block 2999999 250 2999999 Items set value [{Slot:0b,id:"minecraft:feather",Count:1b},{Slot:3b,id:"minecraft:feather",Count:1b}] data modify storage call_stack: this.items_to_insert set value [{Slot:99b,id:"minecraft:slime_ball",Count:1b}] data modify storage call_stack: this.expected set value [{Slot:0b,id:"minecraft:feather",Count:1b},{Slot:1b,id:"minecraft:slime_ball",Count:1b},{Slot:3b,id:"minecraft:feather",Count:1b}] data modify storage call_stack: call.arg0 set from storage call_stack: this.items_to_insert function dt.inventory:api/shulker/items/set -execute positioned 2999999 250 2999999 run function dt.inventory:api/shulker/loot/insert/block +execute in overworld run execute positioned 2999999 250 2999999 run function dt.inventory:api/shulker/loot/insert/block -data modify storage call_stack: this.actual set from block 2999999 250 2999999 Items +execute in overworld run data modify storage call_stack: this.actual set from block 2999999 250 2999999 Items data modify storage call_stack: this.success set from storage call_stack: call.return execute store success score result dt.tmp run data modify storage call_stack: this.actual set from storage call_stack: this.expected # temporary shim till unittest datapack is used -scoreboard players reset $pased unittest +scoreboard players reset $passed unittest execute if score result dt.tmp = #equal dt.enum run scoreboard players set $passed unittest 1 execute if score result dt.tmp = #not_equal dt.enum run tellraw @p ["",{"text":"Test Failed: ","color":"dark_red"},{"text":"replace_slot hotbar"}] execute if score result dt.tmp = #equal dt.enum run tellraw @p ["",{"text":"Test Passed: ","color":"dark_green"},{"text":"replace_slot hotbar"}]