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"}]