From 8761af346eaff6319367674789412e349752dcb2 Mon Sep 17 00:00:00 2001 From: xiaodou8593 <51410412+xiaodou8593@users.noreply.github.com> Date: Sun, 16 Jul 2023 22:24:58 +0800 Subject: [PATCH] data structure --- data/math/functions/3vec/_print.mcfunction | 2 + data/math/functions/3vec/_ssprint.mcfunction | 4 +- data/math/functions/_init.mcfunction | 9 ++- data/math/functions/_version.mcfunction | 4 +- data/math/functions/init_overworld.mcfunction | 2 + data/math/functions/list/_fill.mcfunction | 6 ++ data/math/functions/list/_key.mcfunction | 12 ++++ data/math/functions/list/_toset.mcfunction | 16 +++++ .../math/functions/list/fill_sloop.mcfunction | 5 ++ data/math/functions/list/key_sloop.mcfunction | 11 +++ data/math/functions/list/set/sloop.mcfunction | 9 +++ .../functions/list/set/success.mcfunction | 3 + data/math/functions/list/test/fill.mcfunction | 10 +++ data/math/functions/list/test/key.mcfunction | 24 +++++++ .../functions/list/test/key_loop.mcfunction | 7 ++ .../math/functions/list/test/toset.mcfunction | 26 +++++++ data/math/functions/marker/_chest.mcfunction | 4 ++ data/math/functions/qrot/_ex-uvw.mcfunction | 44 ++++++------ data/math/functions/qrot/_get.mcfunction | 1 + data/math/functions/qrot/_print.mcfunction | 4 +- data/math/functions/qrot/_ssprint.mcfunction | 2 + data/math/functions/qrot/_store.mcfunction | 1 + data/math/functions/qrot/_swap.mcfunction | 32 +++++++++ data/math/functions/qrot/_zprint.mcfunction | 2 - .../functions/qrot/axis/_vecto.mcfunction | 67 +++++++++++++++++++ .../functions/randstring/_back.mcfunction | 5 ++ .../functions/randstring/_pull.mcfunction | 2 + .../functions/randstring/back_loop.mcfunction | 6 ++ data/math/functions/set/_cross.mcfunction | 18 +++++ data/math/functions/set/_diff.mcfunction | 19 ++++++ data/math/functions/set/_ex-tags.mcfunction | 7 ++ data/math/functions/set/_get.mcfunction | 4 ++ data/math/functions/set/_merge.mcfunction | 14 ++++ data/math/functions/set/_new.mcfunction | 7 ++ data/math/functions/set/_of.mcfunction | 14 ++++ data/math/functions/set/_print.mcfunction | 6 ++ data/math/functions/set/_ssprint.mcfunction | 6 ++ data/math/functions/set/_store.mcfunction | 4 ++ data/math/functions/set/_subset.mcfunction | 16 +++++ data/math/functions/set/_swap.mcfunction | 10 +++ .../math/functions/set/cross_sloop.mcfunction | 10 +++ .../functions/set/cross_success.mcfunction | 4 ++ data/math/functions/set/diff_sloop.mcfunction | 9 +++ .../functions/set/diff_success.mcfunction | 5 ++ data/math/functions/set/init.mcfunction | 7 ++ .../math/functions/set/merge_sloop.mcfunction | 9 +++ .../functions/set/merge_success.mcfunction | 4 ++ data/math/functions/set/set.mcfunction | 4 ++ .../functions/set/subset_sloop.mcfunction | 8 +++ data/math/functions/set/tags_sloop.mcfunction | 7 ++ data/math/functions/set/test/base.mcfunction | 40 +++++++++++ data/math/functions/set/test/cross.mcfunction | 24 +++++++ data/math/functions/set/test/diff.mcfunction | 26 +++++++ .../functions/set/test/ex-tags.mcfunction | 15 +++++ data/math/functions/set/test/merge.mcfunction | 26 +++++++ data/math/functions/set/test/of.mcfunction | 14 ++++ .../math/functions/set/test/subset.mcfunction | 28 ++++++++ data/math/functions/test/_perf.mcfunction | 10 +++ .../math/functions/test/perf/_loop.mcfunction | 5 ++ .../functions/test/perf/_print.mcfunction | 36 ++++++++++ .../functions/test/perf/_ssnew.mcfunction | 34 ++++++++++ .../functions/test/perf/_ssprint.mcfunction | 31 +++++++++ .../functions/test/perf/_start.mcfunction | 12 ++++ data/math/functions/test/perf/_std.mcfunction | 33 +++++++++ .../math/functions/test/perf/_tick.mcfunction | 13 ++++ data/math/functions/test/perf/doc.txt | 8 +++ .../functions/test/perf/std_loop0.mcfunction | 4 ++ .../functions/test/perf/std_loop1.mcfunction | 5 ++ .../functions/test/perf/std_loop2.mcfunction | 5 ++ 69 files changed, 845 insertions(+), 36 deletions(-) create mode 100644 data/math/functions/3vec/_print.mcfunction create mode 100644 data/math/functions/list/_fill.mcfunction create mode 100644 data/math/functions/list/_key.mcfunction create mode 100644 data/math/functions/list/_toset.mcfunction create mode 100644 data/math/functions/list/fill_sloop.mcfunction create mode 100644 data/math/functions/list/key_sloop.mcfunction create mode 100644 data/math/functions/list/set/sloop.mcfunction create mode 100644 data/math/functions/list/set/success.mcfunction create mode 100644 data/math/functions/list/test/fill.mcfunction create mode 100644 data/math/functions/list/test/key.mcfunction create mode 100644 data/math/functions/list/test/key_loop.mcfunction create mode 100644 data/math/functions/list/test/toset.mcfunction create mode 100644 data/math/functions/marker/_chest.mcfunction create mode 100644 data/math/functions/qrot/_ssprint.mcfunction create mode 100644 data/math/functions/qrot/_swap.mcfunction delete mode 100644 data/math/functions/qrot/_zprint.mcfunction create mode 100644 data/math/functions/qrot/axis/_vecto.mcfunction create mode 100644 data/math/functions/randstring/_back.mcfunction create mode 100644 data/math/functions/randstring/back_loop.mcfunction create mode 100644 data/math/functions/set/_cross.mcfunction create mode 100644 data/math/functions/set/_diff.mcfunction create mode 100644 data/math/functions/set/_ex-tags.mcfunction create mode 100644 data/math/functions/set/_get.mcfunction create mode 100644 data/math/functions/set/_merge.mcfunction create mode 100644 data/math/functions/set/_new.mcfunction create mode 100644 data/math/functions/set/_of.mcfunction create mode 100644 data/math/functions/set/_print.mcfunction create mode 100644 data/math/functions/set/_ssprint.mcfunction create mode 100644 data/math/functions/set/_store.mcfunction create mode 100644 data/math/functions/set/_subset.mcfunction create mode 100644 data/math/functions/set/_swap.mcfunction create mode 100644 data/math/functions/set/cross_sloop.mcfunction create mode 100644 data/math/functions/set/cross_success.mcfunction create mode 100644 data/math/functions/set/diff_sloop.mcfunction create mode 100644 data/math/functions/set/diff_success.mcfunction create mode 100644 data/math/functions/set/init.mcfunction create mode 100644 data/math/functions/set/merge_sloop.mcfunction create mode 100644 data/math/functions/set/merge_success.mcfunction create mode 100644 data/math/functions/set/set.mcfunction create mode 100644 data/math/functions/set/subset_sloop.mcfunction create mode 100644 data/math/functions/set/tags_sloop.mcfunction create mode 100644 data/math/functions/set/test/base.mcfunction create mode 100644 data/math/functions/set/test/cross.mcfunction create mode 100644 data/math/functions/set/test/diff.mcfunction create mode 100644 data/math/functions/set/test/ex-tags.mcfunction create mode 100644 data/math/functions/set/test/merge.mcfunction create mode 100644 data/math/functions/set/test/of.mcfunction create mode 100644 data/math/functions/set/test/subset.mcfunction create mode 100644 data/math/functions/test/_perf.mcfunction create mode 100644 data/math/functions/test/perf/_loop.mcfunction create mode 100644 data/math/functions/test/perf/_print.mcfunction create mode 100644 data/math/functions/test/perf/_ssnew.mcfunction create mode 100644 data/math/functions/test/perf/_ssprint.mcfunction create mode 100644 data/math/functions/test/perf/_start.mcfunction create mode 100644 data/math/functions/test/perf/_std.mcfunction create mode 100644 data/math/functions/test/perf/_tick.mcfunction create mode 100644 data/math/functions/test/perf/doc.txt create mode 100644 data/math/functions/test/perf/std_loop0.mcfunction create mode 100644 data/math/functions/test/perf/std_loop1.mcfunction create mode 100644 data/math/functions/test/perf/std_loop2.mcfunction diff --git a/data/math/functions/3vec/_print.mcfunction b/data/math/functions/3vec/_print.mcfunction new file mode 100644 index 0000000..f4fe288 --- /dev/null +++ b/data/math/functions/3vec/_print.mcfunction @@ -0,0 +1,2 @@ +#math:3vec/_print +tellraw @a [{"text":"(3vec) @s: ["},{"score":{"name":"@s","objective":"3vec_x"}},{"text":","},{"score":{"name":"@s","objective":"3vec_y"}},{"text":","},{"score":{"name":"@s","objective":"3vec_z"}},{"text":"]"}] \ No newline at end of file diff --git a/data/math/functions/3vec/_ssprint.mcfunction b/data/math/functions/3vec/_ssprint.mcfunction index 8bb7b07..fd58e35 100644 --- a/data/math/functions/3vec/_ssprint.mcfunction +++ b/data/math/functions/3vec/_ssprint.mcfunction @@ -1,4 +1,2 @@ #math:3vec/_ssprint -tellraw @a "---3vec---" -tellraw @a [{"text":"xyz:["},{"score":{"name":"3vec_x","objective":"int"}},{"text":","},{"score":{"name":"3vec_y","objective":"int"}},{"text":","},{"score":{"name":"3vec_z","objective":"int"}},{"text":"]"}] -tellraw @a [{"text":"rot:["},{"score":{"name":"3vec_rot0","objective":"int"}},{"text":","},{"score":{"name":"3vec_rot1","objective":"int"}},{"text":","},{"score":{"name":"3vec_l","objective":"int"}},{"text":"]"}] \ No newline at end of file +tellraw @a [{"text":"(3vec) ssobj: ["},{"score":{"name":"3vec_x","objective":"int"}},{"text":","},{"score":{"name":"3vec_y","objective":"int"}},{"text":","},{"score":{"name":"3vec_z","objective":"int"}},{"text":"]"}] \ No newline at end of file diff --git a/data/math/functions/_init.mcfunction b/data/math/functions/_init.mcfunction index 88dc4b0..7558709 100644 --- a/data/math/functions/_init.mcfunction +++ b/data/math/functions/_init.mcfunction @@ -65,10 +65,6 @@ data modify storage math:io item set value {} data modify storage math:io classify set value [] scoreboard players set classify_cnt int 0 -data modify storage math:io set set value [] -data modify storage math:io set_tags set value [] -scoreboard players set set_cnt int 0 - data modify storage math:io rand_lst set value [8593,45316,3528,4112,43,296358,12936510] execute store result score rand_seed int run data get storage math:io rand_lst[0] @@ -100,4 +96,7 @@ function math:cbox/init function math:geom/init #高精度模块初始化 -function math:hpo/init \ No newline at end of file +function math:hpo/init + +#集合初始化 +function math:set/init \ No newline at end of file diff --git a/data/math/functions/_version.mcfunction b/data/math/functions/_version.mcfunction index 2307761..b5faab1 100644 --- a/data/math/functions/_version.mcfunction +++ b/data/math/functions/_version.mcfunction @@ -1,4 +1,4 @@ #math:_version # 输出数学库版本 -tellraw @s {"text":"<数学库> 当前为2.0.2版本."} -scoreboard players set version int 202 \ No newline at end of file +tellraw @s {"text":"<数学库> 当前为2.0.3版本."} +scoreboard players set version int 203 \ No newline at end of file diff --git a/data/math/functions/init_overworld.mcfunction b/data/math/functions/init_overworld.mcfunction index 99a6047..d02f951 100644 --- a/data/math/functions/init_overworld.mcfunction +++ b/data/math/functions/init_overworld.mcfunction @@ -4,6 +4,8 @@ function math:marker/_origin #告示牌 function math:marker/_sign +#箱子 +function math:marker/_chest #世界实体 function math:marker/_math #转发实体 diff --git a/data/math/functions/list/_fill.mcfunction b/data/math/functions/list/_fill.mcfunction new file mode 100644 index 0000000..3a20b5f --- /dev/null +++ b/data/math/functions/list/_fill.mcfunction @@ -0,0 +1,6 @@ +#math:list/_fill +# 输入个数 +# 用storage math:io input填充list + +scoreboard players operation sloop int = inp int +execute if score sloop int matches 1.. run function math:list/fill_sloop \ No newline at end of file diff --git a/data/math/functions/list/_key.mcfunction b/data/math/functions/list/_key.mcfunction new file mode 100644 index 0000000..7ac070e --- /dev/null +++ b/data/math/functions/list/_key.mcfunction @@ -0,0 +1,12 @@ +#math:list/_key +# 转动列表 +# 查找键key的值是输入的位置 +# 如果没查到则输出0 + +execute store result score sloop int store result score stempn int if data storage math:io list[] + +scoreboard players set res int 1 +execute if score sloop int matches 1.. run function math:list/key_sloop +scoreboard players operation list_phi int %= stempn int +scoreboard players add res int 1 +scoreboard players operation res int %= 2 int \ No newline at end of file diff --git a/data/math/functions/list/_toset.mcfunction b/data/math/functions/list/_toset.mcfunction new file mode 100644 index 0000000..fd3fb14 --- /dev/null +++ b/data/math/functions/list/_toset.mcfunction @@ -0,0 +1,16 @@ +#math:list/_toset +# 转换函数:列表->集合 +# 需要传入世界实体为执行者 + +data modify entity @s Tags set value [] + +data modify storage math:io set set value [] +data modify storage math:io set_tags set value [] +scoreboard players set set_cnt int 0 + +data modify storage math:io stemp set from storage math:io list +execute store result score sloop int if data storage math:io stemp[] +execute if score sloop int matches 1.. run function math:list/set/sloop +data modify storage math:io set_tags set from entity @s Tags + +data modify entity @s Tags set value ["math_marker"] \ No newline at end of file diff --git a/data/math/functions/list/fill_sloop.mcfunction b/data/math/functions/list/fill_sloop.mcfunction new file mode 100644 index 0000000..296ed0a --- /dev/null +++ b/data/math/functions/list/fill_sloop.mcfunction @@ -0,0 +1,5 @@ +#math:list/fill_sloop +data modify storage math:io list append from storage math:io input +#循环迭代 +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:list/fill_sloop \ No newline at end of file diff --git a/data/math/functions/list/key_sloop.mcfunction b/data/math/functions/list/key_sloop.mcfunction new file mode 100644 index 0000000..db833d4 --- /dev/null +++ b/data/math/functions/list/key_sloop.mcfunction @@ -0,0 +1,11 @@ +#math:list/key_sloop +data modify storage math:io list append from storage math:io list[0] +data remove storage math:io list[0] +scoreboard players add list_phi int 1 + +data modify storage math:io stemp_cmp set from storage math:io list[0].key +execute store success score res int run data modify storage math:io stemp_cmp set from storage math:io input +execute if score res int matches 0 run scoreboard players set sloop int 1 +#循环迭代 +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:list/key_sloop \ No newline at end of file diff --git a/data/math/functions/list/set/sloop.mcfunction b/data/math/functions/list/set/sloop.mcfunction new file mode 100644 index 0000000..975005d --- /dev/null +++ b/data/math/functions/list/set/sloop.mcfunction @@ -0,0 +1,9 @@ +#math:list/set/sloop +data modify block 29999984 0 8591 back_text.messages[0] set value '{"nbt":"stemp[-1]","storage":"math:io"}' +data modify entity @s Tags append from block 29999984 0 8591 back_text.messages[0] +execute store result score sstemp int if data entity @s Tags[] +execute if score sstemp int > set_cnt int run function math:list/set/success +#循环迭代 +data remove storage math:io stemp[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:list/set/sloop \ No newline at end of file diff --git a/data/math/functions/list/set/success.mcfunction b/data/math/functions/list/set/success.mcfunction new file mode 100644 index 0000000..55ff087 --- /dev/null +++ b/data/math/functions/list/set/success.mcfunction @@ -0,0 +1,3 @@ +#math:list/set/success +data modify storage math:io set append from storage math:io stemp[-1] +scoreboard players add set_cnt int 1 \ No newline at end of file diff --git a/data/math/functions/list/test/fill.mcfunction b/data/math/functions/list/test/fill.mcfunction new file mode 100644 index 0000000..ebc6c8b --- /dev/null +++ b/data/math/functions/list/test/fill.mcfunction @@ -0,0 +1,10 @@ +#math:list/test/fill + +tellraw @a "---list_test_fill---" +scoreboard players set list_phi int 0 +data modify storage math:io list set value [] + +data modify storage math:io input set value {key:"hi"} +scoreboard players set inp int 5 +function math:list/_fill +tellraw @a ["list: ",{"nbt":"list","storage":"math:io"}] \ No newline at end of file diff --git a/data/math/functions/list/test/key.mcfunction b/data/math/functions/list/test/key.mcfunction new file mode 100644 index 0000000..2e3d468 --- /dev/null +++ b/data/math/functions/list/test/key.mcfunction @@ -0,0 +1,24 @@ +#math:list/test/key + +tellraw @a "---list_test_key---" +scoreboard players set inp int 12 + +function math:randstring/_pull + +scoreboard players set list_phi int 0 +data modify storage math:io list set value [] +data modify storage math:io stemp set value {key:""} +scoreboard players operation loop int = inp int +execute if score loop int matches 1.. run function math:list/test/key_loop +tellraw @a ["list: ",{"nbt":"list","storage":"math:io"}] + +data modify storage math:io input set from storage math:io list[8].key +function math:list/_key +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] +tellraw @a ["list: ",{"nbt":"list","storage":"math:io"}] + +data modify storage math:io input set value "哈" +function math:list/_key +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] + +function math:randstring/_back \ No newline at end of file diff --git a/data/math/functions/list/test/key_loop.mcfunction b/data/math/functions/list/test/key_loop.mcfunction new file mode 100644 index 0000000..c034a6c --- /dev/null +++ b/data/math/functions/list/test/key_loop.mcfunction @@ -0,0 +1,7 @@ +#math:list/test/key_loop +data modify storage math:io stemp.key set from storage math:io result[0] +data modify storage math:io list append from storage math:io stemp +#循环迭代 +data remove storage math:io result[0] +scoreboard players remove loop int 1 +execute if score loop int matches 1.. run function math:list/test/key_loop \ No newline at end of file diff --git a/data/math/functions/list/test/toset.mcfunction b/data/math/functions/list/test/toset.mcfunction new file mode 100644 index 0000000..efb4b85 --- /dev/null +++ b/data/math/functions/list/test/toset.mcfunction @@ -0,0 +1,26 @@ +#math:list/test/toset + +tellraw @a "---list_test_toset---" + +scoreboard players set list_phi int 0 +data modify storage math:io list set value [] + +scoreboard players set inp int 2 +data modify storage math:io input set value "hello" +function math:list/_fill + +scoreboard players set inp int 1 +data modify storage math:io input set value "world" +function math:list/_fill + +scoreboard players set inp int 3 +data modify storage math:io input set value "cber" +function math:list/_fill + +tellraw @a ["list: ",{"nbt":"list","storage":"math:io"}] + +execute as @e[tag=math_marker,limit=1] run function math:list/_toset + +tellraw @a ["set: ",{"nbt":"set","storage":"math:io"}] +tellraw @a ["set_tags: ",{"nbt":"set_tags","storage":"math:io"}] +tellraw @a ["set_cnt: ",{"score":{"name":"set_cnt","objective":"int"}}] \ No newline at end of file diff --git a/data/math/functions/marker/_chest.mcfunction b/data/math/functions/marker/_chest.mcfunction new file mode 100644 index 0000000..e7f653a --- /dev/null +++ b/data/math/functions/marker/_chest.mcfunction @@ -0,0 +1,4 @@ +#math:marker/_chest +forceload add 29999984 8591 29999984 8591 +setblock 29999984 0 8592 chest +item replace block 29999984 0 8592 container.0 with glass \ No newline at end of file diff --git a/data/math/functions/qrot/_ex-uvw.mcfunction b/data/math/functions/qrot/_ex-uvw.mcfunction index 7d317a3..43c9322 100644 --- a/data/math/functions/qrot/_ex-uvw.mcfunction +++ b/data/math/functions/qrot/_ex-uvw.mcfunction @@ -1,25 +1,25 @@ #math:qrot/_ex-uvw #扩展函数:根据xyzw扩展局部坐标系属性 -execute store result score u1 int store result score u2 int store result score stempxw int run scoreboard players operation u0 int = qrot_x int +execute store result score u1 int store result score u2 int store result score sstempxw int run scoreboard players operation u0 int = qrot_x int scoreboard players operation u0 int *= qrot_x int -execute store result score v2 int store result score stempyw int run scoreboard players operation v1 int = qrot_y int +execute store result score v2 int store result score sstempyw int run scoreboard players operation v1 int = qrot_y int scoreboard players operation v1 int *= qrot_y int -execute store result score stempzw int run scoreboard players operation w2 int = qrot_z int +execute store result score sstempzw int run scoreboard players operation w2 int = qrot_z int scoreboard players operation w2 int *= qrot_z int -scoreboard players operation stempx2 int = u0 int -scoreboard players operation stempy2 int = v1 int -scoreboard players operation stempw2 int = qrot_w int -scoreboard players operation stempw2 int *= qrot_w int -scoreboard players operation u0 int += stempw2 int +scoreboard players operation sstempx2 int = u0 int +scoreboard players operation sstempy2 int = v1 int +scoreboard players operation sstempw2 int = qrot_w int +scoreboard players operation sstempw2 int *= qrot_w int +scoreboard players operation u0 int += sstempw2 int scoreboard players operation u0 int -= v1 int scoreboard players operation u0 int -= w2 int -scoreboard players operation v1 int += stempw2 int -scoreboard players operation v1 int -= stempx2 int +scoreboard players operation v1 int += sstempw2 int +scoreboard players operation v1 int -= sstempx2 int scoreboard players operation v1 int -= w2 int -scoreboard players operation w2 int += stempw2 int -scoreboard players operation w2 int -= stempx2 int -scoreboard players operation w2 int -= stempy2 int +scoreboard players operation w2 int += sstempw2 int +scoreboard players operation w2 int -= sstempx2 int +scoreboard players operation w2 int -= sstempy2 int scoreboard players operation u0 int /= 10000 int scoreboard players operation v1 int /= 10000 int @@ -27,27 +27,27 @@ scoreboard players operation w2 int /= 10000 int scoreboard players operation u1 int *= qrot_y int scoreboard players operation v0 int = u1 int -scoreboard players operation stempzw int *= qrot_w int -scoreboard players operation u1 int += stempzw int -scoreboard players operation v0 int -= stempzw int +scoreboard players operation sstempzw int *= qrot_w int +scoreboard players operation u1 int += sstempzw int +scoreboard players operation v0 int -= sstempzw int scoreboard players operation u1 int /= 5000 int scoreboard players operation v0 int /= 5000 int scoreboard players operation u2 int *= qrot_z int scoreboard players operation w0 int = u2 int -scoreboard players operation stempyw int *= qrot_w int -scoreboard players operation u2 int -= stempyw int -scoreboard players operation w0 int += stempyw int +scoreboard players operation sstempyw int *= qrot_w int +scoreboard players operation u2 int -= sstempyw int +scoreboard players operation w0 int += sstempyw int scoreboard players operation u2 int /= 5000 int scoreboard players operation w0 int /= 5000 int scoreboard players operation v2 int *= qrot_z int scoreboard players operation w1 int = v2 int -scoreboard players operation stempxw int *= qrot_w int -scoreboard players operation v2 int += stempxw int -scoreboard players operation w1 int -= stempxw int +scoreboard players operation sstempxw int *= qrot_w int +scoreboard players operation v2 int += sstempxw int +scoreboard players operation w1 int -= sstempxw int scoreboard players operation v2 int /= 5000 int scoreboard players operation w1 int /= 5000 int \ No newline at end of file diff --git a/data/math/functions/qrot/_get.mcfunction b/data/math/functions/qrot/_get.mcfunction index 25b0798..27c56df 100644 --- a/data/math/functions/qrot/_get.mcfunction +++ b/data/math/functions/qrot/_get.mcfunction @@ -1,3 +1,4 @@ +#math:qrot/_get scoreboard players operation qrot_v0 int = @s qrot_v0 scoreboard players operation qrot_v1 int = @s qrot_v1 scoreboard players operation qrot_v2 int = @s qrot_v2 diff --git a/data/math/functions/qrot/_print.mcfunction b/data/math/functions/qrot/_print.mcfunction index c52ac6f..9e71d35 100644 --- a/data/math/functions/qrot/_print.mcfunction +++ b/data/math/functions/qrot/_print.mcfunction @@ -1,2 +1,2 @@ -#math:qrot/_print -tellraw @a ["(qrot)xyzw: [",{"score":{"name":"qrot_x","objective":"int"}},{"text":","},{"score":{"name":"qrot_y","objective":"int"}},{"text":","},{"score":{"name":"qrot_z","objective":"int"}},{"text":","},{"score":{"name":"qrot_w","objective":"int"}},{"text":"]"}] \ No newline at end of file +#math:qrot/_zprint +tellraw @a ["(qrot)xyzw: [",{"score":{"name":"@s","objective":"qrot_x"}},{"text":","},{"score":{"name":"@s","objective":"qrot_y"}},{"text":","},{"score":{"name":"@s","objective":"qrot_z"}},{"text":","},{"score":{"name":"@s","objective":"qrot_w"}},{"text":"]"}] \ No newline at end of file diff --git a/data/math/functions/qrot/_ssprint.mcfunction b/data/math/functions/qrot/_ssprint.mcfunction new file mode 100644 index 0000000..c52ac6f --- /dev/null +++ b/data/math/functions/qrot/_ssprint.mcfunction @@ -0,0 +1,2 @@ +#math:qrot/_print +tellraw @a ["(qrot)xyzw: [",{"score":{"name":"qrot_x","objective":"int"}},{"text":","},{"score":{"name":"qrot_y","objective":"int"}},{"text":","},{"score":{"name":"qrot_z","objective":"int"}},{"text":","},{"score":{"name":"qrot_w","objective":"int"}},{"text":"]"}] \ No newline at end of file diff --git a/data/math/functions/qrot/_store.mcfunction b/data/math/functions/qrot/_store.mcfunction index 660c357..328bfda 100644 --- a/data/math/functions/qrot/_store.mcfunction +++ b/data/math/functions/qrot/_store.mcfunction @@ -1,3 +1,4 @@ +#math:qrot/_store scoreboard players operation @s qrot_v0 = qrot_v0 int scoreboard players operation @s qrot_v1 = qrot_v1 int scoreboard players operation @s qrot_v2 = qrot_v2 int diff --git a/data/math/functions/qrot/_swap.mcfunction b/data/math/functions/qrot/_swap.mcfunction new file mode 100644 index 0000000..59c304d --- /dev/null +++ b/data/math/functions/qrot/_swap.mcfunction @@ -0,0 +1,32 @@ +#math:qrot/_swap +scoreboard players operation qrot_v0 int >< @s qrot_v0 +scoreboard players operation qrot_v1 int >< @s qrot_v1 +scoreboard players operation qrot_v2 int >< @s qrot_v2 +scoreboard players operation qrot_beta int >< @s qrot_beta +scoreboard players operation qrot_cbeta int >< @s qrot_cbeta +scoreboard players operation qrot_sbeta int >< @s qrot_sbeta +scoreboard players operation qrot_i0 int >< @s qrot_i0 +scoreboard players operation qrot_i1 int >< @s qrot_i1 +scoreboard players operation qrot_i2 int >< @s qrot_i2 +scoreboard players operation qrot_i3 int >< @s qrot_i3 +scoreboard players operation qrot_j0 int >< @s qrot_j0 +scoreboard players operation qrot_j1 int >< @s qrot_j1 +scoreboard players operation qrot_j2 int >< @s qrot_j2 +scoreboard players operation qrot_j3 int >< @s qrot_j3 +scoreboard players operation qrot_alpha int >< @s qrot_alpha +scoreboard players operation x int >< @s x +scoreboard players operation y int >< @s y +scoreboard players operation z int >< @s z +scoreboard players operation u0 int >< @s u0 +scoreboard players operation u1 int >< @s u1 +scoreboard players operation u2 int >< @s u2 +scoreboard players operation v0 int >< @s v0 +scoreboard players operation v1 int >< @s v1 +scoreboard players operation v2 int >< @s v2 +scoreboard players operation w0 int >< @s w0 +scoreboard players operation w1 int >< @s w1 +scoreboard players operation w2 int >< @s w2 +scoreboard players operation qrot_x int >< @s qrot_x +scoreboard players operation qrot_y int >< @s qrot_y +scoreboard players operation qrot_z int >< @s qrot_z +scoreboard players operation qrot_w int >< @s qrot_w \ No newline at end of file diff --git a/data/math/functions/qrot/_zprint.mcfunction b/data/math/functions/qrot/_zprint.mcfunction deleted file mode 100644 index 9e71d35..0000000 --- a/data/math/functions/qrot/_zprint.mcfunction +++ /dev/null @@ -1,2 +0,0 @@ -#math:qrot/_zprint -tellraw @a ["(qrot)xyzw: [",{"score":{"name":"@s","objective":"qrot_x"}},{"text":","},{"score":{"name":"@s","objective":"qrot_y"}},{"text":","},{"score":{"name":"@s","objective":"qrot_z"}},{"text":","},{"score":{"name":"@s","objective":"qrot_w"}},{"text":"]"}] \ No newline at end of file diff --git a/data/math/functions/qrot/axis/_vecto.mcfunction b/data/math/functions/qrot/axis/_vecto.mcfunction new file mode 100644 index 0000000..89857a0 --- /dev/null +++ b/data/math/functions/qrot/axis/_vecto.mcfunction @@ -0,0 +1,67 @@ +#math:qrot/axis/_vecto +#转换函数:单位向量到旋转基 +#i向量 +scoreboard players operation qrot_i0 int = qrot_v0 int +scoreboard players operation qrot_i0 int *= qrot_sbeta int +scoreboard players operation qrot_i0 int /= 10000 int + +scoreboard players operation qrot_i1 int = qrot_v1 int +scoreboard players operation qrot_i1 int *= qrot_sbeta int +scoreboard players operation qrot_i1 int /= 10000 int + +scoreboard players operation qrot_i2 int = qrot_v2 int +scoreboard players operation qrot_i2 int *= qrot_sbeta int +scoreboard players operation qrot_i2 int /= 10000 int + +scoreboard players operation qrot_i3 int = qrot_cbeta int + +#j向量 +scoreboard players operation qrot_j3 int = 3vec_x int +scoreboard players operation qrot_j3 int *= qrot_v0 int +scoreboard players operation stemp0 int = 3vec_y int +scoreboard players operation stemp0 int *= qrot_v1 int +scoreboard players operation qrot_j3 int += stemp0 int +scoreboard players operation stemp0 int = 3vec_z int +scoreboard players operation stemp0 int *= qrot_v2 int +scoreboard players operation qrot_j3 int += stemp0 int +scoreboard players operation qrot_j3 int /= 10000 int +scoreboard players operation qrot_j3 int *= qrot_sbeta int +scoreboard players operation qrot_j3 int /= -10000 int + +scoreboard players operation qrot_j0 int = 3vec_x int +scoreboard players operation qrot_j0 int *= qrot_cbeta int +scoreboard players operation qrot_j1 int = 3vec_y int +scoreboard players operation qrot_j1 int *= qrot_cbeta int +scoreboard players operation qrot_j2 int = 3vec_z int +scoreboard players operation qrot_j2 int *= qrot_cbeta int + +scoreboard players operation stemp0 int = 3vec_x int +scoreboard players operation stemp0 int *= qrot_v1 int +scoreboard players operation stemp1 int = 3vec_y int +scoreboard players operation stemp1 int *= qrot_v0 int +scoreboard players operation stemp0 int -= stemp1 int +scoreboard players operation stemp0 int /= 10000 int +scoreboard players operation stemp0 int *= qrot_sbeta int +scoreboard players operation qrot_j2 int += stemp0 int + +scoreboard players operation stemp0 int = 3vec_y int +scoreboard players operation stemp0 int *= qrot_v2 int +scoreboard players operation stemp1 int = 3vec_z int +scoreboard players operation stemp1 int *= qrot_v1 int +scoreboard players operation stemp0 int -= stemp1 int +scoreboard players operation stemp0 int /= 10000 int +scoreboard players operation stemp0 int *= qrot_sbeta int +scoreboard players operation qrot_j0 int += stemp0 int + +scoreboard players operation stemp0 int = 3vec_z int +scoreboard players operation stemp0 int *= qrot_v0 int +scoreboard players operation stemp1 int = 3vec_x int +scoreboard players operation stemp1 int *= qrot_v2 int +scoreboard players operation stemp0 int -= stemp1 int +scoreboard players operation stemp0 int /= 10000 int +scoreboard players operation stemp0 int *= qrot_sbeta int +scoreboard players operation qrot_j1 int += stemp0 int + +scoreboard players operation qrot_j0 int /= 10000 int +scoreboard players operation qrot_j1 int /= 10000 int +scoreboard players operation qrot_j2 int /= 10000 int \ No newline at end of file diff --git a/data/math/functions/randstring/_back.mcfunction b/data/math/functions/randstring/_back.mcfunction new file mode 100644 index 0000000..444c1a3 --- /dev/null +++ b/data/math/functions/randstring/_back.mcfunction @@ -0,0 +1,5 @@ +#math:randstring/_back +# 输入 +# 反向转动字符集 +scoreboard players operation sloop int = inp int +execute if score sloop int matches 1.. run function math:randstring/back_loop \ No newline at end of file diff --git a/data/math/functions/randstring/_pull.mcfunction b/data/math/functions/randstring/_pull.mcfunction index 17bcad9..f70c59a 100644 --- a/data/math/functions/randstring/_pull.mcfunction +++ b/data/math/functions/randstring/_pull.mcfunction @@ -1,4 +1,6 @@ #math:randstring/_pull +# 输出前个字符 +# 输出到storage math:io result data modify storage math:io result set value [] scoreboard players operation sloop int = inp int execute if score sloop int matches 1.. run function math:randstring/pull_loop \ No newline at end of file diff --git a/data/math/functions/randstring/back_loop.mcfunction b/data/math/functions/randstring/back_loop.mcfunction new file mode 100644 index 0000000..192ac3e --- /dev/null +++ b/data/math/functions/randstring/back_loop.mcfunction @@ -0,0 +1,6 @@ +#math:randstring/back_loop +data modify storage math:io randstring prepend from storage math:io randstring[-1] +data remove storage math:io randstring[-1] +#循环迭代 +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:randstring/back_loop \ No newline at end of file diff --git a/data/math/functions/set/_cross.mcfunction b/data/math/functions/set/_cross.mcfunction new file mode 100644 index 0000000..071b6d9 --- /dev/null +++ b/data/math/functions/set/_cross.mcfunction @@ -0,0 +1,18 @@ +#math:set/_cross +# 求交集 +# 输入临时对象,执行者对象 +# 输出临时对象 + +data modify storage math:io stemp_Tags set from entity @s Tags +data modify entity @s Tags set from entity @s data.set_tags +scoreboard players operation sstemp0 int = @s set_cnt + +data modify storage math:io stemp set from storage math:io set +data modify storage math:io stemp_tags set from storage math:io set_tags +scoreboard players operation sloop int = set_cnt int +data modify storage math:io set set value [] +data modify storage math:io set_tags set value [] +scoreboard players set set_cnt int 0 +execute if score sloop int matches 1.. run function math:set/cross_sloop + +data modify entity @s Tags set from storage math:io stemp_Tags \ No newline at end of file diff --git a/data/math/functions/set/_diff.mcfunction b/data/math/functions/set/_diff.mcfunction new file mode 100644 index 0000000..75d504e --- /dev/null +++ b/data/math/functions/set/_diff.mcfunction @@ -0,0 +1,19 @@ +#math:set/_diff +# 求差集 +# 用实体对象减去临时对象 +# 输入临时对象,执行者对象 +# 输出临时对象 + +data modify storage math:io stemp_Tags set from entity @s Tags +data modify entity @s Tags set from entity @s data.set_tags +scoreboard players operation sstemp0 int = @s set_cnt + +data modify storage math:io stemp set from storage math:io set +data modify storage math:io stemp_tags set from storage math:io set_tags +scoreboard players operation sloop int = set_cnt int +data modify storage math:io set set value [] +data modify storage math:io set_tags set value [] +scoreboard players set set_cnt int 0 +execute if score sloop int matches 1.. run function math:set/diff_sloop + +data modify entity @s Tags set from storage math:io stemp_Tags \ No newline at end of file diff --git a/data/math/functions/set/_ex-tags.mcfunction b/data/math/functions/set/_ex-tags.mcfunction new file mode 100644 index 0000000..891c44e --- /dev/null +++ b/data/math/functions/set/_ex-tags.mcfunction @@ -0,0 +1,7 @@ +#math:set/_ex-tags +# 扩展tags属性 + +data modify storage math:io set_tags set value [] +data modify storage math:io stemp set from storage math:io set +scoreboard players operation sloop int = set_cnt int +execute if score sloop int matches 1.. run function math:set/tags_sloop \ No newline at end of file diff --git a/data/math/functions/set/_get.mcfunction b/data/math/functions/set/_get.mcfunction new file mode 100644 index 0000000..82804ce --- /dev/null +++ b/data/math/functions/set/_get.mcfunction @@ -0,0 +1,4 @@ +#math:set/_get +data modify storage math:io set set from entity @s data.set +data modify storage math:io set_tags set from entity @s data.set_tags +scoreboard players operation set_cnt int = @s set_cnt \ No newline at end of file diff --git a/data/math/functions/set/_merge.mcfunction b/data/math/functions/set/_merge.mcfunction new file mode 100644 index 0000000..91857f2 --- /dev/null +++ b/data/math/functions/set/_merge.mcfunction @@ -0,0 +1,14 @@ +#math:set/_merge +# 求并集 +# 输入临时对象,执行者对象 +# 输出临时对象 + +data modify storage math:io stemp_Tags set from entity @s Tags +data modify entity @s Tags set from storage math:io set_tags + +data modify storage math:io stemp set from entity @s data.set +data modify storage math:io stemp_tags set from entity @s data.set_tags +scoreboard players operation sloop int = @s set_cnt +execute if score sloop int matches 1.. run function math:set/merge_sloop + +data modify entity @s Tags set from storage math:io stemp_Tags \ No newline at end of file diff --git a/data/math/functions/set/_new.mcfunction b/data/math/functions/set/_new.mcfunction new file mode 100644 index 0000000..08f25c7 --- /dev/null +++ b/data/math/functions/set/_new.mcfunction @@ -0,0 +1,7 @@ +#math:set/_new +# 输入数据模板storage math:io input +# 返回一个集合对象 + +tag @e remove result +summon marker 0 11 0 {Tags:["result","set"],data:{set:[],set_tags:[]}} +execute as @e[tag=result,limit=1] run function math:set/set \ No newline at end of file diff --git a/data/math/functions/set/_of.mcfunction b/data/math/functions/set/_of.mcfunction new file mode 100644 index 0000000..d32cad7 --- /dev/null +++ b/data/math/functions/set/_of.mcfunction @@ -0,0 +1,14 @@ +#math:set/_of +# 判断元素是否在集合中 +# 需要传入世界实体为执行者 +# 输入storage math:io input +# 输出 + +data modify entity @s Tags set from storage math:io set_tags + +data modify block 29999984 0 8591 back_text.messages[0] set value '{"nbt":"input","storage":"math:io"}' +data modify entity @s Tags append from block 29999984 0 8591 back_text.messages[0] +execute store result score sstemp int if data entity @s Tags[] +execute store result score res int if score sstemp int = set_cnt int + +data modify entity @s Tags set value ["math_marker"] \ No newline at end of file diff --git a/data/math/functions/set/_print.mcfunction b/data/math/functions/set/_print.mcfunction new file mode 100644 index 0000000..89ae69d --- /dev/null +++ b/data/math/functions/set/_print.mcfunction @@ -0,0 +1,6 @@ +#math:set/_print + +tellraw @a "---set---" +tellraw @a ["set: ",{"nbt":"data.set","entity":"@s"}] +tellraw @a ["set_tags: ",{"nbt":"data.set_tags","entity":"@s"}] +tellraw @a ["set_cnt: ",{"score":{"name":"@s","objective":"set_cnt"}}] \ No newline at end of file diff --git a/data/math/functions/set/_ssprint.mcfunction b/data/math/functions/set/_ssprint.mcfunction new file mode 100644 index 0000000..4406f34 --- /dev/null +++ b/data/math/functions/set/_ssprint.mcfunction @@ -0,0 +1,6 @@ +#math:set/_ssprint + +tellraw @a "---set---" +tellraw @a ["set: ",{"nbt":"set","storage":"math:io"}] +tellraw @a ["set_tags: ",{"nbt":"set_tags","storage":"math:io"}] +tellraw @a ["set_cnt: ",{"score":{"name":"set_cnt","objective":"int"}}] \ No newline at end of file diff --git a/data/math/functions/set/_store.mcfunction b/data/math/functions/set/_store.mcfunction new file mode 100644 index 0000000..af2f324 --- /dev/null +++ b/data/math/functions/set/_store.mcfunction @@ -0,0 +1,4 @@ +#math:set/_store +data modify entity @s data.set set from storage math:io set +data modify entity @s data.set_tags set from storage math:io set_tags +scoreboard players operation @s set_cnt = set_cnt int \ No newline at end of file diff --git a/data/math/functions/set/_subset.mcfunction b/data/math/functions/set/_subset.mcfunction new file mode 100644 index 0000000..5a1c3d4 --- /dev/null +++ b/data/math/functions/set/_subset.mcfunction @@ -0,0 +1,16 @@ +#math:set/_subset +# 判断执行者是不是临时对象的子集 +# 输入实体对象,临时对象 +# 输出到 + +scoreboard players set res int 1 + +data modify storage math:io stemp_Tags set from entity @s Tags +data modify entity @s Tags set from storage math:io set_tags +scoreboard players operation sstemp0 int = set_cnt int + +data modify storage math:io stemp_tags set from entity @s data.set_tags +scoreboard players operation sloop int = @s set_cnt +execute if score sloop int matches 1.. run function math:set/subset_sloop + +data modify entity @s Tags set from storage math:io stemp_Tags \ No newline at end of file diff --git a/data/math/functions/set/_swap.mcfunction b/data/math/functions/set/_swap.mcfunction new file mode 100644 index 0000000..199068a --- /dev/null +++ b/data/math/functions/set/_swap.mcfunction @@ -0,0 +1,10 @@ +#math:set/_swap +data modify storage math:io stemp set from entity @s data.set +data modify entity @s data.set set from storage math:io set +data modify storage math:io set set from storage math:io stemp + +data modify storage math:io stemp set from entity @s data.set_tags +data modify entity @s data.set_tags set from storage math:io set_tags +data modify storage math:io set_tags set from storage math:io stemp + +scoreboard players operation set_cnt int >< @s set_cnt \ No newline at end of file diff --git a/data/math/functions/set/cross_sloop.mcfunction b/data/math/functions/set/cross_sloop.mcfunction new file mode 100644 index 0000000..eca8082 --- /dev/null +++ b/data/math/functions/set/cross_sloop.mcfunction @@ -0,0 +1,10 @@ +#math:set/cross_sloop +data modify entity @s Tags append from storage math:io stemp_tags[-1] +execute store result score sstemp1 int if data entity @s Tags[] +execute if score sstemp1 int = sstemp0 int run function math:set/cross_success +scoreboard players operation sstemp0 int = sstemp1 int +#循环迭代 +data remove storage math:io stemp[-1] +data remove storage math:io stemp_tags[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:set/cross_sloop \ No newline at end of file diff --git a/data/math/functions/set/cross_success.mcfunction b/data/math/functions/set/cross_success.mcfunction new file mode 100644 index 0000000..5bebaa8 --- /dev/null +++ b/data/math/functions/set/cross_success.mcfunction @@ -0,0 +1,4 @@ +#math:set/cross_success +data modify storage math:io set append from storage math:io stemp[-1] +data modify storage math:io set_tags append from storage math:io stemp_tags[-1] +scoreboard players add set_cnt int 1 \ No newline at end of file diff --git a/data/math/functions/set/diff_sloop.mcfunction b/data/math/functions/set/diff_sloop.mcfunction new file mode 100644 index 0000000..ddf1f9d --- /dev/null +++ b/data/math/functions/set/diff_sloop.mcfunction @@ -0,0 +1,9 @@ +#math:set/diff_sloop +data modify entity @s Tags append from storage math:io stemp_tags[-1] +execute store result score sstemp1 int if data entity @s Tags[] +execute if score sstemp1 int > sstemp0 int run function math:set/diff_success +#循环迭代 +data remove storage math:io stemp[-1] +data remove storage math:io stemp_tags[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:set/diff_sloop \ No newline at end of file diff --git a/data/math/functions/set/diff_success.mcfunction b/data/math/functions/set/diff_success.mcfunction new file mode 100644 index 0000000..f92043d --- /dev/null +++ b/data/math/functions/set/diff_success.mcfunction @@ -0,0 +1,5 @@ +#math:set/diff_success +data modify storage math:io set append from storage math:io stemp[-1] +data modify storage math:io set_tags append from storage math:io stemp_tags[-1] +scoreboard players add set_cnt int 1 +scoreboard players operation sstemp0 int = sstemp1 int \ No newline at end of file diff --git a/data/math/functions/set/init.mcfunction b/data/math/functions/set/init.mcfunction new file mode 100644 index 0000000..51f27fd --- /dev/null +++ b/data/math/functions/set/init.mcfunction @@ -0,0 +1,7 @@ +#math:test/init + +scoreboard objectives add set_cnt dummy + +data modify storage math:io set set value [] +data modify storage math:io set_tags set value [] +scoreboard players set set_cnt int 0 \ No newline at end of file diff --git a/data/math/functions/set/merge_sloop.mcfunction b/data/math/functions/set/merge_sloop.mcfunction new file mode 100644 index 0000000..7ec25bd --- /dev/null +++ b/data/math/functions/set/merge_sloop.mcfunction @@ -0,0 +1,9 @@ +#math:set/merge_sloop +data modify entity @s Tags append from storage math:io stemp_tags[-1] +execute store result score sstemp int if data entity @s Tags[] +execute if score sstemp int > set_cnt int run function math:set/merge_success +#循环迭代 +data remove storage math:io stemp[-1] +data remove storage math:io stemp_tags[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:set/merge_sloop \ No newline at end of file diff --git a/data/math/functions/set/merge_success.mcfunction b/data/math/functions/set/merge_success.mcfunction new file mode 100644 index 0000000..6e24eb4 --- /dev/null +++ b/data/math/functions/set/merge_success.mcfunction @@ -0,0 +1,4 @@ +#math:set/merge_success +data modify storage math:io set append from storage math:io stemp[-1] +data modify storage math:io set_tags append from storage math:io stemp_tags[-1] +scoreboard players add set_cnt int 1 \ No newline at end of file diff --git a/data/math/functions/set/set.mcfunction b/data/math/functions/set/set.mcfunction new file mode 100644 index 0000000..fc9a7c9 --- /dev/null +++ b/data/math/functions/set/set.mcfunction @@ -0,0 +1,4 @@ +#math:set/set +execute store result score @s id run scoreboard players add #id id 1 +scoreboard players set @s set_cnt 0 +data modify entity @s Tags append from storage math:io input.tags[] \ No newline at end of file diff --git a/data/math/functions/set/subset_sloop.mcfunction b/data/math/functions/set/subset_sloop.mcfunction new file mode 100644 index 0000000..4122207 --- /dev/null +++ b/data/math/functions/set/subset_sloop.mcfunction @@ -0,0 +1,8 @@ +#math:set/subset_sloop +data modify entity @s Tags append from storage math:io stemp_tags[-1] +execute store result score sstemp1 int if data entity @s Tags[] +execute if score sstemp1 int > sstemp0 int store success score sloop int run scoreboard players set res int 0 +#循环迭代 +data remove storage math:io stemp_tags[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:set/subset_sloop \ No newline at end of file diff --git a/data/math/functions/set/tags_sloop.mcfunction b/data/math/functions/set/tags_sloop.mcfunction new file mode 100644 index 0000000..30f2e43 --- /dev/null +++ b/data/math/functions/set/tags_sloop.mcfunction @@ -0,0 +1,7 @@ +#math:set/tags_sloop +data modify block 29999984 0 8591 back_text.messages[0] set value '{"nbt":"stemp[-1]","storage":"math:io"}' +data modify storage math:io set_tags append from block 29999984 0 8591 back_text.messages[0] +#循环迭代 +data remove storage math:io stemp[-1] +scoreboard players remove sloop int 1 +execute if score sloop int matches 1.. run function math:set/tags_sloop \ No newline at end of file diff --git a/data/math/functions/set/test/base.mcfunction b/data/math/functions/set/test/base.mcfunction new file mode 100644 index 0000000..1a7f230 --- /dev/null +++ b/data/math/functions/set/test/base.mcfunction @@ -0,0 +1,40 @@ +#math:set/test/base + +tellraw @a "---set_test_base---" +data modify storage math:io list set value ["hello","hello","world","im","a","a","cber"] +function math:list/_toset +data modify storage math:io input set value {tags:["A","test"]} +function math:set/_new +execute as @e[tag=result,limit=1] run function math:set/_store + +data modify storage math:io list set value ["hi","hi","cber","this","is","is","minecraft"] +function math:list/_toset +data modify storage math:io input set value {tags:["B","test"]} +function math:set/_new +execute as @e[tag=result,limit=1] run function math:set/_store + +execute as @e[tag=A,limit=1] run function math:set/_print +execute as @e[tag=B,limit=1] run function math:set/_print + +execute as @e[tag=A,limit=1] run function math:set/_get +data modify storage math:io input set value "8593" +function math:set/_append +execute as @e[tag=B,limit=1] run function math:set/_store +execute as @e[tag=B,limit=1] run function math:set/_print + +function math:set/_ssnew +data modify storage math:io input set value "8593" +function math:set/_append +data modify storage math:io input set value "3528" +function math:set/_append +execute as @e[tag=B,limit=1] run function math:set/_store +execute as @e[tag=B,limit=1] run function math:set/_print + +data modify storage math:io list set value ["no","name"] +function math:list/_toset +function math:set/_ssprint +execute as @e[tag=B,limit=1] run function math:set/_swap +execute as @e[tag=B,limit=1] run function math:set/_print +function math:set/_ssprint + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/set/test/cross.mcfunction b/data/math/functions/set/test/cross.mcfunction new file mode 100644 index 0000000..12a0450 --- /dev/null +++ b/data/math/functions/set/test/cross.mcfunction @@ -0,0 +1,24 @@ +#math:set/test/cross + +data modify storage math:io input set value {tags:["test","set"]} +function math:set/_new +data modify storage math:io list set value ["hi","there","cber","name","minecraft"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_store + +data modify storage math:io list set value ["hi","hello","there","this"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_cross +function math:set/_ssprint + +data modify storage math:io list set value ["no","he","does"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_cross +function math:set/_ssprint + +data modify storage math:io list set value ["cber","is","name"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_cross +function math:set/_ssprint + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/set/test/diff.mcfunction b/data/math/functions/set/test/diff.mcfunction new file mode 100644 index 0000000..f0dc7b9 --- /dev/null +++ b/data/math/functions/set/test/diff.mcfunction @@ -0,0 +1,26 @@ +#math:set/test/diff + +tellraw @a "---set_test_diff---" + +data modify storage math:io input set value {tags:["test","set"]} +function math:set/_new +data modify storage math:io list set value ["hi","this","is"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_store + +data modify storage math:io list set value ["hi","minecraft","is","me"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_diff +function math:set/_ssprint + +data modify storage math:io list set value ["hi","this","is","minecraft"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_diff +function math:set/_ssprint + +data modify storage math:io list set value ["no","minecraft"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_diff +function math:set/_ssprint + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/set/test/ex-tags.mcfunction b/data/math/functions/set/test/ex-tags.mcfunction new file mode 100644 index 0000000..2908e1c --- /dev/null +++ b/data/math/functions/set/test/ex-tags.mcfunction @@ -0,0 +1,15 @@ +#math:set/test/ex-tags + +tellraw @a "---set_test_ex-tags---" + +function math:set/_ssnew +data modify storage math:io set set value ["hi","test"] +execute store result score set_cnt int if data storage math:io set[] +function math:set/_ex-tags + +data modify storage math:io input set value {tags:["test","set"]} +function math:set/_new +execute as @e[tag=set,limit=1] run function math:set/_store +execute as @e[tag=set,limit=1] run function math:set/_print + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/set/test/merge.mcfunction b/data/math/functions/set/test/merge.mcfunction new file mode 100644 index 0000000..2fa0050 --- /dev/null +++ b/data/math/functions/set/test/merge.mcfunction @@ -0,0 +1,26 @@ +#math:set/test/merge + +tellraw @a "---set_test_merge---" + +data modify storage math:io input set value {tags:["test","set"]} +function math:set/_new +data modify storage math:io list set value ["hi","this","is"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_store + +data modify storage math:io list set value ["hi","minecraft","is","me"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_merge +function math:set/_ssprint + +data modify storage math:io list set value ["hi","this","is","minecraft"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_merge +function math:set/_ssprint + +data modify storage math:io list set value ["no","minecraft"] +function math:list/_toset +execute as @e[tag=set,limit=1] run function math:set/_merge +function math:set/_ssprint + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/set/test/of.mcfunction b/data/math/functions/set/test/of.mcfunction new file mode 100644 index 0000000..2a82782 --- /dev/null +++ b/data/math/functions/set/test/of.mcfunction @@ -0,0 +1,14 @@ +#math:set/test/of + +tellraw @a "---set_test_of---" + +data modify storage math:io list set value ["hello","cber","hi","im","world"] +function math:list/_toset + +data modify storage math:io input set value "hi" +function math:set/_of +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] + +data modify storage math:io input set value "no" +function math:set/_of +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] \ No newline at end of file diff --git a/data/math/functions/set/test/subset.mcfunction b/data/math/functions/set/test/subset.mcfunction new file mode 100644 index 0000000..e505a7f --- /dev/null +++ b/data/math/functions/set/test/subset.mcfunction @@ -0,0 +1,28 @@ +#math:set/test/subset + +tellraw @a "---set_test_subset---" + +data modify storage math:io input set value {tags:["test","set","A"]} +function math:set/_new +data modify storage math:io input set value {tags:["test","set","B"]} +function math:set/_new + +data modify storage math:io list set value ["hi","hello","there","this","minecraft"] +function math:list/_toset +execute as @e[tag=A,limit=1] run function math:set/_store + +data modify storage math:io list set value ["hi","there","this"] +function math:list/_toset +execute as @e[tag=B,limit=1] run function math:set/_store +execute as @e[tag=A,limit=1] run function math:set/_get +execute as @e[tag=B,limit=1] run function math:set/_subset +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] + +data modify storage math:io list set value ["hi","there","this","no"] +function math:list/_toset +execute as @e[tag=B,limit=1] run function math:set/_store +execute as @e[tag=A,limit=1] run function math:set/_get +execute as @e[tag=B,limit=1] run function math:set/_subset +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] + +kill @e[tag=test] \ No newline at end of file diff --git a/data/math/functions/test/_perf.mcfunction b/data/math/functions/test/_perf.mcfunction new file mode 100644 index 0000000..2855257 --- /dev/null +++ b/data/math/functions/test/_perf.mcfunction @@ -0,0 +1,10 @@ +#math:test/_perf +worldborder set 1 0 + +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/_loop + +execute store result score res int run worldborder get +tellraw @a ["res: ",{"score":{"name":"res","objective":"int"}}] +worldborder set 50000000 0 \ No newline at end of file diff --git a/data/math/functions/test/perf/_loop.mcfunction b/data/math/functions/test/perf/_loop.mcfunction new file mode 100644 index 0000000..5ef776d --- /dev/null +++ b/data/math/functions/test/perf/_loop.mcfunction @@ -0,0 +1,5 @@ +#math:test/perf/_loop +scoreboard players operation temp int += 1 int +#循环迭代 +scoreboard players remove loop int 1 +execute if score loop int matches 1.. run function math:test/perf/_loop \ No newline at end of file diff --git a/data/math/functions/test/perf/_print.mcfunction b/data/math/functions/test/perf/_print.mcfunction new file mode 100644 index 0000000..2785f70 --- /dev/null +++ b/data/math/functions/test/perf/_print.mcfunction @@ -0,0 +1,36 @@ +#math:test/perf/_print + +execute store result score sstemp int run scoreboard players operation perf_max int -= perf_avg int +scoreboard players operation perf_max int += perf_avg int +scoreboard players operation perf_avg int -= perf_min int +scoreboard players operation sstemp int > perf_avg int +scoreboard players operation perf_avg int += perf_min int +scoreboard players operation sstemp int *= 100 int +scoreboard players operation sstemp int /= perf_avg int + +tellraw @a "---perf_test_result---" +tellraw @a ["perf_n: ",{"score":{"name":"perf_n","objective":"int"}}] +tellraw @a ["min: ",{"score":{"name":"perf_min","objective":"int"}}," max: ",{"score":{"name":"perf_max","objective":"int"}}] +tellraw @a ["avg: ",{"score":{"name":"perf_avg","objective":"int"}}," err: ",{"score":{"name":"sstemp","objective":"int"}},"%"] + +scoreboard players operation sstemp int = perf_line_avg int +scoreboard players operation sstemp int -= perf_base_avg int +scoreboard players operation sstemp0 int = perf_avg int +scoreboard players operation sstemp0 int -= perf_base_avg int +scoreboard players operation sstemp1 int = sstemp0 int +scoreboard players operation sstemp0 int /= sstemp int +scoreboard players operation sstemp1 int %= sstemp int +scoreboard players operation sstemp1 int *= 100 int +scoreboard players operation sstemp1 int /= sstemp int +data modify block 29999984 0 8591 back_text.messages[0] set value '["scb: ",{"score":{"name":"sstemp0","objective":"int"}},".",{"score":{"name":"sstemp1","objective":"int"}}]' + +scoreboard players operation sstemp int = perf_line_mult_avg int +scoreboard players operation sstemp int -= perf_base_avg int +scoreboard players operation sstemp0 int = perf_avg int +scoreboard players operation sstemp0 int -= perf_base_avg int +scoreboard players operation sstemp1 int = sstemp0 int +scoreboard players operation sstemp0 int /= sstemp int +scoreboard players operation sstemp1 int %= sstemp int +scoreboard players operation sstemp1 int *= 100 int +scoreboard players operation sstemp1 int /= sstemp int +tellraw @a [{"nbt":"back_text.messages[0]","block":"29999984 0 8591","interpret":true}," scb_mult: ",{"score":{"name":"sstemp0","objective":"int"}},".",{"score":{"name":"sstemp1","objective":"int"}}] \ No newline at end of file diff --git a/data/math/functions/test/perf/_ssnew.mcfunction b/data/math/functions/test/perf/_ssnew.mcfunction new file mode 100644 index 0000000..b45a339 --- /dev/null +++ b/data/math/functions/test/perf/_ssnew.mcfunction @@ -0,0 +1,34 @@ +#math:test/perf/_ssnew +gamerule maxCommandChainLength 2147483647 +scoreboard players set perf_n int 1000000 + +scoreboard players set temp int 8593 + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop0 +execute store result score perf_base int run worldborder get +scoreboard players operation perf_base_avg int = perf_base int +scoreboard players operation perf_base_min int = perf_base int +scoreboard players operation perf_base_max int = perf_base int + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop1 +execute store result score perf_line int run worldborder get +scoreboard players operation perf_line_avg int = perf_line int +scoreboard players operation perf_line_min int = perf_line int +scoreboard players operation perf_line_max int = perf_line int + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop2 +execute store result score perf_line_mult int run worldborder get +scoreboard players operation perf_line_mult_avg int = perf_line_mult int +scoreboard players operation perf_line_mult_min int = perf_line_mult int +scoreboard players operation perf_line_mult_max int = perf_line_mult int + +worldborder set 50000000 0 \ No newline at end of file diff --git a/data/math/functions/test/perf/_ssprint.mcfunction b/data/math/functions/test/perf/_ssprint.mcfunction new file mode 100644 index 0000000..ce3dac1 --- /dev/null +++ b/data/math/functions/test/perf/_ssprint.mcfunction @@ -0,0 +1,31 @@ +#math:test/perf/_ssprint +tellraw @a "---perf_test---" + +tellraw @a ["perf_n: ",{"score":{"name":"perf_n","objective":"int"}}] + +execute store result score sstemp int run scoreboard players operation perf_base_max int -= perf_base_avg int +scoreboard players operation perf_base_max int += perf_base_avg int +scoreboard players operation perf_base_avg int -= perf_base_min int +scoreboard players operation sstemp int > perf_base_avg int +scoreboard players operation perf_base_avg int += perf_base_min int +scoreboard players operation sstemp int *= 100 int +scoreboard players operation sstemp int /= perf_base_avg int +tellraw @a ["base: {avg:",{"score":{"name":"perf_base_avg","objective":"int"}},{"text":", min:"},{"score":{"name":"perf_base_min","objective":"int"}},{"text":", max:"},{"score":{"name":"perf_base_max","objective":"int"}},{"text":", err:"},{"score":{"name":"sstemp","objective":"int"}},"%}"] + +execute store result score sstemp int run scoreboard players operation perf_line_max int -= perf_line_avg int +scoreboard players operation perf_line_max int += perf_line_avg int +scoreboard players operation perf_line_avg int -= perf_line_min int +scoreboard players operation sstemp int > perf_line_avg int +scoreboard players operation perf_line_avg int += perf_line_min int +scoreboard players operation sstemp int *= 100 int +scoreboard players operation sstemp int /= perf_line_avg int +tellraw @a ["line: {avg:",{"score":{"name":"perf_line_avg","objective":"int"}},{"text":", min:"},{"score":{"name":"perf_line_min","objective":"int"}},{"text":", max:"},{"score":{"name":"perf_line_max","objective":"int"}},{"text":", err:"},{"score":{"name":"sstemp","objective":"int"}},"%}"] + +execute store result score sstemp int run scoreboard players operation perf_line_mult_max int -= perf_line_mult_avg int +scoreboard players operation perf_line_mult_max int += perf_line_mult_avg int +scoreboard players operation perf_line_mult_avg int -= perf_line_mult_min int +scoreboard players operation sstemp int > perf_line_mult_avg int +scoreboard players operation perf_line_mult_avg int += perf_line_mult_min int +scoreboard players operation sstemp int *= 100 int +scoreboard players operation sstemp int /= perf_line_mult_avg int +tellraw @a ["line_mult: {avg:",{"score":{"name":"perf_line_mult_avg","objective":"int"}},{"text":", min:"},{"score":{"name":"perf_line_mult_min","objective":"int"}},{"text":", max:"},{"score":{"name":"perf_line_mult_max","objective":"int"}},{"text":", err:"},{"score":{"name":"sstemp","objective":"int"}},"%}"] \ No newline at end of file diff --git a/data/math/functions/test/perf/_start.mcfunction b/data/math/functions/test/perf/_start.mcfunction new file mode 100644 index 0000000..934e8dd --- /dev/null +++ b/data/math/functions/test/perf/_start.mcfunction @@ -0,0 +1,12 @@ +#math:test/perf/_start + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/_loop +execute store result score res int run worldborder get +scoreboard players operation perf_avg int = res int +scoreboard players operation perf_min int = res int +scoreboard players operation perf_max int = res int + +worldborder set 50000000 0 \ No newline at end of file diff --git a/data/math/functions/test/perf/_std.mcfunction b/data/math/functions/test/perf/_std.mcfunction new file mode 100644 index 0000000..d0cf914 --- /dev/null +++ b/data/math/functions/test/perf/_std.mcfunction @@ -0,0 +1,33 @@ +#math:test/perf/_std + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop0 +execute store result score perf_base int run worldborder get +scoreboard players operation perf_base_avg int += perf_base int +scoreboard players operation perf_base_avg int /= 2 int +scoreboard players operation perf_base_min int < perf_base int +scoreboard players operation perf_base_max int > perf_base int + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop1 +execute store result score perf_line int run worldborder get +scoreboard players operation perf_line_avg int += perf_line int +scoreboard players operation perf_line_avg int /= 2 int +scoreboard players operation perf_line_min int < perf_line int +scoreboard players operation perf_line_max int > perf_line int + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/std_loop2 +execute store result score perf_line_mult int run worldborder get +scoreboard players operation perf_line_mult_avg int += perf_line_mult int +scoreboard players operation perf_line_mult_avg int /= 2 int +scoreboard players operation perf_line_mult_min int < perf_line_mult int +scoreboard players operation perf_line_mult_max int > perf_line_mult int + +worldborder set 50000000 0 \ No newline at end of file diff --git a/data/math/functions/test/perf/_tick.mcfunction b/data/math/functions/test/perf/_tick.mcfunction new file mode 100644 index 0000000..cb849f0 --- /dev/null +++ b/data/math/functions/test/perf/_tick.mcfunction @@ -0,0 +1,13 @@ +#math:test/perf/_tick + +worldborder set 1 0 +worldborder set 50000000 50000 +scoreboard players operation loop int = perf_n int +execute if score loop int matches 1.. run function math:test/perf/_loop +execute store result score res int run worldborder get +scoreboard players operation perf_avg int += res int +scoreboard players operation perf_avg int /= 2 int +scoreboard players operation perf_min int < res int +scoreboard players operation perf_max int > res int + +worldborder set 50000000 0 \ No newline at end of file diff --git a/data/math/functions/test/perf/doc.txt b/data/math/functions/test/perf/doc.txt new file mode 100644 index 0000000..d5d5d4d --- /dev/null +++ b/data/math/functions/test/perf/doc.txt @@ -0,0 +1,8 @@ +execute store result score sstemp int run scoreboard players operation perf_line_mult_max int -= perf_line_mult_avg int +scoreboard players operation perf_line_mult_max int += perf_line_mult_avg int +scoreboard players operation perf_line_mult_avg int -= perf_line_mult_min int +scoreboard players operation sstemp int > perf_line_mult_avg int +scoreboard players operation perf_line_mult_avg int += perf_line_mult_min int +scoreboard players operation sstemp int *= 100 int +scoreboard players operation sstemp int /= perf_line_mult_avg int +tellraw @a ["line_mult: {avg:",{"score":{"name":"perf_line_mult_avg","objective":"int"}},{"text":", min:"},{"score":{"name":"perf_line_mult_min","objective":"int"}},{"text":", max:"},{"score":{"name":"perf_line_mult_max","objective":"int"}},{"text":", max_err:"},{"score":{"name":"sstemp","objective":"int"}},"%}"] \ No newline at end of file diff --git a/data/math/functions/test/perf/std_loop0.mcfunction b/data/math/functions/test/perf/std_loop0.mcfunction new file mode 100644 index 0000000..59e09a0 --- /dev/null +++ b/data/math/functions/test/perf/std_loop0.mcfunction @@ -0,0 +1,4 @@ +#math:test/perf/std_loop0 +#循环迭代 +scoreboard players remove loop int 1 +execute if score loop int matches 1.. run function math:test/perf/std_loop0 \ No newline at end of file diff --git a/data/math/functions/test/perf/std_loop1.mcfunction b/data/math/functions/test/perf/std_loop1.mcfunction new file mode 100644 index 0000000..4cbbe40 --- /dev/null +++ b/data/math/functions/test/perf/std_loop1.mcfunction @@ -0,0 +1,5 @@ +#math:test/perf/std_loop1 +scoreboard players operation temp int += 10000 int +#循环迭代 +scoreboard players remove loop int 1 +execute if score loop int matches 1.. run function math:test/perf/std_loop1 \ No newline at end of file diff --git a/data/math/functions/test/perf/std_loop2.mcfunction b/data/math/functions/test/perf/std_loop2.mcfunction new file mode 100644 index 0000000..88260bd --- /dev/null +++ b/data/math/functions/test/perf/std_loop2.mcfunction @@ -0,0 +1,5 @@ +#math:test/perf/std_loop2 +scoreboard players operation temp int *= 10000 int +#循环迭代 +scoreboard players remove loop int 1 +execute if score loop int matches 1.. run function math:test/perf/std_loop2 \ No newline at end of file