Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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"}]
Original file line number Diff line number Diff line change
@@ -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"}]
Loading