diff --git a/NaturalMergeSort/README.md b/NaturalMergeSort/README.md index ae4c6b7195..e5db4bfb80 100644 --- a/NaturalMergeSort/README.md +++ b/NaturalMergeSort/README.md @@ -5,14 +5,28 @@ Efficient Sort of Integer Lists in Minecraft JE 1.16+ # 使い方/How To Use ```mcfunction +## For Integer List +## Any type of integer is OK data modify storage natural_merge_sort: List set value [3,8,1,2,10,5,6,2,9,1,5,4,7] -function natural_merge_sort:ascend +function #natural_merge_sort:ascend data get storage natural_merge_sort: List # => [1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10] -function natural_merge_sort:descend +function #natural_merge_sort:descend data get storage natural_merge_sort: List # => [10, 9, 8, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1] + + +## For Compound List +## Compound needs to have weight. +data modify storage natural_merge_sort: List set value [{weight:3,value:"three"},{weight:8,value:"eight"},{weight:1,value:"one"},{weight:2,value:"two"},{weight:10,value:"ten"},{weight:5,value:"five"},{weight:6,value:"six"},{weight:2,value:"two"},{weight:9,value:"nine"},{weight:1,value:"one"},{weight:5,value:"five"},{weight:4,value:"four"},{weight:7,value:"seven"}] +function #natural_merge_sort:ascend +data get storage natural_merge_sort: List +# => [{weight: 1, value: "one"}, {weight: 1, value: "one"}, {weight: 2, value: "two"}, {weight: 2, value: "two"}, {weight: 3, value: "three"}, {weight: 4, value: "four"}, {weight: 5, value: "five"}, {weight: 5, value: "five"}, {weight: 6, value: "six"}, {weight: 7, value: "seven"}, {weight: 8, value: "eight"}, {weight: 9, value: "nine"}, {weight: 10, value: "ten"}] + +function #natural_merge_sort:descend +data get storage natural_merge_sort: List +# => [{weight: 10, value: "ten"}, {weight: 9, value: "nine"}, {weight: 8, value: "eight"}, {weight: 7, value: "seven"}, {weight: 6, value: "six"}, {weight: 5, value: "five"}, {weight: 5, value: "five"}, {weight: 4, value: "four"}, {weight: 3, value: "three"}, {weight: 2, value: "two"}, {weight: 2, value: "two"}, {weight: 1, value: "one"}, {weight: 1, value: "one"}] ``` # 連絡はこちら/Contact diff --git a/NaturalMergeSort/data/natural_merge_sort/functions/_index.d.mcfunction b/NaturalMergeSort/data/natural_merge_sort/functions/_index.d.mcfunction index 01ec8b35ad..50268e4981 100644 --- a/NaturalMergeSort/data/natural_merge_sort/functions/_index.d.mcfunction +++ b/NaturalMergeSort/data/natural_merge_sort/functions/_index.d.mcfunction @@ -3,11 +3,11 @@ #> 数値配列操作用ストレージ # Storage for sorting operation. -# @within function lib:array/sort_* +# @within function lib:array/sort/int/* # @internal #declare storage natural_merge_sort: #> 計算用ScoreHolder # @internal #declare score_holder $Value1 - #declare score_holder $Value2 \ No newline at end of file + #declare score_holder $Value2 diff --git a/NaturalMergeSort/data/natural_merge_sort/functions/ascend/.mcfunction b/NaturalMergeSort/data/natural_merge_sort/functions/ascend/.mcfunction new file mode 100644 index 0000000000..524c6366af --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort/functions/ascend/.mcfunction @@ -0,0 +1,16 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort:ascend/ +# 渡された数値配列を、昇順にソートします。 +# Sort the specified int list in ascending order. +# @api +# @input storage natural_merge_sort: List +# ソートする数値配列 / the int list to sort + +#define storage natural_merge_sort: + +## compound(でweight持ち)なら +execute if data storage natural_merge_sort: List[0].weight run function natural_merge_sort_for_compound:ascend +## それ以外はリストとして +execute unless data storage natural_merge_sort: List[0].weight run function natural_merge_sort:ascend diff --git a/NaturalMergeSort/data/natural_merge_sort/functions/descend/.mcfunction b/NaturalMergeSort/data/natural_merge_sort/functions/descend/.mcfunction new file mode 100644 index 0000000000..df283053b4 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort/functions/descend/.mcfunction @@ -0,0 +1,16 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort:descend/ +# 渡された数値配列を、昇順にソートします。 +# Sort the specified int list in descending order. +# @api +# @input storage natural_merge_sort: List +# ソートする数値配列 / the int list to sort + +#define storage natural_merge_sort: + +## compound(でweight持ち)なら +execute if data storage natural_merge_sort: List[0].weight run function natural_merge_sort_for_compound:descend +## それ以外はリストとして +execute unless data storage natural_merge_sort: List[0].weight run function natural_merge_sort:descend diff --git a/NaturalMergeSort/data/natural_merge_sort/tags/functions/ascend.json b/NaturalMergeSort/data/natural_merge_sort/tags/functions/ascend.json new file mode 100644 index 0000000000..cbb6312f6f --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort/tags/functions/ascend.json @@ -0,0 +1,5 @@ +{ + "values": [ + "natural_merge_sort:ascend/" + ] +} \ No newline at end of file diff --git a/NaturalMergeSort/data/natural_merge_sort/tags/functions/descend.json b/NaturalMergeSort/data/natural_merge_sort/tags/functions/descend.json new file mode 100644 index 0000000000..ba6aa6eaa1 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort/tags/functions/descend.json @@ -0,0 +1,5 @@ +{ + "values": [ + "natural_merge_sort:descend/" + ] +} \ No newline at end of file diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/_index.d.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/_index.d.mcfunction new file mode 100644 index 0000000000..ef841e6f24 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/_index.d.mcfunction @@ -0,0 +1,13 @@ +#> natural_merge_sort_for_compound:_index.d +# @private + +#> 数値配列操作用ストレージ +# Storage for sorting operation. +# @within function lib:array/sort/compound/* +# @internal + #declare storage natural_merge_sort_for_compound: + +#> 計算用ScoreHolder +# @internal + #declare score_holder $Value1 + #declare score_holder $Value2 diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/ascend.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/ascend.mcfunction new file mode 100644 index 0000000000..e50c7e49bd --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/ascend.mcfunction @@ -0,0 +1,16 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:ascend +# 渡された数値配列を、昇順にソートします。 +# Sort the specified int list in ascending order. +# @api +# @input storage natural_merge_sort: List +# ソートする数値配列 / the int list to sort + +function natural_merge_sort_for_compound:sys/sort +execute unless data storage natural_merge_sort_for_compound: ListAsc[0] run function natural_merge_sort_for_compound:sys/ascend +data modify storage lib: Array set from storage natural_merge_sort_for_compound: ListAsc[0] +# リセット + scoreboard players reset $Value1 Temporary + scoreboard players reset $Value2 Temporary diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/descend.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/descend.mcfunction new file mode 100644 index 0000000000..ba1921dd7d --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/descend.mcfunction @@ -0,0 +1,16 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:descend +# 渡された数値配列を、降順にソートします。 +# Sort the specified int list in descending order. +# @api +# @input storage natural_merge_sort: List +# ソートする数値配列 / the int list to sort + +function natural_merge_sort_for_compound:sys/sort +execute unless data storage natural_merge_sort_for_compound: ListDesc[0] run function natural_merge_sort_for_compound:sys/descend +data modify storage lib: Array set from storage natural_merge_sort_for_compound: ListDesc[0] +# リセット + scoreboard players reset $Value1 Temporary + scoreboard players reset $Value2 Temporary diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend.mcfunction new file mode 100644 index 0000000000..4c1559bc4f --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend.mcfunction @@ -0,0 +1,17 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/ascend +# 昇順を保つようにマージする。 +# Merge in ascending order. +# @within +# natural_merge_sort_for_compound:ascend +# natural_merge_sort_for_compound:sys/descend +# natural_merge_sort_for_compound:sys/sort + +execute store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-1][-1].weight +execute store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-2][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListDesc[-2][-1] run scoreboard players set $Value2 Temporary 2147483647 +data modify storage natural_merge_sort_for_compound: ListAsc set value [[]] +function natural_merge_sort_for_compound:sys/ascend/loop +execute if data storage natural_merge_sort_for_compound: ListAsc[1] run function natural_merge_sort_for_compound:sys/descend diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/loop.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/loop.mcfunction new file mode 100644 index 0000000000..a2a1483905 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/loop.mcfunction @@ -0,0 +1,12 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/ascend/loop +# @within +# natural_merge_sort_for_compound:sys/ascend +# natural_merge_sort_for_compound:sys/ascend/loop + +execute if score $Value1 Temporary <= $Value2 Temporary run function natural_merge_sort_for_compound:sys/ascend/take1 +execute if score $Value2 Temporary <= $Value1 Temporary run function natural_merge_sort_for_compound:sys/ascend/take2 +execute unless data storage natural_merge_sort_for_compound: ListDesc[-1][-1] unless data storage natural_merge_sort_for_compound: ListDesc[-2][-1] run function natural_merge_sort_for_compound:sys/ascend/shift +execute if data storage natural_merge_sort_for_compound: ListDesc[0] run function natural_merge_sort_for_compound:sys/ascend/loop diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/shift.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/shift.mcfunction new file mode 100644 index 0000000000..070c20fb73 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/shift.mcfunction @@ -0,0 +1,12 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/ascend/shift +# @within +# natural_merge_sort_for_compound:sys/ascend/loop + +data remove storage natural_merge_sort_for_compound: ListDesc[-1] +data remove storage natural_merge_sort_for_compound: ListDesc[-1] +execute if data storage natural_merge_sort_for_compound: ListDesc[-1][-1] store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-1][-1].weight +execute if data storage natural_merge_sort_for_compound: ListDesc[-2][-1] store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-2][-1].weight +execute if data storage natural_merge_sort_for_compound: ListDesc[0] run data modify storage natural_merge_sort_for_compound: ListAsc append value [] diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take1.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take1.mcfunction new file mode 100644 index 0000000000..7667902a66 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take1.mcfunction @@ -0,0 +1,11 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/ascend/take1 +# @within +# natural_merge_sort_for_compound:sys/ascend/loop + +data modify storage natural_merge_sort_for_compound: ListAsc[-1] append from storage natural_merge_sort_for_compound: ListDesc[-1][-1] +data remove storage natural_merge_sort_for_compound: ListDesc[-1][-1] +execute store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-1][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListDesc[-1][-1] run scoreboard players set $Value1 Temporary 2147483647 diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take2.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take2.mcfunction new file mode 100644 index 0000000000..31a06317e5 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/ascend/take2.mcfunction @@ -0,0 +1,11 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/ascend/take2 +# @within +# natural_merge_sort_for_compound:sys/ascend/loop + +data modify storage natural_merge_sort_for_compound: ListAsc[-1] append from storage natural_merge_sort_for_compound: ListDesc[-2][-1] +data remove storage natural_merge_sort_for_compound: ListDesc[-2][-1] +execute store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListDesc[-2][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListDesc[-2][-1] run scoreboard players set $Value2 Temporary 2147483647 diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend.mcfunction new file mode 100644 index 0000000000..332099300a --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend.mcfunction @@ -0,0 +1,17 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/descend +# 降順を保つようにマージする。 +# Merge in descending order. +# @within +# natural_merge_sort_for_compound:descend +# natural_merge_sort_for_compound:sys/ascend +# natural_merge_sort_for_compound:sys/sort + +execute store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-1][-1].weight +execute store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-2][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListAsc[-2][-1] run scoreboard players set $Value2 Temporary -2147483648 +data modify storage natural_merge_sort_for_compound: ListDesc set value [[]] +function natural_merge_sort_for_compound:sys/descend/loop +execute if data storage natural_merge_sort_for_compound: ListDesc[1] run function natural_merge_sort_for_compound:sys/ascend diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/loop.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/loop.mcfunction new file mode 100644 index 0000000000..5939b8b161 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/loop.mcfunction @@ -0,0 +1,12 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/descend/loop +# @within +# natural_merge_sort_for_compound:sys/descend +# natural_merge_sort_for_compound:sys/descend/loop + +execute if score $Value1 Temporary >= $Value2 Temporary run function natural_merge_sort_for_compound:sys/descend/take1 +execute if score $Value2 Temporary >= $Value1 Temporary run function natural_merge_sort_for_compound:sys/descend/take2 +execute unless data storage natural_merge_sort_for_compound: ListAsc[-1][-1] unless data storage natural_merge_sort_for_compound: ListAsc[-2][-1] run function natural_merge_sort_for_compound:sys/descend/shift +execute if data storage natural_merge_sort_for_compound: ListAsc[0] run function natural_merge_sort_for_compound:sys/descend/loop diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/shift.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/shift.mcfunction new file mode 100644 index 0000000000..52ed70a5d9 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/shift.mcfunction @@ -0,0 +1,12 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/descend/shift +# @within +# natural_merge_sort_for_compound:sys/descend/loop + +data remove storage natural_merge_sort_for_compound: ListAsc[-1] +data remove storage natural_merge_sort_for_compound: ListAsc[-1] +execute if data storage natural_merge_sort_for_compound: ListAsc[-1][-1] store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-1][-1].weight +execute if data storage natural_merge_sort_for_compound: ListAsc[-2][-1] store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-2][-1].weight +execute if data storage natural_merge_sort_for_compound: ListAsc[0] run data modify storage natural_merge_sort_for_compound: ListDesc append value [] diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take1.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take1.mcfunction new file mode 100644 index 0000000000..bf565a0cc2 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take1.mcfunction @@ -0,0 +1,11 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/descend/take1 +# @within +# natural_merge_sort_for_compound:sys/descend/loop + +data modify storage natural_merge_sort_for_compound: ListDesc[-1] append from storage natural_merge_sort_for_compound: ListAsc[-1][-1] +data remove storage natural_merge_sort_for_compound: ListAsc[-1][-1] +execute store result score $Value1 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-1][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListAsc[-1][-1] run scoreboard players set $Value1 Temporary -2147483648 diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take2.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take2.mcfunction new file mode 100644 index 0000000000..4a2a41e43a --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/descend/take2.mcfunction @@ -0,0 +1,11 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/descend/take2 +# @within +# natural_merge_sort_for_compound:sys/descend/loop + +data modify storage natural_merge_sort_for_compound: ListDesc[-1] append from storage natural_merge_sort_for_compound: ListAsc[-2][-1] +data remove storage natural_merge_sort_for_compound: ListAsc[-2][-1] +execute store result score $Value2 Temporary run data get storage natural_merge_sort_for_compound: ListAsc[-2][-1].weight +execute unless data storage natural_merge_sort_for_compound: ListAsc[-2][-1] run scoreboard players set $Value2 Temporary -2147483648 diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/setup.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/setup.mcfunction new file mode 100644 index 0000000000..92b67458f1 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/setup.mcfunction @@ -0,0 +1,16 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/setup +# ソートする配列をListDescに設定します。 +# Set the list to sort to ListDesc. +# @within +# natural_merge_sort_for_compound:sys/setup +# natural_merge_sort_for_compound:sys/sort + +execute store result score $Value1 Temporary run data get storage lib: Array[-1].weight +execute if score $Value2 Temporary < $Value1 Temporary run data modify storage natural_merge_sort_for_compound: ListDesc append value [] +data modify storage natural_merge_sort_for_compound: ListDesc[-1] append from storage lib: Array[-1] +scoreboard players operation $Value2 Temporary = $Value1 Temporary +data remove storage lib: Array[-1] +execute if data storage lib: Array[0] run function natural_merge_sort_for_compound:sys/setup diff --git a/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/sort.mcfunction b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/sort.mcfunction new file mode 100644 index 0000000000..6dada7a734 --- /dev/null +++ b/NaturalMergeSort/data/natural_merge_sort_for_compound/functions/sys/sort.mcfunction @@ -0,0 +1,15 @@ +### Copyright © 2020 赤石愛 +### This software is released under the MIT License, see LICENSE. + +#> natural_merge_sort_for_compound:sys/sort +# ナチュラルマージソートします。 +# Sort by Natural Merge Sort. +# @within +# natural_merge_sort_for_compound:* +# @input storage natural_merge_sort_for_compound: List +# ソートする数値配列 / the int list to sort + +data modify storage natural_merge_sort_for_compound: ListDesc set value [] +scoreboard players set $Value2 Temporary -2147483648 +execute if data storage lib: Array[0] run function natural_merge_sort_for_compound:sys/setup +function natural_merge_sort_for_compound:sys/ascend diff --git a/NaturalMergeSort/pack.mcmeta b/NaturalMergeSort/pack.mcmeta index c7711fef0a..b6c19625ee 100644 --- a/NaturalMergeSort/pack.mcmeta +++ b/NaturalMergeSort/pack.mcmeta @@ -1,6 +1,6 @@ { - "pack":{ - "pack_format": 26, - "description": "Natural Merge Sort" - } + "pack":{ + "pack_format": 26, + "description": "Natural Merge Sort" + } } diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/.mcfunction index 393445b3c7..339fd9ece0 100644 --- a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/.mcfunction +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/.mcfunction @@ -10,10 +10,8 @@ execute if data storage asset:artifact Lore[0] run function asset_manager:artifact/create/set_lore/vanilla_lore # 装備時効果 # ステータス補正 - data modify storage asset:artifact CopiedModifiers set from storage asset:artifact Equipment.Modifiers - execute if data storage asset:artifact CopiedModifiers[0] if data storage asset:artifact Item.tag.display.Lore[0] run data modify storage asset:artifact Item.tag.display.Lore append value '""' - execute if data storage asset:artifact CopiedModifiers[0] run function asset_manager:artifact/create/set_lore/modifier/ - data remove storage asset:artifact CopiedModifiers + execute if data storage asset:artifact Equipment.Modifiers[0] if data storage asset:artifact Item.tag.display.Lore[0] run data modify storage asset:artifact Item.tag.display.Lore append value '""' + execute if data storage asset:artifact Equipment.Modifiers[0] run function asset_manager:artifact/create/set_lore/modifier/ # セット効果 execute if data storage asset:artifact Equipment.Effects[{Visible:true}] if data storage asset:artifact Item.tag.display.Lore[0] run data modify storage asset:artifact Item.tag.display.Lore append value '""' execute if data storage asset:artifact Equipment.Effects[0] run function asset_manager:artifact/create/set_lore/equipment/ diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/.mcfunction index 6d88b33528..f5dd92c14d 100644 --- a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/.mcfunction +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/.mcfunction @@ -2,104 +2,18 @@ # # 装備時効果の内容をLoreに追加 # -# @within function -# asset_manager:artifact/create/set_lore/ -# asset_manager:artifact/create/set_lore/modifier/ +# @within function asset_manager:artifact/create/set_lore/ -#> temp -# @private - #declare score_holder $AmountFrac - #declare score_holder $AmountFrac2 - #declare score_holder $AmountInt - #declare score_holder $CustomModifier +# 補正が2個以上ならソートする + execute if data storage asset:artifact Equipment.Modifiers[1] run function asset_manager:artifact/create/set_lore/modifier/sort -# 変数を用意 - scoreboard players set $CustomModifier Temporary 0 - data modify storage asset:artifact Modifier set from storage asset:artifact CopiedModifiers[0] - data modify storage asset:artifact Line set value ['{"text":"","color":"green","italic":false}','""','" +"','{"translate":"%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"}]}','""'] +# 補正が2個以上でないならソートされたものとする + execute unless data storage asset:artifact Equipment.Modifiers[1] run data modify storage asset:artifact SortedModifiers set from storage asset:artifact Equipment.Modifiers -# カスタムModifier - execute if data storage asset:artifact Modifier{Type:"attack/base"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/base"} run data modify storage asset:artifact Line[1] set value '"攻撃"' - execute if data storage asset:artifact Modifier{Type:"attack/fire"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/fire"} run data modify storage asset:artifact Line[1] set value '"火攻撃"' - execute if data storage asset:artifact Modifier{Type:"attack/magic"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/magic"} run data modify storage asset:artifact Line[1] set value '"魔法攻撃"' - execute if data storage asset:artifact Modifier{Type:"attack/physical"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/physical"} run data modify storage asset:artifact Line[1] set value '"物理攻撃"' - execute if data storage asset:artifact Modifier{Type:"attack/thunder"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/thunder"} run data modify storage asset:artifact Line[1] set value '"雷攻撃"' - execute if data storage asset:artifact Modifier{Type:"attack/water"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"attack/water"} run data modify storage asset:artifact Line[1] set value '"水攻撃"' - execute if data storage asset:artifact Modifier{Type:"defense/base"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/base"} run data modify storage asset:artifact Line[1] set value '"耐性"' - execute if data storage asset:artifact Modifier{Type:"defense/fire"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/fire"} run data modify storage asset:artifact Line[1] set value '"火耐性"' - execute if data storage asset:artifact Modifier{Type:"defense/magic"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/magic"} run data modify storage asset:artifact Line[1] set value '"魔法耐性"' - execute if data storage asset:artifact Modifier{Type:"defense/physical"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/physical"} run data modify storage asset:artifact Line[1] set value '"物理耐性"' - execute if data storage asset:artifact Modifier{Type:"defense/thunder"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/thunder"} run data modify storage asset:artifact Line[1] set value '"雷耐性"' - execute if data storage asset:artifact Modifier{Type:"defense/water"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"defense/water"} run data modify storage asset:artifact Line[1] set value '"水耐性"' - execute if data storage asset:artifact Modifier{Type:"fall_resistance"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"fall_resistance"} run data modify storage asset:artifact Line[1] set value '"落下耐性"' - execute if data storage asset:artifact Modifier{Type:"heal"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"heal"} run data modify storage asset:artifact Line[1] set value '"与回復量"' - execute if data storage asset:artifact Modifier{Type:"receive_heal"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"receive_heal"} run data modify storage asset:artifact Line[1] set value '"被回復量"' - execute if data storage asset:artifact Modifier{Type:"mp_regen"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"mp_regen"} run data modify storage asset:artifact Line[1] set value '"MP回復量"' - execute if data storage asset:artifact Modifier{Type:"max_health"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"max_health"} run data modify storage asset:artifact Line[1] set value '"最大体力"' - execute if data storage asset:artifact Modifier{Type:"max_mp"} run scoreboard players set $CustomModifier Temporary 1 - execute if data storage asset:artifact Modifier{Type:"max_mp"} run data modify storage asset:artifact Line[1] set value '"最大MP"' - execute if score $CustomModifier Temporary matches 0 run function asset_manager:artifact/create/set_lore/modifier/generic.m with storage asset:artifact Modifier - -# ノックバック耐性だけバニラに合わせて表示を10倍しておく - execute if data storage asset:artifact Modifier{Type:"generic.knockback_resistance"} store result storage asset:artifact Modifier.Amount double 0.1 run data get storage asset:artifact Modifier.Amount 100 - -# 数値チェック -# Operation == "add": -# $AmountInt = floor(abs(Amount)) -# $AmountFrac(e3) = abs(Amount) * e3 % e3 -# Operation != "add": -# $AmountInt(e2) = floor(abs(Amount) * e2) -# $AmountFrac(e5) = abs(Amount) * e5 % e3 - execute store result score $AmountFrac Temporary run data get storage asset:artifact Modifier.Amount 1000 - execute unless data storage asset:artifact Modifier{Operation:"add"} run data modify storage asset:artifact Line[4] set value '"%"' - execute unless data storage asset:artifact Modifier{Operation:"add"} run scoreboard players operation $AmountFrac Temporary *= $100 Const - execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[0] set value '{"text":"","color":"red","italic":false}' - execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[2] set value '" -"' - execute unless score $AmountFrac Temporary matches 0.. run scoreboard players operation $AmountFrac Temporary *= $-1 Const - scoreboard players operation $AmountInt Temporary = $AmountFrac Temporary - scoreboard players operation $AmountInt Temporary /= $1000 Const - scoreboard players operation $AmountFrac Temporary %= $1000 Const -# $AmountFrac % 10 == 0: -# $AmountFrac(e2|e4) = $AmountFrac(e3|e5) / e1 - scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary - scoreboard players operation $AmountFrac2 Temporary %= $10 Const - execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const - scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary - scoreboard players operation $AmountFrac2 Temporary %= $10 Const - execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const -# 文字列に代入 - execute store result storage asset:artifact Amount.Int int 1 run scoreboard players get $AmountInt Temporary - execute store result storage asset:artifact Amount.Frac int 1 run scoreboard players get $AmountFrac Temporary - execute if score $AmountFrac Temporary matches 1.. run data modify storage asset:artifact Line[3] set value '{"translate":"%s.%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"},{"storage":"asset:artifact","nbt":"Amount.Frac"}]}' -# Lore追加 - loot replace block 10000 0 10000 container.0 loot asset_manager:artifact/generate_lore/modifier - data modify storage asset:artifact Item.tag.display.Lore append from block 10000 0 10000 Items[0].tag.display.Lore[] +# 書き出し + function asset_manager:artifact/create/set_lore/modifier/write # リセット - scoreboard players reset $CustomModifier Temporary - scoreboard players reset $AmountInt Temporary - scoreboard players reset $AmountFrac Temporary - scoreboard players reset $AmountFrac2 Temporary - data remove storage asset:artifact Line - data remove storage asset:artifact Amount -# 残っていればループ - data remove storage asset:artifact Modifier - data remove storage asset:artifact CopiedModifiers[0] - execute if data storage asset:artifact CopiedModifiers[0] run function asset_manager:artifact/create/set_lore/modifier/ + data remove storage asset:artifact CopiedModifiers + data remove storage asset:artifact PrioritizedModifiers + data remove storage asset:artifact SortedModifiers diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/generic.m.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/generic.m.mcfunction index 1f3c536c3e..5a59b0d300 100644 --- a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/generic.m.mcfunction +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/generic.m.mcfunction @@ -1,6 +1,6 @@ #> asset_manager:artifact/create/set_lore/modifier/generic.m # @input args # Type : string -# @within function asset_manager:artifact/create/set_lore/modifier/ +# @within function asset_manager:artifact/create/set_lore/modifier/write $data modify storage asset:artifact Line[1] set value '{"translate":"attribute.name.$(Type)"}' diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/define.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/define.mcfunction new file mode 100644 index 0000000000..1e1ae1336a --- /dev/null +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/define.mcfunction @@ -0,0 +1,35 @@ +#> asset_manager:artifact/create/set_lore/modifier/priority/define +# +# 各補正の優先度を定義します +# +# @within function core:load_once + +# 攻撃 + data modify storage asset:artifact ModifierPriority.attack/base set value 255 + data modify storage asset:artifact ModifierPriority.attack/physical set value 254 + data modify storage asset:artifact ModifierPriority.attack/magic set value 253 + data modify storage asset:artifact ModifierPriority.attack/fire set value 252 + data modify storage asset:artifact ModifierPriority.attack/water set value 251 + data modify storage asset:artifact ModifierPriority.attack/thunder set value 250 + +# 耐性 + data modify storage asset:artifact ModifierPriority.defense/base set value 249 + data modify storage asset:artifact ModifierPriority.defense/physical set value 248 + data modify storage asset:artifact ModifierPriority.defense/magic set value 247 + data modify storage asset:artifact ModifierPriority.defense/fire set value 246 + data modify storage asset:artifact ModifierPriority.defense/water set value 245 + data modify storage asset:artifact ModifierPriority.defense/thunder set value 244 + +# その他のTSB固有の補正 + data modify storage asset:artifact ModifierPriority.max_health set value 243 + data modify storage asset:artifact ModifierPriority.heal set value 242 + data modify storage asset:artifact ModifierPriority.receive_heal set value 241 + data modify storage asset:artifact ModifierPriority.max_mp set value 240 + data modify storage asset:artifact ModifierPriority.mp_regen set value 239 + data modify storage asset:artifact ModifierPriority.fall_resistance set value 238 + +# バニラattribute + data modify storage asset:artifact ModifierPriority.generic.armor set value 127 + data modify storage asset:artifact ModifierPriority.generic.armor_toughness set value 126 + data modify storage asset:artifact ModifierPriority.generic.movement_speed set value 125 + data modify storage asset:artifact ModifierPriority.generic.knockback_resistance set value 124 diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.m.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.m.mcfunction new file mode 100644 index 0000000000..8b7bc18a65 --- /dev/null +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.m.mcfunction @@ -0,0 +1,31 @@ +#> asset_manager:artifact/create/set_lore/modifier/priority/set.m +# +# +# +# @within function asset_manager:artifact/create/set_lore/modifier/priority/set + +#> Private +# @private + #declare score_holder $Priority + #declare score_holder $Amount + +# Priorityを取得 + $execute store result score $Priority Temporary run data get storage asset:artifact ModifierPriority.$(Type) + +# 補正の量を取得 + execute store result score $Amount Temporary run data get storage asset:artifact Modifier.Amount 1000 + +# 補正がマイナスならPriorityをメチャクチャ落とす + execute if score $Amount Temporary matches ..1 run scoreboard players remove $Priority Temporary 1024 + +# storageにPriorityを代入 +# lib:array/sort/compound用にweightとして代入する + execute store result storage asset:artifact Modifier.weight int 1 run scoreboard players get $Priority Temporary + +# 別のstorageへまとめて追加しておく + data modify storage asset:artifact PrioritizedModifiers append from storage asset:artifact Modifier + +# リセット + data remove storage asset:artifact Modifier + scoreboard players reset $Priority Temporary + scoreboard players reset $Amount Temporary diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.mcfunction new file mode 100644 index 0000000000..cc0c30fe70 --- /dev/null +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/priority/set.mcfunction @@ -0,0 +1,19 @@ +#> asset_manager:artifact/create/set_lore/modifier/priority/set +# +# +# +# @within function +# asset_manager:artifact/create/set_lore/modifier/sort +# asset_manager:artifact/create/set_lore/modifier/priority/set + +# 必要な変数を用意 + data modify storage asset:artifact Modifier set from storage asset:artifact CopiedModifiers[-1] + +# 優先度をセット + function asset_manager:artifact/create/set_lore/modifier/priority/set.m with storage asset:artifact Modifier + +# 最後尾の要素を削除 + data remove storage asset:artifact CopiedModifiers[-1] + +# 要素がまだあれば再帰 + execute if data storage asset:artifact CopiedModifiers[0] run function asset_manager:artifact/create/set_lore/modifier/priority/set diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/sort.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/sort.mcfunction new file mode 100644 index 0000000000..6aaa7e6bbd --- /dev/null +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/sort.mcfunction @@ -0,0 +1,17 @@ +#> asset_manager:artifact/create/set_lore/modifier/sort +# +# +# +# @within function asset_manager:artifact/create/set_lore/modifier/ + +# 各補正にPriorityを設定 + data modify storage asset:artifact CopiedModifiers set from storage asset:artifact Equipment.Modifiers + function asset_manager:artifact/create/set_lore/modifier/priority/set + +# ソート + function lib:array/session/open + data modify storage lib: Array set from storage asset:artifact PrioritizedModifiers + function lib:array/sort/compound/descend + data modify storage asset:artifact SortedModifiers set from storage lib: Array + function lib:array/session/close + diff --git a/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/write.mcfunction b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/write.mcfunction new file mode 100644 index 0000000000..1da035ccae --- /dev/null +++ b/TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/write.mcfunction @@ -0,0 +1,105 @@ +#> asset_manager:artifact/create/set_lore/modifier/write +# +# +# +# @within function +# asset_manager:artifact/create/set_lore/modifier/ +# asset_manager:artifact/create/set_lore/modifier/write + +#> temp +# @private + #declare score_holder $AmountFrac + #declare score_holder $AmountFrac2 + #declare score_holder $AmountInt + #declare score_holder $CustomModifier + +# 変数を用意 + scoreboard players set $CustomModifier Temporary 0 + data modify storage asset:artifact Modifier set from storage asset:artifact SortedModifiers[0] + data modify storage asset:artifact Line set value ['{"text":"","color":"green","italic":false}','""','" +"','{"translate":"%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"}]}','""'] + +# カスタムModifier + execute if data storage asset:artifact Modifier{Type:"attack/base"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/base"} run data modify storage asset:artifact Line[1] set value '"攻撃"' + execute if data storage asset:artifact Modifier{Type:"attack/fire"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/fire"} run data modify storage asset:artifact Line[1] set value '"火攻撃"' + execute if data storage asset:artifact Modifier{Type:"attack/magic"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/magic"} run data modify storage asset:artifact Line[1] set value '"魔法攻撃"' + execute if data storage asset:artifact Modifier{Type:"attack/physical"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/physical"} run data modify storage asset:artifact Line[1] set value '"物理攻撃"' + execute if data storage asset:artifact Modifier{Type:"attack/thunder"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/thunder"} run data modify storage asset:artifact Line[1] set value '"雷攻撃"' + execute if data storage asset:artifact Modifier{Type:"attack/water"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"attack/water"} run data modify storage asset:artifact Line[1] set value '"水攻撃"' + execute if data storage asset:artifact Modifier{Type:"defense/base"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/base"} run data modify storage asset:artifact Line[1] set value '"耐性"' + execute if data storage asset:artifact Modifier{Type:"defense/fire"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/fire"} run data modify storage asset:artifact Line[1] set value '"火耐性"' + execute if data storage asset:artifact Modifier{Type:"defense/magic"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/magic"} run data modify storage asset:artifact Line[1] set value '"魔法耐性"' + execute if data storage asset:artifact Modifier{Type:"defense/physical"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/physical"} run data modify storage asset:artifact Line[1] set value '"物理耐性"' + execute if data storage asset:artifact Modifier{Type:"defense/thunder"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/thunder"} run data modify storage asset:artifact Line[1] set value '"雷耐性"' + execute if data storage asset:artifact Modifier{Type:"defense/water"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"defense/water"} run data modify storage asset:artifact Line[1] set value '"水耐性"' + execute if data storage asset:artifact Modifier{Type:"fall_resistance"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"fall_resistance"} run data modify storage asset:artifact Line[1] set value '"落下耐性"' + execute if data storage asset:artifact Modifier{Type:"heal"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"heal"} run data modify storage asset:artifact Line[1] set value '"与回復量"' + execute if data storage asset:artifact Modifier{Type:"receive_heal"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"receive_heal"} run data modify storage asset:artifact Line[1] set value '"被回復量"' + execute if data storage asset:artifact Modifier{Type:"mp_regen"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"mp_regen"} run data modify storage asset:artifact Line[1] set value '"MP回復量"' + execute if data storage asset:artifact Modifier{Type:"max_health"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"max_health"} run data modify storage asset:artifact Line[1] set value '"最大体力"' + execute if data storage asset:artifact Modifier{Type:"max_mp"} run scoreboard players set $CustomModifier Temporary 1 + execute if data storage asset:artifact Modifier{Type:"max_mp"} run data modify storage asset:artifact Line[1] set value '"最大MP"' + execute if score $CustomModifier Temporary matches 0 run function asset_manager:artifact/create/set_lore/modifier/generic.m with storage asset:artifact Modifier + +# ノックバック耐性だけバニラに合わせて表示を10倍しておく + execute if data storage asset:artifact Modifier{Type:"generic.knockback_resistance"} store result storage asset:artifact Modifier.Amount double 0.1 run data get storage asset:artifact Modifier.Amount 100 + +# 数値チェック +# Operation == "add": +# $AmountInt = floor(abs(Amount)) +# $AmountFrac(e3) = abs(Amount) * e3 % e3 +# Operation != "add": +# $AmountInt(e2) = floor(abs(Amount) * e2) +# $AmountFrac(e5) = abs(Amount) * e5 % e3 + execute store result score $AmountFrac Temporary run data get storage asset:artifact Modifier.Amount 1000 + execute unless data storage asset:artifact Modifier{Operation:"add"} run data modify storage asset:artifact Line[4] set value '"%"' + execute unless data storage asset:artifact Modifier{Operation:"add"} run scoreboard players operation $AmountFrac Temporary *= $100 Const + execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[0] set value '{"text":"","color":"red","italic":false}' + execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[2] set value '" -"' + execute unless score $AmountFrac Temporary matches 0.. run scoreboard players operation $AmountFrac Temporary *= $-1 Const + scoreboard players operation $AmountInt Temporary = $AmountFrac Temporary + scoreboard players operation $AmountInt Temporary /= $1000 Const + scoreboard players operation $AmountFrac Temporary %= $1000 Const +# $AmountFrac % 10 == 0: +# $AmountFrac(e2|e4) = $AmountFrac(e3|e5) / e1 + scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary + scoreboard players operation $AmountFrac2 Temporary %= $10 Const + execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const + scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary + scoreboard players operation $AmountFrac2 Temporary %= $10 Const + execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const +# 文字列に代入 + execute store result storage asset:artifact Amount.Int int 1 run scoreboard players get $AmountInt Temporary + execute store result storage asset:artifact Amount.Frac int 1 run scoreboard players get $AmountFrac Temporary + execute if score $AmountFrac Temporary matches 1.. run data modify storage asset:artifact Line[3] set value '{"translate":"%s.%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"},{"storage":"asset:artifact","nbt":"Amount.Frac"}]}' +# Lore追加 + loot replace block 10000 0 10000 container.0 loot asset_manager:artifact/generate_lore/modifier + data modify storage asset:artifact Item.tag.display.Lore append from block 10000 0 10000 Items[0].tag.display.Lore[] + +# リセット + scoreboard players reset $CustomModifier Temporary + scoreboard players reset $AmountInt Temporary + scoreboard players reset $AmountFrac Temporary + scoreboard players reset $AmountFrac2 Temporary + data remove storage asset:artifact Line + data remove storage asset:artifact Amount +# 残っていればループ + data remove storage asset:artifact Modifier + data remove storage asset:artifact SortedModifiers[0] + execute if data storage asset:artifact SortedModifiers[0] run function asset_manager:artifact/create/set_lore/modifier/write diff --git a/TheSkyBlessing/data/core/functions/load_once.mcfunction b/TheSkyBlessing/data/core/functions/load_once.mcfunction index 889d2e3d16..99e3abea48 100644 --- a/TheSkyBlessing/data/core/functions/load_once.mcfunction +++ b/TheSkyBlessing/data/core/functions/load_once.mcfunction @@ -182,6 +182,9 @@ team modify NoCollision collisionRule never bossbar set asset:special_cooldown color green bossbar set asset:special_cooldown style notched_10 + # 神器の補正の優先度を定義 + function asset_manager:artifact/create/set_lore/modifier/priority/define + #> AssetManager: Mob -Public # @public scoreboard objectives add MobID dummy {"text":"MobAssetのID"} diff --git a/TheSkyBlessing/data/lib/functions/array/picks.mcfunction b/TheSkyBlessing/data/lib/functions/array/picks.mcfunction index 62a765a9dd..8eb21c1d38 100644 --- a/TheSkyBlessing/data/lib/functions/array/picks.mcfunction +++ b/TheSkyBlessing/data/lib/functions/array/picks.mcfunction @@ -25,7 +25,7 @@ data modify storage lib: ArrayTemp set from storage lib: Array data modify storage lib: Array set from storage lib: Picks # ソート - function lib:array/sort_ascend + function lib:array/sort/int/ascend # 配列を元に戻す data modify storage lib: Picks set from storage lib: Array data modify storage lib: Array set from storage lib: ArrayTemp @@ -50,4 +50,4 @@ data remove storage lib: ArrayTemp scoreboard players reset $Prev Temporary scoreboard players reset $Cur Temporary - scoreboard players reset $ListSize Temporary \ No newline at end of file + scoreboard players reset $ListSize Temporary diff --git a/TheSkyBlessing/data/lib/functions/array/sort/compound/ascend.mcfunction b/TheSkyBlessing/data/lib/functions/array/sort/compound/ascend.mcfunction new file mode 100644 index 0000000000..ebd26406b3 --- /dev/null +++ b/TheSkyBlessing/data/lib/functions/array/sort/compound/ascend.mcfunction @@ -0,0 +1,19 @@ +#> lib:array/sort/compound/ascend +# +# Compund型の配列の要素を昇順ソートします。 +# +# @input +# storage lib: Array: [Compound] @ N +# - 各要素は weightキーを持つ必要があります +# 配列データ +# @output +# storage lib: Array: [Compound] @ N +# 昇順にソートされた配列データ +# @public + + +# セッションチェック + execute if data storage lib: {ArrayLibSessionOpened:false} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:array/のセッションが開かれずに利用されています。","color":"white"}] + +# NaturalMergeSort呼び出し + function natural_merge_sort_for_compound:ascend diff --git a/TheSkyBlessing/data/lib/functions/array/sort/compound/descend.mcfunction b/TheSkyBlessing/data/lib/functions/array/sort/compound/descend.mcfunction new file mode 100644 index 0000000000..6708426b81 --- /dev/null +++ b/TheSkyBlessing/data/lib/functions/array/sort/compound/descend.mcfunction @@ -0,0 +1,19 @@ +#> lib:array/sort/compound/descend +# +# Compund型の配列の要素を降順ソートします。 +# +# @input +# storage lib: Array: [Compound] @ N +# - 各要素は weightキーを持つ必要があります +# 配列データ +# @output +# storage lib: Array: [Compound] @ N +# 降順にソートされた配列データ +# @public + + +# セッションチェック + execute if data storage lib: {ArrayLibSessionOpened:false} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:array/のセッションが開かれずに利用されています。","color":"white"}] + +# NaturalMergeSort呼び出し + function natural_merge_sort_for_compound:descend diff --git a/TheSkyBlessing/data/lib/functions/array/sort_ascend.mcfunction b/TheSkyBlessing/data/lib/functions/array/sort/int/ascend.mcfunction similarity index 88% rename from TheSkyBlessing/data/lib/functions/array/sort_ascend.mcfunction rename to TheSkyBlessing/data/lib/functions/array/sort/int/ascend.mcfunction index 69b9333901..0a3364ba43 100644 --- a/TheSkyBlessing/data/lib/functions/array/sort_ascend.mcfunction +++ b/TheSkyBlessing/data/lib/functions/array/sort/int/ascend.mcfunction @@ -1,4 +1,4 @@ -#> lib:array/sort_ascend +#> lib:array/sort/int/ascend # # 配列の要素を昇順ソートします。 # @@ -15,4 +15,4 @@ execute if data storage lib: {ArrayLibSessionOpened:false} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:array/のセッションが開かれずに利用されています。","color":"white"}] # 実際ただのエイリアスである。 - function natural_merge_sort:ascend \ No newline at end of file + function natural_merge_sort:ascend diff --git a/TheSkyBlessing/data/lib/functions/array/sort_descend.mcfunction b/TheSkyBlessing/data/lib/functions/array/sort/int/descend.mcfunction similarity index 88% rename from TheSkyBlessing/data/lib/functions/array/sort_descend.mcfunction rename to TheSkyBlessing/data/lib/functions/array/sort/int/descend.mcfunction index 3fcbb17187..3645fa684e 100644 --- a/TheSkyBlessing/data/lib/functions/array/sort_descend.mcfunction +++ b/TheSkyBlessing/data/lib/functions/array/sort/int/descend.mcfunction @@ -1,4 +1,4 @@ -#> lib:array/sort_descend +#> lib:array/sort/int/descend # # 配列の要素を降順ソートします。 # @@ -15,4 +15,4 @@ execute if data storage lib: {ArrayLibSessionOpened:false} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:array/のセッションが開かれずに利用されています。","color":"white"}] # 実際ただのエイリアスである。 - function natural_merge_sort:descend \ No newline at end of file + function natural_merge_sort:descend