From 026b8ed019d22bb5f746d13b95396b4fc1f4dd88 Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Thu, 1 Oct 2026 16:37:05 +0800 Subject: [PATCH 1/6] Enhance get_side_entities_count function with validation Added validation checks for side parameter and implemented entity counting logic for left, right, up, and down directions. --- .../lib/get_side_entities_count.mcfunction | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction new file mode 100644 index 0000000..cba2eb6 --- /dev/null +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -0,0 +1,51 @@ +## 此文件用于监测任意实体左右侧实体计数 +# 原理:半径足够大的圆可以近似看做一条直线 +# 传参:as 实体、side宏(0=左,1=右,2=上,3=下) + +scoreboard objective add dfl_scoreboard dummy +scoreboard objective add entities_side dummy +$scoreboard players set #lib_get_side_entities_side tmp $(side) + +## 校验 +# 显示校验失败 +execute \ + if score #lib_get_side_entities_side tmp matches -2147483647..-1 \ + run tellraw @s {\ + "text":"执行失败!side宏应为0(左)/1(右)!",\ + "color":"red"\ + } +execute \ + if score #lib_get_side_entities_side tmp matches 4..2147483647 \ + run tellraw @s {\ + "text":"执行失败!side宏应为0(左)/1(右)!",\ + "color":"red"\ + } +# 校验成功与执行 +#左 +execute \ + if score #lib_get_side_entities_side tmp matches 0 \ + rotated as @s \ + positioned ^1024 ^ ^ \ + store result score @s entities_side \ + if entity @e[distance=0..1024] +#右 +execute \ + if score #lib_get_side_entities_side tmp matches 0 \ + rotated as @s \ + positioned ^1024 ^ ^ \ + store result score @s entities_side \ + if entity @e[distance=0..1024] +#上 +execute \ + if score #lib_get_side_entities_side tmp matches 0 \ + rotated as @s \ + positioned ^ ^1024 ^ \ + store result score @s entities_side \ + if entity @e[distance=0..1024] +#下 +execute \ + if score #lib_get_side_entities_side tmp matches 0 \ + rotated as @s \ + positioned ^ ^-1024 ^ \ + store result score @s entities_side \ + if entity @e[distance=0..1024] From e08c21e5ebf13807d17945bbdf5546c8757404d7 Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Thu, 1 Oct 2026 16:53:47 +0800 Subject: [PATCH 2/6] =?UTF-8?q?666=E8=BF=99=E4=B8=AA=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E5=BF=98=E6=94=B9=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dfl/function/lib/get_side_entities_count.mcfunction | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction index cba2eb6..b3789da 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -11,13 +11,13 @@ $scoreboard players set #lib_get_side_entities_side tmp $(side) execute \ if score #lib_get_side_entities_side tmp matches -2147483647..-1 \ run tellraw @s {\ - "text":"执行失败!side宏应为0(左)/1(右)!",\ + "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ "color":"red"\ } execute \ if score #lib_get_side_entities_side tmp matches 4..2147483647 \ run tellraw @s {\ - "text":"执行失败!side宏应为0(左)/1(右)!",\ + "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ "color":"red"\ } # 校验成功与执行 From 6a2801909a83f255b136131a8dc1dc84d5f2108f Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Wed, 7 Oct 2026 14:04:07 +0800 Subject: [PATCH 3/6] Update get_side_entities_count.mcfunction --- .../lib/get_side_entities_count.mcfunction | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction index b3789da..2d0d896 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -1,21 +1,21 @@ -## 此文件用于监测任意实体左右侧实体计数 +## 此文件用于监测任意实体上、下、左、右侧实体计数 # 原理:半径足够大的圆可以近似看做一条直线 # 传参:as 实体、side宏(0=左,1=右,2=上,3=下) scoreboard objective add dfl_scoreboard dummy scoreboard objective add entities_side dummy -$scoreboard players set #lib_get_side_entities_side tmp $(side) +$scoreboard players set #lib_get_side_entities_side dfl_scoreboard $(side) ## 校验 # 显示校验失败 execute \ - if score #lib_get_side_entities_side tmp matches -2147483647..-1 \ + if score #lib_get_side_entities_side dfl_scoreboard matches -2147483647..-1 \ run tellraw @s {\ "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ "color":"red"\ } execute \ - if score #lib_get_side_entities_side tmp matches 4..2147483647 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 4..2147483647 \ run tellraw @s {\ "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ "color":"red"\ @@ -23,28 +23,28 @@ execute \ # 校验成功与执行 #左 execute \ - if score #lib_get_side_entities_side tmp matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ rotated as @s \ positioned ^1024 ^ ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] #右 execute \ - if score #lib_get_side_entities_side tmp matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ rotated as @s \ positioned ^1024 ^ ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] #上 execute \ - if score #lib_get_side_entities_side tmp matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ rotated as @s \ positioned ^ ^1024 ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] #下 execute \ - if score #lib_get_side_entities_side tmp matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ rotated as @s \ positioned ^ ^-1024 ^ \ store result score @s entities_side \ From 7e8a6a39797c64f55bed0c731c1a78a24c5a5faa Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Wed, 7 Oct 2026 14:05:15 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=80=8E=E4=B9=88=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E9=83=BD=E6=98=AF0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dfl/function/lib/get_side_entities_count.mcfunction | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction index 2d0d896..24fd27e 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -30,21 +30,21 @@ execute \ if entity @e[distance=0..1024] #右 execute \ - if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 1 \ rotated as @s \ positioned ^1024 ^ ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] #上 execute \ - if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 2 \ rotated as @s \ positioned ^ ^1024 ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] #下 execute \ - if score #lib_get_side_entities_side dfl_scoreboard matches 0 \ + if score #lib_get_side_entities_side dfl_scoreboard matches 3 \ rotated as @s \ positioned ^ ^-1024 ^ \ store result score @s entities_side \ From e627065d97f75e5aeac658941eb59526a033cca0 Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Wed, 7 Oct 2026 14:05:40 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=89=93=E9=94=99=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/dfl/function/lib/get_side_entities_count.mcfunction | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction index 24fd27e..891f736 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -2,8 +2,8 @@ # 原理:半径足够大的圆可以近似看做一条直线 # 传参:as 实体、side宏(0=左,1=右,2=上,3=下) -scoreboard objective add dfl_scoreboard dummy -scoreboard objective add entities_side dummy +scoreboard objectives add dfl_scoreboard dummy +scoreboard objectives add entities_side dummy $scoreboard players set #lib_get_side_entities_side dfl_scoreboard $(side) ## 校验 From 083b4fa91e35583b9072d0ccfcccce850775e2b6 Mon Sep 17 00:00:00 2001 From: chen0201 <18049754322@163.com> Date: Sat, 17 Oct 2026 12:31:17 +0800 Subject: [PATCH 6/6] Expand side entity count to include front and back --- .../lib/get_side_entities_count.mcfunction | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction index 891f736..31a108e 100644 --- a/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction +++ b/subprojects/datapack-function-library/data/dfl/function/lib/get_side_entities_count.mcfunction @@ -1,6 +1,6 @@ -## 此文件用于监测任意实体上、下、左、右侧实体计数 +## 此文件用于监测任意实体上、下、左、右、前、后侧实体计数 # 原理:半径足够大的圆可以近似看做一条直线 -# 传参:as 实体、side宏(0=左,1=右,2=上,3=下) +# 传参:as 实体、side宏(0=左,1=右,2=上,3=下,4=前,5=后) scoreboard objectives add dfl_scoreboard dummy scoreboard objectives add entities_side dummy @@ -11,13 +11,13 @@ $scoreboard players set #lib_get_side_entities_side dfl_scoreboard $(side) execute \ if score #lib_get_side_entities_side dfl_scoreboard matches -2147483647..-1 \ run tellraw @s {\ - "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ + "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)/4(前)/5(后)!",\ "color":"red"\ } execute \ if score #lib_get_side_entities_side dfl_scoreboard matches 4..2147483647 \ run tellraw @s {\ - "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)!",\ + "text":"执行失败!side宏应为0(左)/1(右)/2(上)/3(下)/4(前)/5(后)!",\ "color":"red"\ } # 校验成功与执行 @@ -49,3 +49,18 @@ execute \ positioned ^ ^-1024 ^ \ store result score @s entities_side \ if entity @e[distance=0..1024] +#前 +execute \ + if score #lib_get_side_entities_side dfl_scoreboard matches 4 \ + rotated as @s \ + positioned ^ ^ ^1024 \ + store result score @s entities_side \ + if entity @e[distance=0..1024] + +#后 +execute \ + if score #lib_get_side_entities_side dfl_scoreboard matches 5 \ + rotated as @s \ + positioned ^ ^ ^-1024 \ + store result score @s entities_side \ + if entity @e[distance=0..1024]