Interface RedstoneBehaviour


public interface RedstoneBehaviour
The redstone side of a block type: whether it emits a signal, what a comparator reads out of it, and how it reacts when its surroundings change.
Since:
0.1.0
  • Method Details

    • isSignalSource

      default boolean isSignalSource(BlockData state)
      Returns true if the state emits a signal, which also makes redstone dust connect to it.
      Parameters:
      state - the state of the block
      Returns:
      true if the state emits a signal, which also makes redstone dust connect to it
      Since:
      0.1.0
    • signal

      default int signal(SignalGetter world, BlockPosition position, BlockData state, BlockFace direction)
      Gets the weak signal the block emits towards one of its neighbours.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      direction - the direction from the block reading the signal to this block
      Returns:
      the signal, from 0 to 15
      Since:
      0.1.0
    • directSignal

      default int directSignal(SignalGetter world, BlockPosition position, BlockData state, BlockFace direction)
      Gets the strong signal the block emits towards one of its neighbours: a conductor receiving it powers its own neighbours with it.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      direction - the direction from the block reading the signal to this block
      Returns:
      the signal, from 0 to 15
      Since:
      0.1.0
    • connectsToWire

      default boolean connectsToWire(SignalGetter world, BlockPosition position, BlockData state, @Nullable BlockFace direction)
      Tells whether redstone dust next to the block connects to it.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      direction - the direction from the dust to this block, or null when the dust is one block above or below, where only dust connects
      Returns:
      true to connect; by default, when the block is a signal source and the dust is beside it
      Since:
      0.1.0
    • hasAnalogOutput

      default boolean hasAnalogOutput(BlockData state)
      Returns true if a comparator can read a level out of the state.
      Parameters:
      state - the state of the block
      Returns:
      true if a comparator can read a level out of the state
      Since:
      0.1.0
    • analogOutput

      default int analogOutput(SignalGetter world, BlockPosition position, BlockData state, BlockFace direction)
      Gets the level a comparator reads out of the block, such as how full a container is.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      direction - the direction from the comparator to this block
      Returns:
      the level, from 0 to 15
      Since:
      0.1.0
    • onPlace

      default void onPlace(RedstoneWorld world, BlockPosition position, BlockData state, BlockData previous)
      Called when the state at position became state: the block was just placed, or only one of its properties changed, as when a repeater turns on. The block is in place.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the new state
      previous - the state it replaced, of another block type when the block was just placed
      Since:
      0.1.0
    • onRemoved

      default void onRemoved(RedstoneWorld world, BlockPosition position, BlockData state)
      Called once the block was replaced by another block type, to tell the blocks it powered: it is no longer in the world. BlockBehaviour.onRemove(World, BlockPosition, BlockData) ran before, while it still was. Like vanilla, a replacement made with RedstoneWorld.Update.SHAPES or RedstoneWorld.Update.QUIET does not call it.
      Parameters:
      world - the world of the block
      position - where the block was
      state - the state that was removed
      Since:
      0.1.0
    • neighborChanged

      default void neighborChanged(RedstoneWorld world, BlockPosition position, BlockData state, TypedKey<BlockType> source)
      Called when one of the six neighbours of the block changed: what a lamp, a door or redstone dust react to.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      source - the block type that caused the update
      Since:
      0.1.0
    • updateShape

      default BlockData updateShape(RedstoneWorld world, BlockPosition position, BlockData state, BlockFace direction, BlockData neighbor)
      Called when the block next to this one on one side changed, to let this one follow its shape: redstone dust reconnects, an observer fires, a lever whose support disappeared breaks.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      direction - the side of this block the changed neighbour is on
      neighbor - the new state of that neighbour
      Returns:
      the state the block should take: state to keep it, any kind of air to break it
      Since:
      0.1.0
    • updateIndirectNeighborShapes

      default void updateIndirectNeighborShapes(RedstoneWorld world, BlockPosition position, BlockData state)
      Called when the block was placed, changed or removed, to update the shape of blocks that are not its direct neighbours, such as redstone dust one block lower or higher beside it.
      Parameters:
      world - the world of the block
      position - where the block is, or was
      state - the state of the block, the removed one when it was removed
      Since:
      0.1.0
    • tick

      default void tick(RedstoneWorld world, BlockPosition position, BlockData state)
      Called when a tick scheduled for the block is due: a repeater switches, a button pops back out.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      Since:
      0.1.0
    • triggerEvent

      default boolean triggerEvent(RedstoneWorld world, BlockPosition position, BlockData state, int type, int data)
      Called when a block event queued for the block is due: a piston extends or retracts.
      Parameters:
      world - the world of the block
      position - where the block is
      state - the state of the block
      type - what the event is, as given when it was queued
      data - the value going with it, as given when it was queued
      Returns:
      true if the block acted on the event, which is then sent to the players seeing the block; false, the default, if it ignored it
      Since:
      0.1.0