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 Summary
Modifier and TypeMethodDescriptiondefault intanalogOutput(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.default booleanconnectsToWire(SignalGetter world, BlockPosition position, BlockData state, @Nullable BlockFace direction) Tells whether redstone dust next to the block connects to it.default intdirectSignal(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.default booleanhasAnalogOutput(BlockData state) Returnstrueif a comparator can read a level out of the state.default booleanisSignalSource(BlockData state) Returnstrueif the state emits a signal, which also makes redstone dust connect to it.default voidneighborChanged(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.default voidonPlace(RedstoneWorld world, BlockPosition position, BlockData state, BlockData previous) Called when the state atpositionbecamestate: the block was just placed, or only one of its properties changed, as when a repeater turns on.default voidonRemoved(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.default intsignal(SignalGetter world, BlockPosition position, BlockData state, BlockFace direction) Gets the weak signal the block emits towards one of its neighbours.default voidtick(RedstoneWorld world, BlockPosition position, BlockData state) Called when a tick scheduled for the block is due: a repeater switches, a button pops back out.default booleantriggerEvent(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.default voidupdateIndirectNeighborShapes(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.default BlockDataupdateShape(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.
-
Method Details
-
isSignalSource
Returnstrueif the state emits a signal, which also makes redstone dust connect to it.- Parameters:
state- the state of the block- Returns:
trueif 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 blockposition- where the block isstate- the state of the blockdirection- the direction from the block reading the signal to this block- Returns:
- the signal, from
0to15 - 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 blockposition- where the block isstate- the state of the blockdirection- the direction from the block reading the signal to this block- Returns:
- the signal, from
0to15 - 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 blockposition- where the block isstate- the state of the blockdirection- the direction from the dust to this block, ornullwhen the dust is one block above or below, where only dust connects- Returns:
trueto connect; by default, when the block is a signal source and the dust is beside it- Since:
- 0.1.0
-
hasAnalogOutput
Returnstrueif a comparator can read a level out of the state.- Parameters:
state- the state of the block- Returns:
trueif 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 blockposition- where the block isstate- the state of the blockdirection- the direction from the comparator to this block- Returns:
- the level, from
0to15 - Since:
- 0.1.0
-
onPlace
default void onPlace(RedstoneWorld world, BlockPosition position, BlockData state, BlockData previous) Called when the state atpositionbecamestate: 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 blockposition- where the block isstate- the new stateprevious- the state it replaced, of another block type when the block was just placed- Since:
- 0.1.0
-
onRemoved
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 withRedstoneWorld.Update.SHAPESorRedstoneWorld.Update.QUIETdoes not call it.- Parameters:
world- the world of the blockposition- where the block wasstate- 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 blockposition- where the block isstate- the state of the blocksource- 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 blockposition- where the block isstate- the state of the blockdirection- the side of this block the changed neighbour is onneighbor- the new state of that neighbour- Returns:
- the state the block should take:
stateto 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 blockposition- where the block is, or wasstate- the state of the block, the removed one when it was removed- Since:
- 0.1.0
-
tick
Called when a tick scheduled for the block is due: a repeater switches, a button pops back out.- Parameters:
world- the world of the blockposition- where the block isstate- 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 blockposition- where the block isstate- the state of the blocktype- what the event is, as given when it was queueddata- the value going with it, as given when it was queued- Returns:
trueif 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
-