Skip to content

Instantly share code, notes, and snippets.

@intsuc
Last active August 22, 2019 15:07
Show Gist options
  • Save intsuc/9746a82b2a39149ab8bf2fc12b5afe9b to your computer and use it in GitHub Desktop.
Save intsuc/9746a82b2a39149ab8bf2fc12b5afe9b to your computer and use it in GitHub Desktop.
if statement with an implicit/explicit stack
execute if score #condition boolean matches 1 run function explicit-1-then
# peek
execute store result score #condition boolean run data get entity @s HandItems[0].tag.boolean_stack[-1]
execute if score #condition boolean matches 0 run function explicit-1-else
# push
data modify entity @s HandItems[0].tag.boolean_stack append value 0b
execute store success entity @s HandItems[0].tag.boolean_stack[-1] byte 1 store success score #condition boolean if block 0 0 0 minecraft:air
function explicit-1-if
# pop
data remove entity @s HandItems[0].tag.boolean_stack[-1]
execute as 0-0-0-0-0 run function explicit-1
execute if entity @s[y_rotation=1] run function implicit-1-then
# peek
teleport @s ~ ~ ~ ~ ~
execute if entity @s[y_rotation=0] run function implicit-1-else
# pop
execute store success entity @s Rotation[0] float 1 if block 0 0 0 minecraft:air
# push
execute rotated as @s run function implicit-1-if
execute as 0-0-0-0-0 run function implicit-1
scoreboard objectives add boolean dummy
summon minecraft:armor_stand ~ ~ ~ {UUIDMost: 0L, UUIDLeast: 0L, Marker: true, HandItems: [{id: "minecraft:tnt", Count: 1b, tag: {boolean_stack: []}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment