Skip to content

Instantly share code, notes, and snippets.

@Arcensoth
Created August 18, 2017 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arcensoth/4f3a4aee5d9a7fb6d5387fc942281d36 to your computer and use it in GitHub Desktop.
Save Arcensoth/4f3a4aee5d9a7fb6d5387fc942281d36 to your computer and use it in GitHub Desktop.
# (1) explicitly chained
commands.execute().chain(
commands.execute.at(
target=selectors.entities(type=entities.creeper))
).chain(
commands.execute.unless_entity(
target=selectors.entities(type=entities.ocelot, r=3))
).chain(
commands.execute.if_block(
position=(0, -1, 0),
block=blocks.grass)
).then(
commands.summon(
position=(0, 0, 0),
entity=entities.ocelot))
# (2) up-front as a group
commands.execute(
modifiers=(
commands.execute.at(
target=selectors.entities(type=entities.creeper)),
commands.execute.unless_entity(
target=selectors.entities(type=entities.ocelot, r=3)),
commands.execute.if_block(
position=(0, -1, 0),
block=blocks.grass)),
command=commands.summon(
position=(0, 0, 0),
entity=entities.ocelot))
# (3) recursively, as subcommands of one another
commands.execute.at(
target=selectors.entities(type=entities.creeper),
subcommand=commands.execute.unless_entity(
target=selectors.entities(type=entities.ocelot, r=3),
subcommand=commands.execute.if_block(
position=(0, -1, 0),
block=blocks.grass,
subcommand=commands.execute.then(
command=commands.summon(
position=(0, 0, 0),
entity=entities.ocelot)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment