Skip to content

Instantly share code, notes, and snippets.

@Arcensoth
Last active February 26, 2018 23:24
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/1df40ab7daf74cd7dfb64f7715dc42e5 to your computer and use it in GitHub Desktop.
Save Arcensoth/1df40ab7daf74cd7dfb64f7715dc42e5 to your computer and use it in GitHub Desktop.

EntityTickFunction: A function defined via entity data that runs once per tick using the entity as the executor

The title says it all. Similar in ways to the old gameLoopFunction but for individual entities.

Here's some inspiration:

  • Conveniently use @s in the EntityTickFunction to refer to the host entity, bypassing the overhead of running (relatively) expensive @e selectors at 20Hz. Great for systems like custom AI that need to be as responsive as possible while remaining efficient.
  • Trivially - and slightly more efficiently - run one-time initialization functions on newly-spawned mobs by summoning them with an EntityTickFunction that replaces/removes itself once complete.
  • Automatically run multiple (non-nested) functions on an entity every tick by specifying EntityTickFunction to be one of those fancy new function tags.

My Minecraft engine knowledge is limited, but it might even make sense to run this function parallel to the entity's actual game simulation tick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment