From 71d5345c06f4e3522f5a2383073ba7d504e734a8 Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Sat, 26 Sep 2026 20:26:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=EF=B8=8F=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=8E=A9=E5=AE=B6=E4=BD=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (还得学着bro的表情包式commit消息:/) --- .../data/dfl/function/lib/get_pos.mcfunction | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction 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..39a5e58 --- /dev/null +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction @@ -0,0 +1,24 @@ +# 此函数用于获取玩家当前位置至计分板 +# 需要传参:execute的子命令:as 玩家(也许可以获取任意实体的,但没试过) + +scoreboard objectives add player_x dummy +scoreboard objectives add player_y dummy +scoreboard objectives add player_z dummy + +# x轴坐标 +execute \ + at @s \ + store result score @s player_x \ + run data get entity @s Pos[0] + +# y轴坐标 +execute \ + at @s \ + store result score @s player_y \ + run data get entity @s Pos[1] + +# z轴坐标 +execute \ + at @s \ + store result score @s player_z \ + run data get entity @s Pos[2] From ba63f7261c337600dfb35a9f1bfcff8d90b9a11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=B1=A1=5Felephant?= Date: Sun, 27 Sep 2026 00:56:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[DFL]=20=E6=9B=B4=E6=96=B0lib/get=5Fpos?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4execute=E4=B8=AD=E7=9A=84=E5=86=97?= =?UTF-8?q?=E4=BD=99at=20@s=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E8=AE=B0?= =?UTF-8?q?=E5=88=86=E9=A1=B9=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 读取的是nbt,而不依赖执行位置,所以实际上不需要at @s --- .../data/dfl/function/lib/get_pos.mcfunction | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) 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 index 39a5e58..c345f4e 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_pos.mcfunction @@ -1,24 +1,17 @@ -# 此函数用于获取玩家当前位置至计分板 -# 需要传参:execute的子命令:as 玩家(也许可以获取任意实体的,但没试过) +# 此函数读取当前实体的位置并写入计分板 -scoreboard objectives add player_x dummy -scoreboard objectives add player_y dummy -scoreboard objectives add player_z dummy +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 \ - at @s \ - store result score @s player_x \ +execute store result score @s dfl_entity_pos_x \ run data get entity @s Pos[0] # y轴坐标 -execute \ - at @s \ - store result score @s player_y \ +execute store result score @s dfl_entity_pos_y \ run data get entity @s Pos[1] # z轴坐标 -execute \ - at @s \ - store result score @s player_z \ +execute store result score @s dfl_entity_pos_z \ run data get entity @s Pos[2]