diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction new file mode 100644 index 0000000..c345f4e --- /dev/null +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction @@ -0,0 +1,17 @@ +# 此函数读取当前实体的位置并写入计分板 + +scoreboard objectives add dfl_entity_pos_x dummy +scoreboard objectives add dfl_entity_pos_y dummy +scoreboard objectives add dfl_entity_pos_z dummy + +# x轴坐标 +execute store result score @s dfl_entity_pos_x \ + run data get entity @s Pos[0] + +# y轴坐标 +execute store result score @s dfl_entity_pos_y \ + run data get entity @s Pos[1] + +# z轴坐标 +execute store result score @s dfl_entity_pos_z \ + run data get entity @s Pos[2]