From a5b882dfec5e0fca5a4174177b998eb825e0cb3a Mon Sep 17 00:00:00 2001 From: xwjcool123 Date: Sat, 8 May 2021 18:16:27 +0800 Subject: [PATCH 1/3] Improve XOR algorithm The new algorithm only takes less than 100 commands and 3 variables to calculate the XOR value of two integers, which will (hopefully) improve the efficiency significantly. --- Copyrights.txt | 2 + .../private/calculate/xor.mcfunction | 462 ++++-------------- data/mrcd/functions/private/init.mcfunction | 30 +- 3 files changed, 112 insertions(+), 382 deletions(-) diff --git a/Copyrights.txt b/Copyrights.txt index 299e69f..500eda8 100644 --- a/Copyrights.txt +++ b/Copyrights.txt @@ -5,3 +5,5 @@ Copyrights of the content of this folder: All rights reserved. Please, do not sell it, if sharing this datapack attribute the work to the team, and if possible add a link. + +Current XOR algorithm is provided by xwjcool. diff --git a/data/mrcd/functions/private/calculate/xor.mcfunction b/data/mrcd/functions/private/calculate/xor.mcfunction index e310825..e935f98 100644 --- a/data/mrcd/functions/private/calculate/xor.mcfunction +++ b/data/mrcd/functions/private/calculate/xor.mcfunction @@ -1,361 +1,111 @@ # 函数参数: #var0, #var1 -# var0-1: 0-65535之间的被异或的数 +# var0-1: 被异或的两个Int32 # 返回值: #var0 -# var0: 0-65535之间的数 +# var0: Int32 # params: #var0, #var1 -# var0-1: number range from 0-65535 +# var0-1: two Int32s used for XOR calculation # return values: #var0 -# var0: number range from 0-65535 - -# 保存符号位 save sign bit -scoreboard players set #var_xor_sign0 mrcd_system 0 -scoreboard players set #var_xor_sign1 mrcd_system 0 -execute if score #var0 mrcd_system matches -2147483648..-1 run scoreboard players set #var_xor_sign0 mrcd_system 1 -execute if score #var1 mrcd_system matches -2147483648..-1 run scoreboard players set #var_xor_sign1 mrcd_system 1 - -# 计算补码 convert to complement -execute if score #var_xor_sign0 mrcd_system matches 1 run scoreboard players set #var_xor_t0 mrcd_system 2147483647 -execute if score #var_xor_sign0 mrcd_system matches 1 run scoreboard players operation #var_xor_t0 mrcd_system += #var0 mrcd_system -execute if score #var_xor_sign0 mrcd_system matches 1 run scoreboard players add #var_xor_t0 mrcd_system 1 -execute if score #var_xor_sign0 mrcd_system matches 1 run scoreboard players operation #var0 mrcd_system = #var_xor_t0 mrcd_system -execute if score #var_xor_sign1 mrcd_system matches 1 run scoreboard players set #var_xor_t1 mrcd_system 2147483647 -execute if score #var_xor_sign1 mrcd_system matches 1 run scoreboard players operation #var_xor_t1 mrcd_system += #var1 mrcd_system -execute if score #var_xor_sign1 mrcd_system matches 1 run scoreboard players add #var_xor_t1 mrcd_system 1 -execute if score #var_xor_sign1 mrcd_system matches 1 run scoreboard players operation #var1 mrcd_system = #var_xor_t1 mrcd_system - - -# 转换为二进制 convert to binary -execute store result score #var_xor_t0_0 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_1 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_2 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_3 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_4 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_5 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_6 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_7 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_8 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_9 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_10 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_11 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_12 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_13 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_14 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_15 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_16 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_17 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_18 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_19 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_20 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_21 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_22 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_23 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_24 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_25 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_26 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_27 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_28 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_29 mrcd_system run scoreboard players get #var0 mrcd_system -execute store result score #var_xor_t0_30 mrcd_system run scoreboard players get #var0 mrcd_system -scoreboard players operation #var_xor_t0_1 mrcd_system /= #n2 mrcd_system -scoreboard players operation #var_xor_t0_2 mrcd_system /= #n4 mrcd_system -scoreboard players operation #var_xor_t0_3 mrcd_system /= #n8 mrcd_system -scoreboard players operation #var_xor_t0_4 mrcd_system /= #n16 mrcd_system -scoreboard players operation #var_xor_t0_5 mrcd_system /= #n32 mrcd_system -scoreboard players operation #var_xor_t0_6 mrcd_system /= #n64 mrcd_system -scoreboard players operation #var_xor_t0_7 mrcd_system /= #n128 mrcd_system -scoreboard players operation #var_xor_t0_8 mrcd_system /= #n256 mrcd_system -scoreboard players operation #var_xor_t0_9 mrcd_system /= #n512 mrcd_system -scoreboard players operation #var_xor_t0_10 mrcd_system /= #n1024 mrcd_system -scoreboard players operation #var_xor_t0_11 mrcd_system /= #n2048 mrcd_system -scoreboard players operation #var_xor_t0_12 mrcd_system /= #n4096 mrcd_system -scoreboard players operation #var_xor_t0_13 mrcd_system /= #n8192 mrcd_system -scoreboard players operation #var_xor_t0_14 mrcd_system /= #n16384 mrcd_system -scoreboard players operation #var_xor_t0_15 mrcd_system /= #n32768 mrcd_system -scoreboard players operation #var_xor_t0_16 mrcd_system /= #n65536 mrcd_system -scoreboard players operation #var_xor_t0_17 mrcd_system /= #n131072 mrcd_system -scoreboard players operation #var_xor_t0_18 mrcd_system /= #n262144 mrcd_system -scoreboard players operation #var_xor_t0_19 mrcd_system /= #n524288 mrcd_system -scoreboard players operation #var_xor_t0_20 mrcd_system /= #n1048576 mrcd_system -scoreboard players operation #var_xor_t0_21 mrcd_system /= #n2097152 mrcd_system -scoreboard players operation #var_xor_t0_22 mrcd_system /= #n4194304 mrcd_system -scoreboard players operation #var_xor_t0_23 mrcd_system /= #n8388608 mrcd_system -scoreboard players operation #var_xor_t0_24 mrcd_system /= #n16777216 mrcd_system -scoreboard players operation #var_xor_t0_25 mrcd_system /= #n33554432 mrcd_system -scoreboard players operation #var_xor_t0_26 mrcd_system /= #n67108864 mrcd_system -scoreboard players operation #var_xor_t0_27 mrcd_system /= #n134217728 mrcd_system -scoreboard players operation #var_xor_t0_28 mrcd_system /= #n268435456 mrcd_system -scoreboard players operation #var_xor_t0_29 mrcd_system /= #n536870912 mrcd_system -scoreboard players operation #var_xor_t0_30 mrcd_system /= #n1073741824 mrcd_system -scoreboard players operation #var_xor_t0_0 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_1 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_2 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_3 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_4 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_5 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_6 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_7 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_8 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_9 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_10 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_11 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_12 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_13 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_14 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_15 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_16 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_17 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_18 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_19 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_20 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_21 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_22 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_23 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_24 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_25 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_26 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_27 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_28 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_29 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t0_30 mrcd_system %= #n2 mrcd_system -execute store result score #var_xor_t0_31 mrcd_system run scoreboard players get #var_xor_sign0 mrcd_system - -execute store result score #var_xor_t1_0 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_1 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_2 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_3 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_4 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_5 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_6 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_7 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_8 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_9 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_10 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_11 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_12 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_13 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_14 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_15 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_16 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_17 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_18 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_19 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_20 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_21 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_22 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_23 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_24 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_25 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_26 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_27 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_28 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_29 mrcd_system run scoreboard players get #var1 mrcd_system -execute store result score #var_xor_t1_30 mrcd_system run scoreboard players get #var1 mrcd_system -scoreboard players operation #var_xor_t1_1 mrcd_system /= #n2 mrcd_system -scoreboard players operation #var_xor_t1_2 mrcd_system /= #n4 mrcd_system -scoreboard players operation #var_xor_t1_3 mrcd_system /= #n8 mrcd_system -scoreboard players operation #var_xor_t1_4 mrcd_system /= #n16 mrcd_system -scoreboard players operation #var_xor_t1_5 mrcd_system /= #n32 mrcd_system -scoreboard players operation #var_xor_t1_6 mrcd_system /= #n64 mrcd_system -scoreboard players operation #var_xor_t1_7 mrcd_system /= #n128 mrcd_system -scoreboard players operation #var_xor_t1_8 mrcd_system /= #n256 mrcd_system -scoreboard players operation #var_xor_t1_9 mrcd_system /= #n512 mrcd_system -scoreboard players operation #var_xor_t1_10 mrcd_system /= #n1024 mrcd_system -scoreboard players operation #var_xor_t1_11 mrcd_system /= #n2048 mrcd_system -scoreboard players operation #var_xor_t1_12 mrcd_system /= #n4096 mrcd_system -scoreboard players operation #var_xor_t1_13 mrcd_system /= #n8192 mrcd_system -scoreboard players operation #var_xor_t1_14 mrcd_system /= #n16384 mrcd_system -scoreboard players operation #var_xor_t1_15 mrcd_system /= #n32768 mrcd_system -scoreboard players operation #var_xor_t1_16 mrcd_system /= #n65536 mrcd_system -scoreboard players operation #var_xor_t1_17 mrcd_system /= #n131072 mrcd_system -scoreboard players operation #var_xor_t1_18 mrcd_system /= #n262144 mrcd_system -scoreboard players operation #var_xor_t1_19 mrcd_system /= #n524288 mrcd_system -scoreboard players operation #var_xor_t1_20 mrcd_system /= #n1048576 mrcd_system -scoreboard players operation #var_xor_t1_21 mrcd_system /= #n2097152 mrcd_system -scoreboard players operation #var_xor_t1_22 mrcd_system /= #n4194304 mrcd_system -scoreboard players operation #var_xor_t1_23 mrcd_system /= #n8388608 mrcd_system -scoreboard players operation #var_xor_t1_24 mrcd_system /= #n16777216 mrcd_system -scoreboard players operation #var_xor_t1_25 mrcd_system /= #n33554432 mrcd_system -scoreboard players operation #var_xor_t1_26 mrcd_system /= #n67108864 mrcd_system -scoreboard players operation #var_xor_t1_27 mrcd_system /= #n134217728 mrcd_system -scoreboard players operation #var_xor_t1_28 mrcd_system /= #n268435456 mrcd_system -scoreboard players operation #var_xor_t1_29 mrcd_system /= #n536870912 mrcd_system -scoreboard players operation #var_xor_t1_30 mrcd_system /= #n1073741824 mrcd_system -scoreboard players operation #var_xor_t1_0 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_1 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_2 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_3 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_4 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_5 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_6 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_7 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_8 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_9 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_10 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_11 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_12 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_13 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_14 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_15 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_16 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_17 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_18 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_19 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_20 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_21 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_22 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_23 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_24 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_25 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_26 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_27 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_28 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_29 mrcd_system %= #n2 mrcd_system -scoreboard players operation #var_xor_t1_30 mrcd_system %= #n2 mrcd_system -execute store result score #var_xor_t1_31 mrcd_system run scoreboard players get #var_xor_sign1 mrcd_system - - - -#tellraw @a ["n0: ",{"score":{"name":"#var_xor_t0_31","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_30","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_29","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_28","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_27","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_26","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_25","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_24","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_23","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_22","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_21","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_20","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_19","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_18","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_17","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_16","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_15","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_14","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_13","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_12","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_11","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_10","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_9","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_8","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_7","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_6","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_5","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_4","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_3","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_2","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_1","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_0","objective":"mrcd_system"}}] -#tellraw @a ["n1: ",{"score":{"name":"#var_xor_t1_31","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_30","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_29","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_28","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_27","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_26","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_25","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_24","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_23","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_22","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_21","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_20","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_19","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_18","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_17","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_16","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_15","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_14","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_13","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_12","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_11","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_10","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_9","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_8","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_7","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_6","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_5","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_4","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_3","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_2","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_1","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t1_0","objective":"mrcd_system"}}] - -# 按位异或 xor by bit -scoreboard players operation #var_xor_t0_0 mrcd_system += #var_xor_t1_0 mrcd_system -scoreboard players operation #var_xor_t0_1 mrcd_system += #var_xor_t1_1 mrcd_system -scoreboard players operation #var_xor_t0_2 mrcd_system += #var_xor_t1_2 mrcd_system -scoreboard players operation #var_xor_t0_3 mrcd_system += #var_xor_t1_3 mrcd_system -scoreboard players operation #var_xor_t0_4 mrcd_system += #var_xor_t1_4 mrcd_system -scoreboard players operation #var_xor_t0_5 mrcd_system += #var_xor_t1_5 mrcd_system -scoreboard players operation #var_xor_t0_6 mrcd_system += #var_xor_t1_6 mrcd_system -scoreboard players operation #var_xor_t0_7 mrcd_system += #var_xor_t1_7 mrcd_system -scoreboard players operation #var_xor_t0_8 mrcd_system += #var_xor_t1_8 mrcd_system -scoreboard players operation #var_xor_t0_9 mrcd_system += #var_xor_t1_9 mrcd_system -scoreboard players operation #var_xor_t0_10 mrcd_system += #var_xor_t1_10 mrcd_system -scoreboard players operation #var_xor_t0_11 mrcd_system += #var_xor_t1_11 mrcd_system -scoreboard players operation #var_xor_t0_12 mrcd_system += #var_xor_t1_12 mrcd_system -scoreboard players operation #var_xor_t0_13 mrcd_system += #var_xor_t1_13 mrcd_system -scoreboard players operation #var_xor_t0_14 mrcd_system += #var_xor_t1_14 mrcd_system -scoreboard players operation #var_xor_t0_15 mrcd_system += #var_xor_t1_15 mrcd_system -scoreboard players operation #var_xor_t0_16 mrcd_system += #var_xor_t1_16 mrcd_system -scoreboard players operation #var_xor_t0_17 mrcd_system += #var_xor_t1_17 mrcd_system -scoreboard players operation #var_xor_t0_18 mrcd_system += #var_xor_t1_18 mrcd_system -scoreboard players operation #var_xor_t0_19 mrcd_system += #var_xor_t1_19 mrcd_system -scoreboard players operation #var_xor_t0_20 mrcd_system += #var_xor_t1_20 mrcd_system -scoreboard players operation #var_xor_t0_21 mrcd_system += #var_xor_t1_21 mrcd_system -scoreboard players operation #var_xor_t0_22 mrcd_system += #var_xor_t1_22 mrcd_system -scoreboard players operation #var_xor_t0_23 mrcd_system += #var_xor_t1_23 mrcd_system -scoreboard players operation #var_xor_t0_24 mrcd_system += #var_xor_t1_24 mrcd_system -scoreboard players operation #var_xor_t0_25 mrcd_system += #var_xor_t1_25 mrcd_system -scoreboard players operation #var_xor_t0_26 mrcd_system += #var_xor_t1_26 mrcd_system -scoreboard players operation #var_xor_t0_27 mrcd_system += #var_xor_t1_27 mrcd_system -scoreboard players operation #var_xor_t0_28 mrcd_system += #var_xor_t1_28 mrcd_system -scoreboard players operation #var_xor_t0_29 mrcd_system += #var_xor_t1_29 mrcd_system -scoreboard players operation #var_xor_t0_30 mrcd_system += #var_xor_t1_30 mrcd_system -scoreboard players operation #var_xor_t0_31 mrcd_system += #var_xor_t1_31 mrcd_system -execute if score #var_xor_t0_0 mrcd_system matches 2 run scoreboard players set #var_xor_t0_0 mrcd_system 0 -execute if score #var_xor_t0_1 mrcd_system matches 2 run scoreboard players set #var_xor_t0_1 mrcd_system 0 -execute if score #var_xor_t0_2 mrcd_system matches 2 run scoreboard players set #var_xor_t0_2 mrcd_system 0 -execute if score #var_xor_t0_3 mrcd_system matches 2 run scoreboard players set #var_xor_t0_3 mrcd_system 0 -execute if score #var_xor_t0_4 mrcd_system matches 2 run scoreboard players set #var_xor_t0_4 mrcd_system 0 -execute if score #var_xor_t0_5 mrcd_system matches 2 run scoreboard players set #var_xor_t0_5 mrcd_system 0 -execute if score #var_xor_t0_6 mrcd_system matches 2 run scoreboard players set #var_xor_t0_6 mrcd_system 0 -execute if score #var_xor_t0_7 mrcd_system matches 2 run scoreboard players set #var_xor_t0_7 mrcd_system 0 -execute if score #var_xor_t0_8 mrcd_system matches 2 run scoreboard players set #var_xor_t0_8 mrcd_system 0 -execute if score #var_xor_t0_9 mrcd_system matches 2 run scoreboard players set #var_xor_t0_9 mrcd_system 0 -execute if score #var_xor_t0_10 mrcd_system matches 2 run scoreboard players set #var_xor_t0_10 mrcd_system 0 -execute if score #var_xor_t0_11 mrcd_system matches 2 run scoreboard players set #var_xor_t0_11 mrcd_system 0 -execute if score #var_xor_t0_12 mrcd_system matches 2 run scoreboard players set #var_xor_t0_12 mrcd_system 0 -execute if score #var_xor_t0_13 mrcd_system matches 2 run scoreboard players set #var_xor_t0_13 mrcd_system 0 -execute if score #var_xor_t0_14 mrcd_system matches 2 run scoreboard players set #var_xor_t0_14 mrcd_system 0 -execute if score #var_xor_t0_15 mrcd_system matches 2 run scoreboard players set #var_xor_t0_15 mrcd_system 0 -execute if score #var_xor_t0_16 mrcd_system matches 2 run scoreboard players set #var_xor_t0_16 mrcd_system 0 -execute if score #var_xor_t0_17 mrcd_system matches 2 run scoreboard players set #var_xor_t0_17 mrcd_system 0 -execute if score #var_xor_t0_18 mrcd_system matches 2 run scoreboard players set #var_xor_t0_18 mrcd_system 0 -execute if score #var_xor_t0_19 mrcd_system matches 2 run scoreboard players set #var_xor_t0_19 mrcd_system 0 -execute if score #var_xor_t0_20 mrcd_system matches 2 run scoreboard players set #var_xor_t0_20 mrcd_system 0 -execute if score #var_xor_t0_21 mrcd_system matches 2 run scoreboard players set #var_xor_t0_21 mrcd_system 0 -execute if score #var_xor_t0_22 mrcd_system matches 2 run scoreboard players set #var_xor_t0_22 mrcd_system 0 -execute if score #var_xor_t0_23 mrcd_system matches 2 run scoreboard players set #var_xor_t0_23 mrcd_system 0 -execute if score #var_xor_t0_24 mrcd_system matches 2 run scoreboard players set #var_xor_t0_24 mrcd_system 0 -execute if score #var_xor_t0_25 mrcd_system matches 2 run scoreboard players set #var_xor_t0_25 mrcd_system 0 -execute if score #var_xor_t0_26 mrcd_system matches 2 run scoreboard players set #var_xor_t0_26 mrcd_system 0 -execute if score #var_xor_t0_27 mrcd_system matches 2 run scoreboard players set #var_xor_t0_27 mrcd_system 0 -execute if score #var_xor_t0_28 mrcd_system matches 2 run scoreboard players set #var_xor_t0_28 mrcd_system 0 -execute if score #var_xor_t0_29 mrcd_system matches 2 run scoreboard players set #var_xor_t0_29 mrcd_system 0 -execute if score #var_xor_t0_30 mrcd_system matches 2 run scoreboard players set #var_xor_t0_30 mrcd_system 0 -execute if score #var_xor_t0_31 mrcd_system matches 2 run scoreboard players set #var_xor_t0_31 mrcd_system 0 - -#tellraw @a ["n2: ",{"score":{"name":"#var_xor_t0_31","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_30","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_29","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_28","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_27","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_26","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_25","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_24","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_23","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_22","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_21","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_20","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_19","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_18","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_17","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_16","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_15","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_14","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_13","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_12","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_11","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_10","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_9","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_8","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_7","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_6","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_5","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_4","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_3","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_2","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_1","objective":"mrcd_system"}},{"score":{"name":"#var_xor_t0_0","objective":"mrcd_system"}}] - - - - - -# 转换为十进制 convert to demical -scoreboard players operation #var_xor_t0_1 mrcd_system *= #n2 mrcd_system -scoreboard players operation #var_xor_t0_2 mrcd_system *= #n4 mrcd_system -scoreboard players operation #var_xor_t0_3 mrcd_system *= #n8 mrcd_system -scoreboard players operation #var_xor_t0_4 mrcd_system *= #n16 mrcd_system -scoreboard players operation #var_xor_t0_5 mrcd_system *= #n32 mrcd_system -scoreboard players operation #var_xor_t0_6 mrcd_system *= #n64 mrcd_system -scoreboard players operation #var_xor_t0_7 mrcd_system *= #n128 mrcd_system -scoreboard players operation #var_xor_t0_8 mrcd_system *= #n256 mrcd_system -scoreboard players operation #var_xor_t0_9 mrcd_system *= #n512 mrcd_system -scoreboard players operation #var_xor_t0_10 mrcd_system *= #n1024 mrcd_system -scoreboard players operation #var_xor_t0_11 mrcd_system *= #n2048 mrcd_system -scoreboard players operation #var_xor_t0_12 mrcd_system *= #n4096 mrcd_system -scoreboard players operation #var_xor_t0_13 mrcd_system *= #n8192 mrcd_system -scoreboard players operation #var_xor_t0_14 mrcd_system *= #n16384 mrcd_system -scoreboard players operation #var_xor_t0_15 mrcd_system *= #n32768 mrcd_system -scoreboard players operation #var_xor_t0_16 mrcd_system *= #n65536 mrcd_system -scoreboard players operation #var_xor_t0_17 mrcd_system *= #n131072 mrcd_system -scoreboard players operation #var_xor_t0_18 mrcd_system *= #n262144 mrcd_system -scoreboard players operation #var_xor_t0_19 mrcd_system *= #n524288 mrcd_system -scoreboard players operation #var_xor_t0_20 mrcd_system *= #n1048576 mrcd_system -scoreboard players operation #var_xor_t0_21 mrcd_system *= #n2097152 mrcd_system -scoreboard players operation #var_xor_t0_22 mrcd_system *= #n4194304 mrcd_system -scoreboard players operation #var_xor_t0_23 mrcd_system *= #n8388608 mrcd_system -scoreboard players operation #var_xor_t0_24 mrcd_system *= #n16777216 mrcd_system -scoreboard players operation #var_xor_t0_25 mrcd_system *= #n33554432 mrcd_system -scoreboard players operation #var_xor_t0_26 mrcd_system *= #n67108864 mrcd_system -scoreboard players operation #var_xor_t0_27 mrcd_system *= #n134217728 mrcd_system -scoreboard players operation #var_xor_t0_28 mrcd_system *= #n268435456 mrcd_system -scoreboard players operation #var_xor_t0_29 mrcd_system *= #n536870912 mrcd_system -scoreboard players operation #var_xor_t0_30 mrcd_system *= #n1073741824 mrcd_system -scoreboard players set #var0 mrcd_system 0 -scoreboard players operation #var0 mrcd_system += #var_xor_t0_0 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_1 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_2 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_3 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_4 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_5 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_6 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_7 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_8 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_9 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_10 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_11 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_12 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_13 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_14 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_15 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_16 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_17 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_18 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_19 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_20 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_21 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_22 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_23 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_24 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_25 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_26 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_27 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_28 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_29 mrcd_system -scoreboard players operation #var0 mrcd_system += #var_xor_t0_30 mrcd_system - -execute if score #var_xor_t0_31 mrcd_system matches 1 run scoreboard players add #var0 mrcd_system 2147483647 -execute if score #var_xor_t0_31 mrcd_system matches 1 run scoreboard players add #var0 mrcd_system 1 - -#tellraw @a ["r: ",{"score":{"name":"#var0","objective":"mrcd_system"}}] +# var0: Int32 + +# 如果我先加再说呢? What if I do an addition first? +scoreboard players operation #xor_result mrcd_system = #var0 mrcd_system +scoreboard players operation #xor_result mrcd_system += #var1 mrcd_system + +# 检测并去除进位 detect and remove carried bits +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players operation #xor_result mrcd_system += #n2147483648 mrcd_system +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 1073741824 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 536870912 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 268435456 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 134217728 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 67108864 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 33554432 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 16777216 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 8388608 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 4194304 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 2097152 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 1048576 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 524288 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 262144 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 131072 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 65536 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 32768 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 16384 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 8192 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 4096 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 2048 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 1024 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 512 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 256 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 128 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 64 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 32 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 16 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 8 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 4 +scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system +scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system +execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players remove #xor_result mrcd_system 2 + +# Bam! There you have it! EZ! +scoreboard players operation #var0 mrcd_system = #xor_result mrcd_system diff --git a/data/mrcd/functions/private/init.mcfunction b/data/mrcd/functions/private/init.mcfunction index 4ca47d1..ded57a0 100644 --- a/data/mrcd/functions/private/init.mcfunction +++ b/data/mrcd/functions/private/init.mcfunction @@ -7,35 +7,13 @@ scoreboard players set #installed mrcd_system 1 scoreboard players set #n2 mrcd_system 2 -scoreboard players set #n4 mrcd_system 4 -scoreboard players set #n8 mrcd_system 8 scoreboard players set #n16 mrcd_system 16 -scoreboard players set #n32 mrcd_system 32 -scoreboard players set #n64 mrcd_system 64 -scoreboard players set #n128 mrcd_system 128 scoreboard players set #n256 mrcd_system 256 -scoreboard players set #n512 mrcd_system 512 -scoreboard players set #n1024 mrcd_system 1024 -scoreboard players set #n2048 mrcd_system 2048 -scoreboard players set #n4096 mrcd_system 4096 -scoreboard players set #n8192 mrcd_system 8192 -scoreboard players set #n16384 mrcd_system 16384 -scoreboard players set #n32768 mrcd_system 32768 scoreboard players set #n65536 mrcd_system 65536 -scoreboard players set #n131072 mrcd_system 131072 -scoreboard players set #n262144 mrcd_system 262144 -scoreboard players set #n524288 mrcd_system 524288 -scoreboard players set #n1048576 mrcd_system 1048576 -scoreboard players set #n2097152 mrcd_system 2097152 -scoreboard players set #n4194304 mrcd_system 4194304 -scoreboard players set #n8388608 mrcd_system 8388608 -scoreboard players set #n16777216 mrcd_system 16777216 -scoreboard players set #n33554432 mrcd_system 33554432 -scoreboard players set #n67108864 mrcd_system 67108864 -scoreboard players set #n134217728 mrcd_system 134217728 -scoreboard players set #n268435456 mrcd_system 268435456 -scoreboard players set #n536870912 mrcd_system 536870912 -scoreboard players set #n1073741824 mrcd_system 1073741824 + +# 符号位参与运算。关于异或我只要求这么多,只要不做除法就不会有事。 +# Use the sign bit in calculation. This is the only one more thing I need for XOR. It wont matter as long as no division happens. +scoreboard players set #n2147483648 mrcd_system -2147483648 scoreboard players set #nm1 mrcd_system -1 scoreboard players set #n11 mrcd_system 11 From 9a223af8fed33d235b8a9c18d8969daf36fc055d Mon Sep 17 00:00:00 2001 From: xwjcool123 Date: Sun, 9 May 2021 17:43:35 +0800 Subject: [PATCH 2/3] Fix block tags for 21w13a+ Remove copper slab/stair variations which once caused the tags to fail in versions above 21w13a. Some tag entries are no longer required for 1.16.2~1.16.5 compatibility --- data/mrcd/functions/private/category/pcp_117.mcfunction | 3 +++ .../private/category/player_can_pass.mcfunction | 5 ++--- data/mrcd/functions/private/category/solid.mcfunction | 9 ++------- .../mrcd/functions/private/category/solid_117.mcfunction | 8 ++++++++ data/mrcd/tags/blocks/carpet_like.json | 2 +- data/mrcd/tags/blocks/grass_path_like.json | 3 ++- data/mrcd/tags/blocks/hanging_roots_like.json | 2 +- data/mrcd/tags/blocks/player_can_pass.json | 6 +++--- data/mrcd/tags/blocks/rod_like.json | 2 +- data/mrcd/tags/blocks/slab_like.json | 9 +-------- data/mrcd/tags/blocks/stair_like.json | 9 +-------- data/mrcd/tags/blocks/vine_like.json | 2 +- data/mrcd/tags/blocks/weeping_like.json | 4 ++-- data/mrcd/tags/entity_types/ignore.json | 2 +- 14 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 data/mrcd/functions/private/category/pcp_117.mcfunction create mode 100644 data/mrcd/functions/private/category/solid_117.mcfunction diff --git a/data/mrcd/functions/private/category/pcp_117.mcfunction b/data/mrcd/functions/private/category/pcp_117.mcfunction new file mode 100644 index 0000000..6d061be --- /dev/null +++ b/data/mrcd/functions/private/category/pcp_117.mcfunction @@ -0,0 +1,3 @@ +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ small_dripleaf run function mrcd:private/types/small_dripleaf +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ big_dripleaf_stem run function mrcd:private/types/big_dripleaf_stem/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ spore_blossom run function mrcd:private/types/spore_blossom diff --git a/data/mrcd/functions/private/category/player_can_pass.mcfunction b/data/mrcd/functions/private/category/player_can_pass.mcfunction index 2ad26af..b793ada 100644 --- a/data/mrcd/functions/private/category/player_can_pass.mcfunction +++ b/data/mrcd/functions/private/category/player_can_pass.mcfunction @@ -19,9 +19,6 @@ execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ twisting_vines run funct execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ twisting_vines_plant run function mrcd:private/types/twisting_vines_plant execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ nether_sprouts run function mrcd:private/types/sprouts execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ soul_fire run function mrcd:private/types/soul_fire -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ small_dripleaf run function mrcd:private/types/small_dripleaf -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ big_dripleaf_stem run function mrcd:private/types/big_dripleaf_stem/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ spore_blossom run function mrcd:private/types/spore_blossom execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #wall_signs run function mrcd:private/types/wall_sign execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #buttons run function mrcd:private/types/button @@ -46,3 +43,5 @@ execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:pressure_plate_lik execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:mushroom run function mrcd:private/types/mushroom execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:fungus run function mrcd:private/types/fungus execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:roots run function mrcd:private/types/roots + +function mrcd:private/category/pcp_117 diff --git a/data/mrcd/functions/private/category/solid.mcfunction b/data/mrcd/functions/private/category/solid.mcfunction index 5e80f95..d392cbf 100644 --- a/data/mrcd/functions/private/category/solid.mcfunction +++ b/data/mrcd/functions/private/category/solid.mcfunction @@ -8,8 +8,6 @@ execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ bell run function mrcd:p execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ hopper run function mrcd:private/types/hopper execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ lectern run function mrcd:private/types/lectern execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ chorus_plant run function mrcd:private/types/chorus_plant -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ big_dripleaf run function mrcd:private/types/big_dripleaf/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ candle_cake run function mrcd:private/types/candle_cake execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #walls run function mrcd:private/types/wall execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #fences run function mrcd:private/types/fence @@ -35,11 +33,6 @@ execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ cake run function mrcd:p execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ ender_chest run function mrcd:private/types/chest execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ bamboo run function mrcd:private/types/bamboo execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ chain run function mrcd:private/types/chain -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ small_amethyst_bud run function mrcd:private/types/small_amethyst_bud/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ medium_amethyst_bud run function mrcd:private/types/medium_amethyst_bud/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ large_amethyst_bud run function mrcd:private/types/large_amethyst_bud/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ amethyst_cluster run function mrcd:private/types/amethyst_cluster/main -execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ pointed_dripstone run function mrcd:private/types/pointed_dripstone/main execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ turtle_egg run function mrcd:private/types/turtle_egg/main execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #campfires run function mrcd:private/types/campfires @@ -57,3 +50,5 @@ execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:skull_like run fun execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:wall_skull_like run function mrcd:private/types/wall_skull execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:grass_path_like run function mrcd:private/types/grass_path execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ #mrcd:rod_like run function mrcd:private/types/rod/main + +function mrcd:private/category/solid_117 diff --git a/data/mrcd/functions/private/category/solid_117.mcfunction b/data/mrcd/functions/private/category/solid_117.mcfunction new file mode 100644 index 0000000..ccd5235 --- /dev/null +++ b/data/mrcd/functions/private/category/solid_117.mcfunction @@ -0,0 +1,8 @@ +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ big_dripleaf run function mrcd:private/types/big_dripleaf/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ candle_cake run function mrcd:private/types/candle_cake + +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ small_amethyst_bud run function mrcd:private/types/small_amethyst_bud/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ medium_amethyst_bud run function mrcd:private/types/medium_amethyst_bud/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ large_amethyst_bud run function mrcd:private/types/large_amethyst_bud/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ amethyst_cluster run function mrcd:private/types/amethyst_cluster/main +execute if entity @s[tag=!mrcd_detected] if block ~ ~ ~ pointed_dripstone run function mrcd:private/types/pointed_dripstone/main diff --git a/data/mrcd/tags/blocks/carpet_like.json b/data/mrcd/tags/blocks/carpet_like.json index 0bda32e..5189b99 100644 --- a/data/mrcd/tags/blocks/carpet_like.json +++ b/data/mrcd/tags/blocks/carpet_like.json @@ -1,6 +1,6 @@ { "values": [ "#minecraft:carpets", - "minecraft:moss_carpet" + {"id": "minecraft:moss_carpet", "required": false} ] } diff --git a/data/mrcd/tags/blocks/grass_path_like.json b/data/mrcd/tags/blocks/grass_path_like.json index aaea633..a73ba3f 100644 --- a/data/mrcd/tags/blocks/grass_path_like.json +++ b/data/mrcd/tags/blocks/grass_path_like.json @@ -1,4 +1,5 @@ {"values":[ - "minecraft:dirt_path", + {"id": "minecraft:grass_path", "required": false}, + {"id": "minecraft:dirt_path", "required": false}, "minecraft:farmland" ]} diff --git a/data/mrcd/tags/blocks/hanging_roots_like.json b/data/mrcd/tags/blocks/hanging_roots_like.json index f4dca25..65993db 100644 --- a/data/mrcd/tags/blocks/hanging_roots_like.json +++ b/data/mrcd/tags/blocks/hanging_roots_like.json @@ -1,6 +1,6 @@ { "values": [ "minecraft:weeping_vines", - "minecraft:hanging_roots" + {"id": "minecraft:hanging_roots", "required": false} ] } diff --git a/data/mrcd/tags/blocks/player_can_pass.json b/data/mrcd/tags/blocks/player_can_pass.json index 0227c50..d887a60 100644 --- a/data/mrcd/tags/blocks/player_can_pass.json +++ b/data/mrcd/tags/blocks/player_can_pass.json @@ -62,8 +62,8 @@ "minecraft:water", "minecraft:nether_portal", - "minecraft:small_dripleaf", - "minecraft:big_dripleaf_stem", - "minecraft:spore_blossom" + {"id": "minecraft:small_dripleaf", "required": false}, + {"id": "minecraft:big_dripleaf_stem", "required": false}, + {"id": "minecraft:spore_blossom", "required": false} ]} diff --git a/data/mrcd/tags/blocks/rod_like.json b/data/mrcd/tags/blocks/rod_like.json index 95cbacf..f7d00e8 100644 --- a/data/mrcd/tags/blocks/rod_like.json +++ b/data/mrcd/tags/blocks/rod_like.json @@ -1,6 +1,6 @@ { "values": [ "minecraft:end_rod", - "minecraft:lightning_rod" + {"id": "minecraft:lightning_rod", "required": false} ] } diff --git a/data/mrcd/tags/blocks/slab_like.json b/data/mrcd/tags/blocks/slab_like.json index 46aacfc..5c8406a 100644 --- a/data/mrcd/tags/blocks/slab_like.json +++ b/data/mrcd/tags/blocks/slab_like.json @@ -1,13 +1,6 @@ { "values":[ "#minecraft:slabs", - "minecraft:cut_copper_slab", - "minecraft:exposed_cut_copper_slab", - "minecraft:weathered_cut_copper_slab", - "minecraft:oxidized_cut_copper_slab", - "minecraft:waxed_cut_copper_slab", - "minecraft:waxed_exposed_cut_copper_slab", - "minecraft:waxed_weathered_cut_copper_slab", - "minecraft:sculk_sensor" + {"id": "minecraft:sculk_sensor", "required": false} ] } diff --git a/data/mrcd/tags/blocks/stair_like.json b/data/mrcd/tags/blocks/stair_like.json index 8c5ab07..0b48a93 100644 --- a/data/mrcd/tags/blocks/stair_like.json +++ b/data/mrcd/tags/blocks/stair_like.json @@ -1,12 +1,5 @@ { "values":[ - "#minecraft:stairs", - "minecraft:cut_copper_stairs", - "minecraft:exposed_cut_copper_stairs", - "minecraft:weathered_cut_copper_stairs", - "minecraft:oxidized_cut_copper_stairs", - "minecraft:waxed_cut_copper_stairs", - "minecraft:waxed_exposed_cut_copper_stairs", - "minecraft:waxed_weathered_cut_copper_stairs" + "#minecraft:stairs" ] } diff --git a/data/mrcd/tags/blocks/vine_like.json b/data/mrcd/tags/blocks/vine_like.json index 86009ba..b919916 100644 --- a/data/mrcd/tags/blocks/vine_like.json +++ b/data/mrcd/tags/blocks/vine_like.json @@ -1,5 +1,5 @@ {"values":[ "minecraft:vine", "minecraft:fire", - "minecraft:glow_lichen" + {"id": "minecraft:glow_lichen", "required": false} ]} diff --git a/data/mrcd/tags/blocks/weeping_like.json b/data/mrcd/tags/blocks/weeping_like.json index 08e0e28..e417c94 100644 --- a/data/mrcd/tags/blocks/weeping_like.json +++ b/data/mrcd/tags/blocks/weeping_like.json @@ -1,7 +1,7 @@ { "values": [ "minecraft:weeping_vines_plant", - "minecraft:cave_vines_head", - "minecraft:cave_vines_body" + {"id": "minecraft:cave_vines_head", "required": false}, + {"id": "minecraft:cave_vines_body", "required": false} ] } diff --git a/data/mrcd/tags/entity_types/ignore.json b/data/mrcd/tags/entity_types/ignore.json index e4879c7..42ebbfd 100644 --- a/data/mrcd/tags/entity_types/ignore.json +++ b/data/mrcd/tags/entity_types/ignore.json @@ -11,7 +11,7 @@ "minecraft:fishing_bobber", "minecraft:item", "minecraft:item_frame", - "minecraft:glow_item_frame", + {"id": "minecraft:glow_item_frame", "required": false}, "minecraft:leash_knot", "minecraft:lightning_bolt", "minecraft:player", From fbc00e783e6f16e6ed1ced295f14b96aae90002d Mon Sep 17 00:00:00 2001 From: mattcarter11 <38189440+mattcarter11@users.noreply.github.com> Date: Tue, 15 Mar 2022 17:52:15 +0100 Subject: [PATCH 3/3] Keep only Eng coments to reduce lines count --- Copyrights.txt | 5 ++-- .../private/calculate/hashcode.mcfunction | 14 ++++------- .../private/calculate/offset.mcfunction | 15 +++++------- .../functions/private/calculate/x.mcfunction | 23 +++++-------------- .../private/calculate/xor.mcfunction | 18 ++++++--------- .../functions/private/calculate/y.mcfunction | 22 +++++------------- .../functions/private/calculate/z.mcfunction | 21 +++++------------ .../private/complex_cube/convert.mcfunction | 8 +++---- .../private/complex_cube/main.mcfunction | 1 - .../private/complex_cube/move.mcfunction | 2 +- .../private/complex_cube/x0.mcfunction | 8 ++----- .../private/complex_cube/x1.mcfunction | 8 ++----- .../private/complex_cube/y0.mcfunction | 8 ++----- .../private/complex_cube/y1.mcfunction | 8 ++----- .../private/complex_cube/z0.mcfunction | 8 ++----- .../private/complex_cube/z1.mcfunction | 8 ++----- .../functions/private/cube/main.mcfunction | 1 - .../mrcd/functions/private/cube/x0.mcfunction | 8 ++----- .../mrcd/functions/private/cube/x1.mcfunction | 8 ++----- .../mrcd/functions/private/cube/y0.mcfunction | 8 ++----- .../mrcd/functions/private/cube/y1.mcfunction | 8 ++----- .../mrcd/functions/private/cube/z0.mcfunction | 8 ++----- .../mrcd/functions/private/cube/z1.mcfunction | 8 ++----- data/mrcd/functions/private/entity.mcfunction | 4 ++-- .../private/entity_detect.mcfunction | 2 +- .../private/entity_targeted.mcfunction | 4 ++-- .../private/entity_targeted_detect.mcfunction | 2 +- .../functions/private/hit_block.mcfunction | 2 +- data/mrcd/functions/private/init.mcfunction | 1 - data/mrcd/functions/private/move.mcfunction | 4 +--- .../functions/private/next_cycle.mcfunction | 8 +++---- .../functions/private/reach_target.mcfunction | 4 ++-- .../mrcd/functions/private/recurse.mcfunction | 14 ++++------- data/mrcd/functions/ray_tick.mcfunction | 10 ++++---- 34 files changed, 89 insertions(+), 192 deletions(-) diff --git a/Copyrights.txt b/Copyrights.txt index 500eda8..266fe03 100644 --- a/Copyrights.txt +++ b/Copyrights.txt @@ -1,9 +1,8 @@ Copyrights of the content of this folder: - Creator & Developer: K-bai (minecraft name: K_bai) - Developer: mattcarter11 (minecraft name: YouKnowWhen) + - XOR algorithm: xwjcool All rights reserved. -Please, do not sell it, if sharing this datapack attribute the work to the team, and if possible add a link. - -Current XOR algorithm is provided by xwjcool. +Please, do not sell it, if sharing this datapack attribute the work to the team, and if possible add a link. \ No newline at end of file diff --git a/data/mrcd/functions/private/calculate/hashcode.mcfunction b/data/mrcd/functions/private/calculate/hashcode.mcfunction index e49c507..dd091cc 100644 --- a/data/mrcd/functions/private/calculate/hashcode.mcfunction +++ b/data/mrcd/functions/private/calculate/hashcode.mcfunction @@ -1,12 +1,8 @@ -# 函数参数: #var0, #var1 -# var0-1: int值,xz坐标 -# 返回值: #var0 -# var0: 哈希值 - -# params: #var0, #var1 -# var0-1: int value, x and z position -# return values: #var0 -# var0: hashcode +# args: x and z position +# #var0 (int) +# #var1 (int) +# return: hashcode +# #var0 (int) execute store result score #var_hc_x mrcd_system run scoreboard players get #var0 mrcd_system execute store result score #var_hc_z mrcd_system run scoreboard players get #var1 mrcd_system diff --git a/data/mrcd/functions/private/calculate/offset.mcfunction b/data/mrcd/functions/private/calculate/offset.mcfunction index 31fa6e0..92a5868 100644 --- a/data/mrcd/functions/private/calculate/offset.mcfunction +++ b/data/mrcd/functions/private/calculate/offset.mcfunction @@ -1,12 +1,9 @@ -# 函数参数: #var0, #var1 -# var0-1: int值,xz坐标 -# 返回值: #var0, #var1 -# var0-1: int值,xz坐标偏移量 - -# params: #var0, #var1 -# var0-1: int value, x and z position -# return values: #var0, #var1 -# var0-1: int value, x and z position offset +# args: x and z position +# #var0 (int) +# #var1 (int) +# return: x and z position offset +# #var0 (int) +# #var1 (int) function mrcd:private/calculate/hashcode execute store result score #var_ofs_hc mrcd_system run scoreboard players get #var0 mrcd_system diff --git a/data/mrcd/functions/private/calculate/x.mcfunction b/data/mrcd/functions/private/calculate/x.mcfunction index beb3f7c..fb3d5c3 100644 --- a/data/mrcd/functions/private/calculate/x.mcfunction +++ b/data/mrcd/functions/private/calculate/x.mcfunction @@ -1,24 +1,13 @@ -# 方程联立 -## 直线方程 (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## 平面方程 x=#target_x -# 计算线面交点 -## 若x0!=0 -### 方程整理得 y=(#target_x-x1)y0/x0+y1 -### 方程整理得 z=(#target_x-x1)z0/x0+z1 -## 若x0=0,无交点 - -## Line equation: (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## Plane equation: x=#target_x +# Line equation: (x-x1)/x0 = (y-y1)/y0 = (z-z1)/z0 +# Plane equation: x = #target_x # Calculate the intersection point coordinate -## if x0!=0 -### The equation can be arranged to: y=(#target_x-x1)y0/x0+y1 -### The equation can be arranged to: z=(#target_x-x1)z0/x0+z1 -## if x0=0, no intersection point - +# if x0!=0 +# The equation can be arranged to: y = (#target_x-x1)y0/x0+y1 +# The equation can be arranged to: z = (#target_x-x1)z0/x0+z1 +# if x0=0, no intersection point # x - # y execute store result score #target_y mrcd_system run scoreboard players get #target_x mrcd_system scoreboard players operation #target_y mrcd_system -= #block_x mrcd_system diff --git a/data/mrcd/functions/private/calculate/xor.mcfunction b/data/mrcd/functions/private/calculate/xor.mcfunction index e935f98..51781e7 100644 --- a/data/mrcd/functions/private/calculate/xor.mcfunction +++ b/data/mrcd/functions/private/calculate/xor.mcfunction @@ -1,18 +1,14 @@ -# 函数参数: #var0, #var1 -# var0-1: 被异或的两个Int32 -# 返回值: #var0 -# var0: Int32 +# args: +# #var0 (int32) +# #var1 (int32) +# return: +# #var0 (int32) -# params: #var0, #var1 -# var0-1: two Int32s used for XOR calculation -# return values: #var0 -# var0: Int32 - -# 如果我先加再说呢? What if I do an addition first? +# What if I do an addition first? scoreboard players operation #xor_result mrcd_system = #var0 mrcd_system scoreboard players operation #xor_result mrcd_system += #var1 mrcd_system -# 检测并去除进位 detect and remove carried bits +# detect and remove carried bits scoreboard players operation #var0 mrcd_system *= #n2 mrcd_system scoreboard players operation #var1 mrcd_system *= #n2 mrcd_system execute if score #var0 mrcd_system matches ..-1 if score #var1 mrcd_system matches ..-1 run scoreboard players operation #xor_result mrcd_system += #n2147483648 mrcd_system diff --git a/data/mrcd/functions/private/calculate/y.mcfunction b/data/mrcd/functions/private/calculate/y.mcfunction index 95a2c93..b60c079 100644 --- a/data/mrcd/functions/private/calculate/y.mcfunction +++ b/data/mrcd/functions/private/calculate/y.mcfunction @@ -1,20 +1,10 @@ -# 方程联立 -## 直线方程 (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## 平面方程 y=#target_y -# 计算线面交点 -## 若y0!=0 -### 方程整理得 x=(#target_y-y1)x0/y0+x1 -### 方程整理得 z=(#target_y-y1)z0/y0+z1 -## 若y0=0,无交点 - -## Line equation: (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## Plane equation: y=#target_y +# Line equation: (x-x1)/x0 = (y-y1)/y0 = (z-z1)/z0 +# Plane equation: y = #target_y # Calculate the intersection point coordinate -## if y0!=0 -### The equation can be arranged to: x=(#target_y-y1)x0/y0+x1 -### The equation can be arranged to: z=(#target_y-y1)z0/y0+z1 -## if y0=0, no intersection point - +# if y0!=0 +# The equation can be arranged to: x = (#target_y-y1)x0/y0+x1 +# The equation can be arranged to: z = (#target_y-y1)z0/y0+z1 +# if y0=0, no intersection point # x execute store result score #target_x mrcd_system run scoreboard players get #target_y mrcd_system diff --git a/data/mrcd/functions/private/calculate/z.mcfunction b/data/mrcd/functions/private/calculate/z.mcfunction index 5a09db7..616bd76 100644 --- a/data/mrcd/functions/private/calculate/z.mcfunction +++ b/data/mrcd/functions/private/calculate/z.mcfunction @@ -1,19 +1,10 @@ -# 方程联立 -## 直线方程 (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## 平面方程 z=#target_z -# 计算线面交点 -## 若z0!=0 -### 方程整理得 x=(#target_z-z1)x0/z0+x1 -### 方程整理得 y=(#target_z-z1)y0/z0+y1 -## 若z0=0,无交点 - -## Line equation: (x-x1)/x0=(y-y1)/y0=(z-z1)/z0 -## Plane equation: z=#target_z +# Line equation: (x-x1)/x0 = (y-y1)/y0 = (z-z1)/z0 +# Plane equation: z = #target_z # Calculate the intersection point coordinate -## if z0!=0 -### The equation can be arranged to: x=(#target_z-z1)x0/z0+x1 -### The equation can be arranged to: y=(#target_z-z1)y0/z0+y1 -## if z0=0, no intersection point +# if z0!=0 +# The equation can be arranged to: x = (#target_z-z1)x0/z0+x1 +# The equation can be arranged to: y = (#target_z-z1)y0/z0+y1 +# if z0=0, no intersection point diff --git a/data/mrcd/functions/private/complex_cube/convert.mcfunction b/data/mrcd/functions/private/complex_cube/convert.mcfunction index 5b3db72..5871e7c 100644 --- a/data/mrcd/functions/private/complex_cube/convert.mcfunction +++ b/data/mrcd/functions/private/complex_cube/convert.mcfunction @@ -1,18 +1,18 @@ -# 寻找最近实体 Find the nearnest block marker +# Find the nearnest block marker tag @e[tag=mrcd_touch_mark,sort=nearest,limit=1] add mrcd_temp -# 标记碰撞面 Copy the tag on the nearest block marker +# Copy the tag on the nearest block marker execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_x_plus] run tag @s add mrcd_touch_x_plus execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_x_minus] run tag @s add mrcd_touch_x_minus execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_y_plus] run tag @s add mrcd_touch_y_plus execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_y_minus] run tag @s add mrcd_touch_y_minus execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_z_plus] run tag @s add mrcd_touch_z_plus execute if entity @e[tag=mrcd_temp,tag=mrcd_touch_z_minus] run tag @s add mrcd_touch_z_minus -# 获取目标在方块内的坐标 Get the position of the nearest block marker +# Get the position of the nearest block marker execute store result score #target_x mrcd_system run data get entity @e[tag=mrcd_temp,limit=1] Pos[0] 1000 execute store result score #target_y mrcd_system run data get entity @e[tag=mrcd_temp,limit=1] Pos[1] 1000 execute store result score #target_z mrcd_system run data get entity @e[tag=mrcd_temp,limit=1] Pos[2] 1000 scoreboard players operation #target_x mrcd_system %= #const_1000 mrcd_system scoreboard players operation #target_y mrcd_system %= #const_1000 mrcd_system scoreboard players operation #target_z mrcd_system %= #const_1000 mrcd_system -# 删除标记 Kill all the block markers +# Kill all the block markers kill @e[tag=mrcd_touch_mark] diff --git a/data/mrcd/functions/private/complex_cube/main.mcfunction b/data/mrcd/functions/private/complex_cube/main.mcfunction index 119ed4b..1f61718 100644 --- a/data/mrcd/functions/private/complex_cube/main.mcfunction +++ b/data/mrcd/functions/private/complex_cube/main.mcfunction @@ -1,4 +1,3 @@ -# 根据朝向决定检测哪个面 # Choose a side to detect based on direction execute unless entity @e[tag=mrcd_touch_cube_edge] if score @s mrcd_x0 matches 1.. if score #block_x mrcd_system <= #box_x0 mrcd_system run function mrcd:private/complex_cube/x0 execute unless entity @e[tag=mrcd_touch_cube_edge] if score @s mrcd_x0 matches ..-1 if score #block_x mrcd_system >= #box_x1 mrcd_system run function mrcd:private/complex_cube/x1 diff --git a/data/mrcd/functions/private/complex_cube/move.mcfunction b/data/mrcd/functions/private/complex_cube/move.mcfunction index fdb4f86..f62cdf4 100644 --- a/data/mrcd/functions/private/complex_cube/move.mcfunction +++ b/data/mrcd/functions/private/complex_cube/move.mcfunction @@ -1,4 +1,4 @@ -# 移动到碰撞点 Move to #targetx,y,z +# Move to #targetx,y,z scoreboard players operation #target_x mrcd_system += #block_corner_x mrcd_system scoreboard players operation #target_y mrcd_system += #block_corner_y mrcd_system scoreboard players operation #target_z mrcd_system += #block_corner_z mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/x0.mcfunction b/data/mrcd/functions/private/complex_cube/x0.mcfunction index 8550bfd..e6ad53d 100644 --- a/data/mrcd/functions/private/complex_cube/x0.mcfunction +++ b/data/mrcd/functions/private/complex_cube/x0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 x=#box_x0 -## 相交条件 #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: x=#box_x0 -## Condition of crossing: #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 +# Plane equation: x = #box_x0 +# Condition of crossing: #box_y0 <= y <= #box_y1 #box_z0 <= z <= #box_z1 execute store result score #target_x mrcd_system run scoreboard players get #box_x0 mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/x1.mcfunction b/data/mrcd/functions/private/complex_cube/x1.mcfunction index 058c8ed..c613d28 100644 --- a/data/mrcd/functions/private/complex_cube/x1.mcfunction +++ b/data/mrcd/functions/private/complex_cube/x1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 x=#box_x1 -## 相交条件 #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: x=#box_x1 -## Condition of crossing: #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 +# Plane equation: x = #box_x1 +# Condition of crossing: #box_y0 <= y <= #box_y1 #box_z0 <= z <= #box_z1 execute store result score #target_x mrcd_system run scoreboard players get #box_x1 mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/y0.mcfunction b/data/mrcd/functions/private/complex_cube/y0.mcfunction index a3a0042..31eacfb 100644 --- a/data/mrcd/functions/private/complex_cube/y0.mcfunction +++ b/data/mrcd/functions/private/complex_cube/y0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 y=#box_y0 -## 相交条件 #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: y=#box_y0 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 +# Plane equation: y = #box_y0 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_z0 <= z <= #box_z1 execute store result score #target_y mrcd_system run scoreboard players get #box_y0 mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/y1.mcfunction b/data/mrcd/functions/private/complex_cube/y1.mcfunction index 8bd9d93..9821b27 100644 --- a/data/mrcd/functions/private/complex_cube/y1.mcfunction +++ b/data/mrcd/functions/private/complex_cube/y1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 y=#box_y1 -## 相交条件 #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: y=#box_y1 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 +# Plane equation: y = #box_y1 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_z0 <= z <= #box_z1 execute store result score #target_y mrcd_system run scoreboard players get #box_y1 mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/z0.mcfunction b/data/mrcd/functions/private/complex_cube/z0.mcfunction index 20b11d5..c8fdcc1 100644 --- a/data/mrcd/functions/private/complex_cube/z0.mcfunction +++ b/data/mrcd/functions/private/complex_cube/z0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 z=#box_z0 -## 相交条件 #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 - # Calculate the intersection point coordinate -## Plane equation: z=#box_z0 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 +# Plane equation: z = #box_z0 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_y0 <= y <= #box_y1 execute store result score #target_z mrcd_system run scoreboard players get #box_z0 mrcd_system diff --git a/data/mrcd/functions/private/complex_cube/z1.mcfunction b/data/mrcd/functions/private/complex_cube/z1.mcfunction index 1568212..39c0410 100644 --- a/data/mrcd/functions/private/complex_cube/z1.mcfunction +++ b/data/mrcd/functions/private/complex_cube/z1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 z=#box_z1 -## 相交条件 #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 - # Calculate the intersection point coordinate -## Plane equation: z=#box_z1 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 +# Plane equation: z = #box_z1 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_y0 <= y <= #box_y1 execute store result score #target_z mrcd_system run scoreboard players get #box_z1 mrcd_system diff --git a/data/mrcd/functions/private/cube/main.mcfunction b/data/mrcd/functions/private/cube/main.mcfunction index 837c2ee..951fe1f 100644 --- a/data/mrcd/functions/private/cube/main.mcfunction +++ b/data/mrcd/functions/private/cube/main.mcfunction @@ -1,4 +1,3 @@ -# 根据朝向决定检测哪个面 # Choose a side to detect based on direction execute if score @s[tag=!mrcd_touch_edge] mrcd_x0 matches 1.. if score #block_x mrcd_system <= #box_x0 mrcd_system run function mrcd:private/cube/x0 tag @s[tag=mrcd_touch_x_minus] add mrcd_touch_edge diff --git a/data/mrcd/functions/private/cube/x0.mcfunction b/data/mrcd/functions/private/cube/x0.mcfunction index 612e146..da2a75a 100644 --- a/data/mrcd/functions/private/cube/x0.mcfunction +++ b/data/mrcd/functions/private/cube/x0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 x=#box_x0 -## 相交条件 #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: x=#box_x0 -## Condition of crossing: #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 +# Plane equation: x = #box_x0 +# Condition of crossing: #box_y0 <= y <= #box_y1 #box_z0 <= z <= #box_z1 execute store result score #target_x mrcd_system run scoreboard players get #box_x0 mrcd_system function mrcd:private/calculate/x diff --git a/data/mrcd/functions/private/cube/x1.mcfunction b/data/mrcd/functions/private/cube/x1.mcfunction index 29815a1..64cc74a 100644 --- a/data/mrcd/functions/private/cube/x1.mcfunction +++ b/data/mrcd/functions/private/cube/x1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 x=#box_x1 -## 相交条件 #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: x=#box_x1 -## Condition of crossing: #box_y0<=y<=#box_y1 #box_z0<=z<=#box_z1 +# Plane equation: x = #box_x1 +# Condition of crossing: #box_y0 <= y <= #box_y1 #box_z0 <= z <= #box_z1 execute store result score #target_x mrcd_system run scoreboard players get #box_x1 mrcd_system function mrcd:private/calculate/x diff --git a/data/mrcd/functions/private/cube/y0.mcfunction b/data/mrcd/functions/private/cube/y0.mcfunction index a56e5a5..c779f6f 100644 --- a/data/mrcd/functions/private/cube/y0.mcfunction +++ b/data/mrcd/functions/private/cube/y0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 y=#box_y0 -## 相交条件 #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: y=#box_y0 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 +# Plane equation: y = #box_y0 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_z0 <= z <= #box_z1 execute store result score #target_y mrcd_system run scoreboard players get #box_y0 mrcd_system function mrcd:private/calculate/y diff --git a/data/mrcd/functions/private/cube/y1.mcfunction b/data/mrcd/functions/private/cube/y1.mcfunction index 1a25b73..000af0e 100644 --- a/data/mrcd/functions/private/cube/y1.mcfunction +++ b/data/mrcd/functions/private/cube/y1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 y=#box_y1 -## 相交条件 #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 - # Calculate the intersection point coordinate -## Plane equation: y=#box_y1 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_z0<=z<=#box_z1 +# Plane equation: y = #box_y1 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_z0 <= z <= #box_z1 execute store result score #target_y mrcd_system run scoreboard players get #box_y1 mrcd_system diff --git a/data/mrcd/functions/private/cube/z0.mcfunction b/data/mrcd/functions/private/cube/z0.mcfunction index 07881b7..4689812 100644 --- a/data/mrcd/functions/private/cube/z0.mcfunction +++ b/data/mrcd/functions/private/cube/z0.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 z=#box_z0 -## 相交条件 #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 - # Calculate the intersection point coordinate -## Plane equation: z=#box_z0 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 +# Plane equation: z = #box_z0 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_y0 <= y <= #box_y1 execute store result score #target_z mrcd_system run scoreboard players get #box_z0 mrcd_system diff --git a/data/mrcd/functions/private/cube/z1.mcfunction b/data/mrcd/functions/private/cube/z1.mcfunction index 7e213fd..ff11915 100644 --- a/data/mrcd/functions/private/cube/z1.mcfunction +++ b/data/mrcd/functions/private/cube/z1.mcfunction @@ -1,10 +1,6 @@ -# 计算线面交点 -## 平面方程 z=#box_z1 -## 相交条件 #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 - # Calculate the intersection point coordinate -## Plane equation: z=#box_z1 -## Condition of crossing: #box_x0<=x<=#box_x1 #box_y0<=y<=#box_y1 +# Plane equation: z = #box_z1 +# Condition of crossing: #box_x0 <= x <= #box_x1 #box_y0 <= y <= #box_y1 execute store result score #target_z mrcd_system run scoreboard players get #box_z1 mrcd_system diff --git a/data/mrcd/functions/private/entity.mcfunction b/data/mrcd/functions/private/entity.mcfunction index bbd36c6..cf6e93b 100644 --- a/data/mrcd/functions/private/entity.mcfunction +++ b/data/mrcd/functions/private/entity.mcfunction @@ -1,4 +1,4 @@ -# 一条线实体检测 Test entities on the sight +# Test entities on the sight execute at @s[tag=!mrcd_touch_entity] run function mrcd:private/entity_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^.2 run function mrcd:private/entity_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^.4 run function mrcd:private/entity_detect @@ -10,7 +10,7 @@ execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.4 run function mrcd:priv execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.6 run function mrcd:private/entity_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.7 run function mrcd:private/entity_detect -# 加tag Add tags +# Add tags execute if entity @s[tag=mrcd_touch_entity] run tag @s add mrcd_touch_edge tag @e[tag=mrcd_target_entity_temp] add mrcd_target_entity tag @e[tag=mrcd_target_entity_temp] remove mrcd_target_entity_temp diff --git a/data/mrcd/functions/private/entity_detect.mcfunction b/data/mrcd/functions/private/entity_detect.mcfunction index 56a0f2a..47b73d2 100644 --- a/data/mrcd/functions/private/entity_detect.mcfunction +++ b/data/mrcd/functions/private/entity_detect.mcfunction @@ -1,4 +1,4 @@ -# 实体检测 Entity test +# Entity test execute positioned ~-.05 ~-.05 ~-.05 if entity @e[type=!#mrcd:ignore,dx=0,dy=0,dz=0] positioned ~-.9 ~-.9 ~-.9 run tag @e[type=!#mrcd:ignore,dx=0,dy=0,dz=0] add mrcd_target_entity_temp execute if entity @e[tag=mrcd_target_entity_temp] run tag @s add mrcd_touch_entity #execute if entity @s[tag=mrcd_touch_entity] run tp @s ~ ~ ~ diff --git a/data/mrcd/functions/private/entity_targeted.mcfunction b/data/mrcd/functions/private/entity_targeted.mcfunction index 5e5c112..fa08284 100644 --- a/data/mrcd/functions/private/entity_targeted.mcfunction +++ b/data/mrcd/functions/private/entity_targeted.mcfunction @@ -1,4 +1,4 @@ -# 一条线实体检测 Test entities on the sight +# Test entities on the sight execute at @s[tag=!mrcd_touch_entity] run function mrcd:private/entity_targeted_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^.2 run function mrcd:private/entity_targeted_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^.4 run function mrcd:private/entity_targeted_detect @@ -10,7 +10,7 @@ execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.4 run function mrcd:priv execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.6 run function mrcd:private/entity_targeted_detect execute at @s[tag=!mrcd_touch_entity] positioned ^ ^ ^1.7 run function mrcd:private/entity_targeted_detect -# 加tag Add tags +# Add tags execute if entity @s[tag=mrcd_touch_entity] run tag @s add mrcd_touch_edge tag @e[tag=mrcd_target_entity_temp] add mrcd_target_entity tag @e[tag=mrcd_target_entity_temp] remove mrcd_target_entity_temp diff --git a/data/mrcd/functions/private/entity_targeted_detect.mcfunction b/data/mrcd/functions/private/entity_targeted_detect.mcfunction index e8bf9c0..267ddc8 100644 --- a/data/mrcd/functions/private/entity_targeted_detect.mcfunction +++ b/data/mrcd/functions/private/entity_targeted_detect.mcfunction @@ -1,4 +1,4 @@ -# 实体检测 Entity test +# Entity test execute positioned ~-.05 ~-.05 ~-.05 if entity @e[tag=mrcd_target,dx=0,dy=0,dz=0] positioned ~-.9 ~-.9 ~-.9 run tag @e[tag=mrcd_target,dx=0,dy=0,dz=0] add mrcd_target_entity_temp execute if entity @e[tag=mrcd_target_entity_temp] run tag @s add mrcd_touch_entity #execute if entity @s[tag=mrcd_touch_entity] run tp @s ~ ~ ~ diff --git a/data/mrcd/functions/private/hit_block.mcfunction b/data/mrcd/functions/private/hit_block.mcfunction index 2a7c341..f791130 100644 --- a/data/mrcd/functions/private/hit_block.mcfunction +++ b/data/mrcd/functions/private/hit_block.mcfunction @@ -1,4 +1,4 @@ -# 直接传送到#target的位置 Tp to #target position +# Tp to #target position execute if entity @s[tag=!mrcd_touch_entity] run function mrcd:private/move scoreboard players set #target_x mrcd_system 0 scoreboard players set #target_y mrcd_system 0 diff --git a/data/mrcd/functions/private/init.mcfunction b/data/mrcd/functions/private/init.mcfunction index ded57a0..09cbe30 100644 --- a/data/mrcd/functions/private/init.mcfunction +++ b/data/mrcd/functions/private/init.mcfunction @@ -11,7 +11,6 @@ scoreboard players set #n16 mrcd_system 16 scoreboard players set #n256 mrcd_system 256 scoreboard players set #n65536 mrcd_system 65536 -# 符号位参与运算。关于异或我只要求这么多,只要不做除法就不会有事。 # Use the sign bit in calculation. This is the only one more thing I need for XOR. It wont matter as long as no division happens. scoreboard players set #n2147483648 mrcd_system -2147483648 diff --git a/data/mrcd/functions/private/move.mcfunction b/data/mrcd/functions/private/move.mcfunction index 60b35d6..e125fa8 100644 --- a/data/mrcd/functions/private/move.mcfunction +++ b/data/mrcd/functions/private/move.mcfunction @@ -1,4 +1,4 @@ -# 移动到目标处 Move to #targetx,y,z +# Move to #targetx,y,z execute store result score #target_temp_x mrcd_system run scoreboard players get #target_x mrcd_system execute store result score #target_temp_y mrcd_system run scoreboard players get #target_y mrcd_system execute store result score #target_temp_z mrcd_system run scoreboard players get #target_z mrcd_system @@ -9,12 +9,10 @@ execute store result entity @s Pos[0] double 0.001 run scoreboard players get #t execute store result entity @s Pos[1] double 0.001 run scoreboard players get #target_y mrcd_system execute store result entity @s Pos[2] double 0.001 run scoreboard players get #target_z mrcd_system -# 如果是-1,就往边界靠靠 # -1 means it reached the block on the negative side execute if score #target_temp_x mrcd_system matches -1 at @s run tp @s ~0.0009 ~ ~ ~ ~ execute if score #target_temp_y mrcd_system matches -1 at @s run tp @s ~ ~0.0009 ~ ~ ~ execute if score #target_temp_z mrcd_system matches -1 at @s run tp @s ~ ~ ~0.0009 ~ ~ -# 如果碰到方块了,并且还在1000的边界,为了让AEC在被碰撞的方块内,要轻微移动一下 # 1000 means it reached the block on the positive side execute if entity @s[tag=mrcd_touch_edge] if score #target_temp_x mrcd_system matches 1000 at @s run tp @s ~-0.00001 ~ ~ ~ ~ execute if entity @s[tag=mrcd_touch_edge] if score #target_temp_y mrcd_system matches 1000 at @s run tp @s ~ ~-0.00001 ~ ~ ~ diff --git a/data/mrcd/functions/private/next_cycle.mcfunction b/data/mrcd/functions/private/next_cycle.mcfunction index 1a2016a..c8d55b9 100644 --- a/data/mrcd/functions/private/next_cycle.mcfunction +++ b/data/mrcd/functions/private/next_cycle.mcfunction @@ -1,8 +1,8 @@ -# 修改#total +# #total scoreboard players operation #total_x mrcd_system -= #target_c_x mrcd_system scoreboard players operation #total_y mrcd_system -= #target_c_y mrcd_system scoreboard players operation #total_z mrcd_system -= #target_c_z mrcd_system -# 修改#block +# #block scoreboard players operation #block_x mrcd_system = #target_x mrcd_system scoreboard players operation #block_y mrcd_system = #target_y mrcd_system scoreboard players operation #block_z mrcd_system = #target_z mrcd_system @@ -12,7 +12,7 @@ execute if score #target_z mrcd_system matches 1000 run scoreboard players set # execute if score #target_x mrcd_system matches -1 run scoreboard players set #block_x mrcd_system 1000 execute if score #target_y mrcd_system matches -1 run scoreboard players set #block_y mrcd_system 1000 execute if score #target_z mrcd_system matches -1 run scoreboard players set #block_z mrcd_system 1000 -# 修改#block_corner +# #block_corner execute if score #target_x mrcd_system matches 1000 run scoreboard players add #block_corner_x mrcd_system 1000 execute if score #target_y mrcd_system matches 1000 run scoreboard players add #block_corner_y mrcd_system 1000 execute if score #target_z mrcd_system matches 1000 run scoreboard players add #block_corner_z mrcd_system 1000 @@ -26,7 +26,7 @@ execute if score #target_z mrcd_system matches -1 run scoreboard players remove #tellraw @a ["block_corner_x:",{"score":{"name":"#block_corner_x","objective":"mrcd_system"}},", block_corner_y:",{"score":{"name":"#block_corner_y","objective":"mrcd_system"}},", block_corner_z:",{"score":{"name":"#block_corner_z","objective":"mrcd_system"}}] -# 改变执行坐标继续递归 Change execute position and continue +# Change execute position and continue execute if score #target_x mrcd_system matches 1000 positioned ~1 ~ ~ run function mrcd:private/recurse execute if score #target_x mrcd_system matches -1 positioned ~-1 ~ ~ run function mrcd:private/recurse execute if score #target_y mrcd_system matches 1000 positioned ~ ~1 ~ run function mrcd:private/recurse diff --git a/data/mrcd/functions/private/reach_target.mcfunction b/data/mrcd/functions/private/reach_target.mcfunction index 00c76aa..4c0ff3e 100644 --- a/data/mrcd/functions/private/reach_target.mcfunction +++ b/data/mrcd/functions/private/reach_target.mcfunction @@ -1,4 +1,4 @@ -# 直接传送到#target的位置 Tp to #target position +# Tp to #target position scoreboard players operation #target_x mrcd_system = #total_x mrcd_system scoreboard players operation #target_y mrcd_system = #total_y mrcd_system scoreboard players operation #target_z mrcd_system = #total_z mrcd_system @@ -6,7 +6,7 @@ scoreboard players operation #target_x mrcd_system += #block_x mrcd_system scoreboard players operation #target_y mrcd_system += #block_y mrcd_system scoreboard players operation #target_z mrcd_system += #block_z mrcd_system execute if entity @s[tag=!mrcd_touch_entity] run function mrcd:private/move -# 清除碰撞标签 Clear collision tags and scoreboards +# Clear collision tags and scoreboards tag @s[tag=mrcd_touch_edge] remove mrcd_touch_edge scoreboard players set #target_x mrcd_system 0 scoreboard players set #target_y mrcd_system 0 diff --git a/data/mrcd/functions/private/recurse.mcfunction b/data/mrcd/functions/private/recurse.mcfunction index 6c41c4a..ef3b402 100644 --- a/data/mrcd/functions/private/recurse.mcfunction +++ b/data/mrcd/functions/private/recurse.mcfunction @@ -1,8 +1,8 @@ -# 清空上一次的tag Clear tags from last tick +# Clear tags from last tick tag @s[tag=mrcd_detected] remove mrcd_detected tag @s[tag=mrcd_touch_edge_air] remove mrcd_touch_edge_air -# 方块碰撞判定 Block collision test +# Block collision test ## 当前是空气类方块,跳过 Skip if current block is air execute if block ~ ~ ~ #mrcd:air_like run tag @s add mrcd_detected ## 当前是子弹可穿过方块,跳过 Skip if the marker type is bullet and current block can be passed by player @@ -20,10 +20,9 @@ execute if entity @s[tag=!mrcd_touch_edge] run function mrcd:private/types/air/m #tellraw @a ["target_x:",{"score":{"name":"#target_x","objective":"mrcd_system"}},", target_y:",{"score":{"name":"#target_y","objective":"mrcd_system"}},", target_z:",{"score":{"name":"#target_z","objective":"mrcd_system"}}] #tellraw @a ["block_x:",{"score":{"name":"#block_x","objective":"mrcd_system"}},", block_y:",{"score":{"name":"#block_y","objective":"mrcd_system"}},", block_z:",{"score":{"name":"#block_z","objective":"mrcd_system"}}] -# 把复杂方块的实体转化为坐标 Convert the complex block markers to #target_x,y,z +# Convert the complex block markers to #target_x,y,z execute if entity @s[tag=mrcd_touch_edge_complex] run function mrcd:private/complex_cube/convert -# 实体碰撞判定 本格内有目标生物则执行 此处有dxdydz bug # Entity collision test. Executed if there are any entities in this block. Exist dxdydz bug. execute at @s[tag=mrcd_entity] align xyz if entity @e[type=!#mrcd:ignore,dx=0,dy=0,dz=0] run function mrcd:private/entity execute at @s[tag=mrcd_entity_targeted] align xyz if entity @e[tag=mrcd_target,dx=0,dy=0,dz=0] run function mrcd:private/entity_targeted @@ -31,8 +30,7 @@ execute at @s[tag=mrcd_entity_targeted] align xyz if entity @e[tag=mrcd_target,d -# 移动位置相关 Move marker -## 修改为相对当前坐标的位置 +# Move marker ## Convert #target_x,y,z to a coordinate(#target_c_x,y,z) which based on the coordinate of marker (before based on the coordinate of block corner) execute store result score #target_c_x mrcd_system run scoreboard players get #target_x mrcd_system execute store result score #target_c_y mrcd_system run scoreboard players get #target_y mrcd_system @@ -40,7 +38,6 @@ execute store result score #target_c_z mrcd_system run scoreboard players get #t scoreboard players operation #target_c_x mrcd_system -= #block_x mrcd_system scoreboard players operation #target_c_y mrcd_system -= #block_y mrcd_system scoreboard players operation #target_c_z mrcd_system -= #block_z mrcd_system -## 判定目标距离和总距离的绝对值大小 ## Which is longer? Length of #target_c_x,y,z or #total_x,y,z? execute store result score #var0 mrcd_system run scoreboard players get #total_x mrcd_system execute store result score #var1 mrcd_system run scoreboard players get #target_c_x mrcd_system @@ -59,12 +56,9 @@ scoreboard players operation #var2 mrcd_system -= #var3 mrcd_system scoreboard players operation #var4 mrcd_system -= #var5 mrcd_system execute if score #var0 mrcd_system matches ..0 if score #var2 mrcd_system matches ..0 if score #var4 mrcd_system matches ..0 run scoreboard players set #if_reach_target mrcd_system 1 execute if score #var0 mrcd_system matches 0.. if score #var2 mrcd_system matches 0.. if score #var4 mrcd_system matches 0.. run scoreboard players set #if_reach_target mrcd_system 0 -### 如果总距离小于等于目标距离,表示到达终点 ### #total_x,y,z<#target_c_x,y,z ----> Reached the distance limit execute if score #if_reach_target mrcd_system matches 1 run function mrcd:private/reach_target -### 如果总距离大于目标距离,且碰撞方块,表示到达终点 ### #total_x,y,z >= #target_c_x,y,z and collide with a block ----> Collide with a block execute if score #if_reach_target mrcd_system matches 0 if entity @s[tag=mrcd_touch_edge] run function mrcd:private/hit_block -### 如果总距离大于目标距离,且未碰撞方块,表示还未到达终点 ### #total_x,y,z >= #target_c_x,y,z and not collide with a block ----> Next cycle execute if score #if_reach_target mrcd_system matches 0 if entity @s[tag=!mrcd_touch_edge] run function mrcd:private/next_cycle diff --git a/data/mrcd/functions/ray_tick.mcfunction b/data/mrcd/functions/ray_tick.mcfunction index edd79b5..5f92e38 100644 --- a/data/mrcd/functions/ray_tick.mcfunction +++ b/data/mrcd/functions/ray_tick.mcfunction @@ -1,4 +1,4 @@ -# 清空标签 Clear tags +# Clear tags tag @s[tag=mrcd_touch_edge] remove mrcd_touch_edge tag @s[tag=mrcd_touch_edge_complex] remove mrcd_touch_edge_complex tag @s[tag=mrcd_touch_x_plus] remove mrcd_touch_x_plus @@ -8,14 +8,12 @@ tag @s[tag=mrcd_touch_y_minus] remove mrcd_touch_y_minus tag @s[tag=mrcd_touch_z_plus] remove mrcd_touch_z_plus tag @s[tag=mrcd_touch_z_minus] remove mrcd_touch_z_minus -# 设定距离 Set total distance +# Set total distance execute store result score #total_x mrcd_system run scoreboard players get @s mrcd_x0 execute store result score #total_y mrcd_system run scoreboard players get @s mrcd_y0 execute store result score #total_z mrcd_system run scoreboard players get @s mrcd_z0 -# 获取在方块内的坐标和方块角落坐标 Get the coordinate of current block -# #block_x,y,z: 范围是0-1000,表示相对方块顶点坐标 -# #block_corner_x,y,z: 表示方块顶点绝对坐标(1000倍) +# Get the coordinate of current block # #block_x,y,z: range from 0-1000, relative coordinate in a block # #block_corner_x,y,z: absolute coordinate of current block (multiply by 1000) execute store result score #block_x mrcd_system run data get entity @s Pos[0] 1000 @@ -39,5 +37,5 @@ execute if score #block_z mrcd_system matches 999 run scoreboard players set #bl #tellraw @a ["block_x:",{"score":{"name":"#block_x","objective":"mrcd_system"}},", block_y:",{"score":{"name":"#block_y","objective":"mrcd_system"}},", block_z:",{"score":{"name":"#block_z","objective":"mrcd_system"}}] #tellraw @a ["block_corner_x:",{"score":{"name":"#block_corner_x","objective":"mrcd_system"}},", block_corner_y:",{"score":{"name":"#block_corner_y","objective":"mrcd_system"}},", block_corner_z:",{"score":{"name":"#block_corner_z","objective":"mrcd_system"}}] -# 递归 Recurse +# Recurse execute at @s run function mrcd:private/recurse