Skip to content

Commit

Permalink
bugfix: inventory loot insert now works in nether, add WIP changes fo…
Browse files Browse the repository at this point in the history
…r array and inventory
  • Loading branch information
dthigpen committed Feb 6, 2022
1 parent 64bf870 commit 24a9d14
Show file tree
Hide file tree
Showing 36 changed files with 513 additions and 173 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

Loading

0 comments on commit 24a9d14

Please sign in to comment.