From 47f173c364ee10b5b0517e8fbfbf14254f6cde71 Mon Sep 17 00:00:00 2001 From: macroEngine bot Date: Wed, 19 Aug 2026 12:35:50 +0000 Subject: [PATCH] fix(experimental/particle_trail): toggle always resolved to 'on' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The toggle logic removed the tag first, then re-checked 'if entity @s[tag=...trail]' — which was now always false since the tag had just been removed on the previous line — so the early 'return 0' never fired and execution fell through to the 'add' line, re-adding the tag on every call. Net effect: toggle never actually turned the trail off. Split into toggle_on/toggle_off helpers and use 'execute ... run return run function ...' so the tag is tested exactly once and the two branches are truly mutually exclusive. --- .../particle_trail/toggle.mcfunction | 18 ++++++++++++------ .../particle_trail/toggle_off.mcfunction | 3 +++ .../particle_trail/toggle_on.mcfunction | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_off.mcfunction create mode 100644 packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_on.mcfunction diff --git a/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle.mcfunction b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle.mcfunction index 2654077..62fc192 100644 --- a/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle.mcfunction +++ b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle.mcfunction @@ -9,9 +9,15 @@ execute unless data storage macroengine:engine flags.experimental{particle_trail:1b} run tellraw @s ["",{"text":"[MACROENGINE] ","color":"#00AAAA","bold":true},{"text":"experimental/particle_trail is disabled.","color":"red"}] execute unless data storage macroengine:engine flags.experimental{particle_trail:1b} run return 0 -execute if entity @s[tag=macroengine.experimental.trail] run tag @s remove macroengine.experimental.trail -execute if entity @s[tag=macroengine.experimental.trail] run return 0 -execute unless entity @s[tag=macroengine.experimental.trail] run tag @s add macroengine.experimental.trail - -execute if entity @s[tag=macroengine.experimental.trail] run tellraw @s ["",{"text":"[MACROENGINE] ","color":"#00AAAA","bold":true},{"text":"particle trail → ","color":"gray"},{"text":"on","color":"green"}] -execute unless entity @s[tag=macroengine.experimental.trail] run tellraw @s ["",{"text":"[MACROENGINE] ","color":"#00AAAA","bold":true},{"text":"particle trail → ","color":"gray"},{"text":"off","color":"red"}] +# BUGFIX (was always resolving to "on"): the old code removed the tag +# first, then re-checked `if entity @s[tag=...trail]` — which was now +# always false since the tag had just been removed — so the early +# `return 0` never fired and execution fell through to the `add` line, +# re-adding the tag every time. +# +# Fix: test the tag exactly once. `return run` short-circuits this +# function on the first branch that matches, so the second `execute` +# line never runs when the first one did — the tag is never re-tested +# after being mutated. +execute if entity @s[tag=macroengine.experimental.trail] run return run function macroengine:experimental/particle_trail/toggle_off +execute unless entity @s[tag=macroengine.experimental.trail] run return run function macroengine:experimental/particle_trail/toggle_on diff --git a/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_off.mcfunction b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_off.mcfunction new file mode 100644 index 0000000..8bd4258 --- /dev/null +++ b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_off.mcfunction @@ -0,0 +1,3 @@ +# macroengine:experimental/particle_trail/toggle_off [INTERNAL] +tag @s remove macroengine.experimental.trail +tellraw @s ["",{"text":"[MACROENGINE] ","color":"#00AAAA","bold":true},{"text":"particle trail → ","color":"gray"},{"text":"off","color":"red"}] diff --git a/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_on.mcfunction b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_on.mcfunction new file mode 100644 index 0000000..b0e8363 --- /dev/null +++ b/packs/macroEngine-Datapack-1.21.2/data/macroengine/function/experimental/particle_trail/toggle_on.mcfunction @@ -0,0 +1,3 @@ +# macroengine:experimental/particle_trail/toggle_on [INTERNAL] +tag @s add macroengine.experimental.trail +tellraw @s ["",{"text":"[MACROENGINE] ","color":"#00AAAA","bold":true},{"text":"particle trail → ","color":"gray"},{"text":"on","color":"green"}]