Interface RedstoneWorld
- All Superinterfaces:
BlockGetter, SignalGetter
SignalGetter, plus changing
blocks, telling their neighbours, and scheduling ticks.
Neighbour updates run in the order vanilla runs them, one chain at a time: an update caused while another one is running is queued and runs right after it, rather than nested inside it. Updates reaching a block of another region are handed over to the thread of that region. A world may be configured to drive its redstone dust another way, such as with Alternate Current, which updates the blocks around a whole network of dust in the order power flows through it.
- Since:
- 0.1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumHow far a block change made throughsetBlock(BlockPosition, BlockData, Update)spreads. -
Method Summary
Modifier and TypeMethodDescriptionvoidanalogOutputChanged(BlockPosition position) Tells the comparators reading a block, next to it or behind a conductor, that its analog output changed.voidblockChanged(BlockPosition position, BlockData previous, BlockData current) Tells the engine a block was replaced by something else thansetBlock(BlockPosition, BlockData, RedstoneWorld.Update), so that the redstone around it reacts as ifsetBlockhad been called withRedstoneWorld.Update.NEIGHBORS.voidblockEvent(BlockPosition position, TypedKey<BlockType> block, int type, int data) Queues a block event: a call toRedstoneBehaviour.triggerEvent(RedstoneWorld, BlockPosition, BlockData, int, int), later in the same game tick.booleandestroyBlock(BlockPosition position) Removes a block that can no longer stand, such as redstone dust whose support was removed, telling its neighbours.booleanhasScheduledTick(BlockPosition position, TypedKey<BlockType> block) Returnstrueif a tick is pending for a block, not counting the ticks running this game tick.voidneighborChanged(BlockPosition position, TypedKey<BlockType> source) Tells one block that one of its neighbours changed.voidneighborShapeChanged(BlockPosition position, BlockFace direction) Tells one block that the block next to it on one side changed shape, so that it can follow: redstone dust reconnecting, an observer firing.default voidscheduleTick(BlockPosition position, TypedKey<BlockType> block, int delay) Schedules a tick atTickPriority.NORMALpriority.voidscheduleTick(BlockPosition position, TypedKey<BlockType> block, int delay, TickPriority priority) Schedules a call toRedstoneBehaviour.tick(RedstoneWorld, BlockPosition, BlockData), oncedelaygame ticks have elapsed.booleansetBlock(BlockPosition position, BlockData data, RedstoneWorld.Update update) Replaces a block, and lets the redstone around it react asupdatesays.voidupdateNeighbors(BlockPosition position, TypedKey<BlockType> source) Tells the six neighbours of a block that something changed there, in vanilla order: west, east, down, up, north, south.voidupdateNeighborsExcept(BlockPosition position, TypedKey<BlockType> source, BlockFace skipped) Tells the neighbours of a block that something changed there, except the one on one side.booleanwillTickThisTick(BlockPosition position, TypedKey<BlockType> block) Returnstrueif a tick of a block is due on the current game tick and has not run yet.Methods inherited from interface BlockGetter
blockAtMethods inherited from interface SignalGetter
analogOutput, bestNeighborSignal, controlInputSignal, directSignal, directSignalTo, hasAnalogOutput, hasNeighborSignal, hasSignal, isConductor, isFaceSturdy, signal, world
-
Method Details
-
setBlock
Replaces a block, and lets the redstone around it react asupdatesays. Players see the change and the light follows in every case.Like any block write, it must be called on the thread of the region owning
position.- Parameters:
position- where the block isdata- the new stateupdate- how far the change spreads- Returns:
falseif the block already held that state, or its chunk is not loaded- Throws:
IllegalStateException- if the calling thread does not ownposition- Since:
- 0.1.0
-
destroyBlock
Removes a block that can no longer stand, such as redstone dust whose support was removed, telling its neighbours. A waterlogged block leaves its water behind.- Parameters:
position- where the block is- Returns:
falseif there was nothing to remove, or its chunk is not loaded- Throws:
IllegalStateException- if the calling thread does not ownposition- Since:
- 0.1.0
-
updateNeighbors
Tells the six neighbours of a block that something changed there, in vanilla order: west, east, down, up, north, south.- Parameters:
position- the block that changedsource- the block type that caused the update- Since:
- 0.1.0
-
updateNeighborsExcept
Tells the neighbours of a block that something changed there, except the one on one side.- Parameters:
position- the block that changedsource- the block type that caused the updateskipped- the side not to tell, usually where the change comes from- Since:
- 0.1.0
-
neighborChanged
Tells one block that one of its neighbours changed.- Parameters:
position- the block to tellsource- the block type that caused the update- Since:
- 0.1.0
- See Also:
-
neighborShapeChanged
Tells one block that the block next to it on one side changed shape, so that it can follow: redstone dust reconnecting, an observer firing.- Parameters:
position- the block to telldirection- the side ofpositionthe changed block is on- Since:
- 0.1.0
- See Also:
-
analogOutputChanged
Tells the comparators reading a block, next to it or behind a conductor, that its analog output changed. Call it when what a comparator reads changes without the block state changing, such as the contents of a container.- Parameters:
position- the block whose analog output changed- Since:
- 0.1.0
-
scheduleTick
void scheduleTick(BlockPosition position, TypedKey<BlockType> block, int delay, TickPriority priority) Schedules a call toRedstoneBehaviour.tick(RedstoneWorld, BlockPosition, BlockData), oncedelaygame ticks have elapsed. The tick only runs if the block is still of typeblockby then.A block holds at most one pending tick per block type: scheduling another one before the first ran does nothing.
- Parameters:
position- the block to tickblock- the block type the tick is fordelay- the number of game ticks to wait,1for the next tickpriority- the order among the ticks due on the same game tick- Since:
- 0.1.0
-
scheduleTick
Schedules a tick atTickPriority.NORMALpriority.- Parameters:
position- the block to tickblock- the block type the tick is fordelay- the number of game ticks to wait,1for the next tick- Since:
- 0.1.0
- See Also:
-
hasScheduledTick
Returnstrueif a tick is pending for a block, not counting the ticks running this game tick.Only reliable on the thread of the region owning
position.- Parameters:
position- the blockblock- the block type the tick is for- Returns:
trueif a tick is pending for a block, not counting the ticks running this game tick- Since:
- 0.1.0
-
willTickThisTick
Returnstrueif a tick of a block is due on the current game tick and has not run yet.Only reliable on the thread of the region owning
position.- Parameters:
position- the blockblock- the block type the tick is for- Returns:
trueif a tick of a block is due on the current game tick and has not run yet- Since:
- 0.1.0
-
blockEvent
Queues a block event: a call toRedstoneBehaviour.triggerEvent(RedstoneWorld, BlockPosition, BlockData, int, int), later in the same game tick. What a piston moves on, rather than on the update that powered it.Block events run once the scheduled ticks due on that game tick have run, in the order they were queued. One queued while block events run still runs on that game tick, after those already queued. The event only runs if the block is still of type
blockby then, and queuing an event equal to one that is waiting does nothing.The players seeing the block are told of every event its behaviour accepts, before they are told of the blocks that event changed: their client plays the event out from the world as it was, the way a piston is drawn moving.
- Parameters:
position- the block the event is forblock- the block type the event is fortype- what the event is, from0to255, as the block type defines itdata- a value going with it, from0to255- Throws:
IllegalArgumentException- iftypeordatais out of range- Since:
- 0.1.0
-
blockChanged
Tells the engine a block was replaced by something else thansetBlock(BlockPosition, BlockData, RedstoneWorld.Update), so that the redstone around it reacts as ifsetBlockhad been called withRedstoneWorld.Update.NEIGHBORS.The server calls it for every block placed, broken or blown up; a plugin only needs it when it writes blocks by other means.
- Parameters:
position- where the block isprevious- the state that was replacedcurrent- the state now in place- Since:
- 0.1.0
-