Interface SchedulerSource

All Known Subinterfaces:
Ageable, Angerable, Animal, Bat, CaveSpider, Chicken, Chunk, Cow, Creeper, CubeMob, Damageable, Drowned, Enderman, Endermite, Entity, ExperienceOrb, Frostbite, Husk, ItemEntity, LivingEntity, MagmaCube, Mob, Mooshroom, Pig, Player, Shearable, Sheep, Silverfish, Slime, Spider, SulfurCube, Zombie

public interface SchedulerSource

Something bound to a region of the world, on whose thread tasks can be scheduled: an entity or a chunk.

The tasks of an entity run in the order they were scheduled, on the region holding the entity when they run, following it across regions.

A task that was scheduled either runs or is retired, never both: it is retired when its source is removed, or its region can no longer run it, before the task's turn. The retired callback may run on any thread.

Since:
0.1.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Schedules a task to run as soon as possible on the region thread owning this source.
    boolean
    execute(Runnable task, Runnable retired)
    Schedules a task to run as soon as possible on the region thread owning this source.
    default boolean
    executeDelayed(Runnable task, long delayTicks)
    Schedules a task to run on the region thread owning this source, after a delay.
    boolean
    executeDelayed(Runnable task, Runnable retired, long delayTicks)
    Schedules a task to run on the region thread owning this source, after a delay.
    boolean
    Checks whether the calling thread may safely touch this source.
  • Method Details

    • execute

      default boolean execute(Runnable task)
      Schedules a task to run as soon as possible on the region thread owning this source.
      Parameters:
      task - the task to run
      Returns:
      false if the source is removed and the task was not scheduled
      Since:
      0.1.0
    • execute

      boolean execute(Runnable task, Runnable retired)
      Schedules a task to run as soon as possible on the region thread owning this source.
      Parameters:
      task - the task to run
      retired - called instead of the task if it can no longer run
      Returns:
      false if the source is removed: neither task nor retired will run
      Since:
      0.1.0
    • executeDelayed

      default boolean executeDelayed(Runnable task, long delayTicks)
      Schedules a task to run on the region thread owning this source, after a delay.
      Parameters:
      task - the task to run
      delayTicks - the minimum number of ticks to wait before running the task
      Returns:
      false if the source is removed or the task could not be scheduled
      Since:
      0.1.0
    • executeDelayed

      boolean executeDelayed(Runnable task, Runnable retired, long delayTicks)
      Schedules a task to run on the region thread owning this source, after a delay.
      Parameters:
      task - the task to run
      retired - called instead of the task if it can no longer run
      delayTicks - the minimum number of ticks to wait before running the task
      Returns:
      false if the source is removed or the task could not be scheduled: neither task nor retired will run
      Since:
      0.1.0
    • isOwnedByCurrentThread

      boolean isOwnedByCurrentThread()
      Checks whether the calling thread may safely touch this source.
      Returns:
      true if the calling thread is the region thread owning this source
      Since:
      0.1.0