Interface MachineBehavior

All Known Implementing Classes:
MultiblockMember, ProcessingBehavior

public interface MachineBehavior
Addon-provided logic of a machine (ARCHITECTURE.md ยง12). One instance per machine, created by the type's MachineBehavior.Factory. All methods run on the machine's owner thread.

Behaviors only touch the world through the MachineContext. State that must survive a restart goes into MachineDataKeys, storages and the process slot, never into fields.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    catchUp(@NotNull MachineContext context, long ticks)
    Called once after loading when the type's CatchUpPolicy catches up: ticks is the time spent unloaded, capped.
    default void
    onLoad(@NotNull MachineContext context)
    Called after the machine was placed or loaded, before it first ticks.
    default void
    onRemove(@NotNull MachineContext context)
    Called when the machine is removed from the world.
    default void
    onUnload(@NotNull MachineContext context)
    Called before the machine unloads (its chunk unloads or the server stops).
    default void
    onWake(@NotNull MachineContext context, @NotNull WakeReason reason)
    Called before the first tick after waking up.
    void
    tick(@NotNull MachineContext context)
    Called each tick while the machine is SchedulerState.ACTIVE.
  • Method Details

    • tick

      void tick(@NotNull @NotNull MachineContext context)
      Called each tick while the machine is SchedulerState.ACTIVE.
    • onWake

      default void onWake(@NotNull @NotNull MachineContext context, @NotNull @NotNull WakeReason reason)
      Called before the first tick after waking up.
    • onLoad

      default void onLoad(@NotNull @NotNull MachineContext context)
      Called after the machine was placed or loaded, before it first ticks.
    • onUnload

      default void onUnload(@NotNull @NotNull MachineContext context)
      Called before the machine unloads (its chunk unloads or the server stops).
    • catchUp

      default void catchUp(@NotNull @NotNull MachineContext context, long ticks)
      Called once after loading when the type's CatchUpPolicy catches up: ticks is the time spent unloaded, capped. Must be closed-form and touch only the machine's own storages (no neighbors, no networks, no world). The machine is woken afterwards.
    • onRemove

      default void onRemove(@NotNull @NotNull MachineContext context)
      Called when the machine is removed from the world.