Power providers Power providers can provide power to other blocks in two ways:

“Weak power” – every block adjacent to the power provider is powered. For example – in the picture below, when the lever is on, all adjacent lamps (south, north, west, east, up, down) will turn on. “Strong power” – when the power provider is attached to a suitable block, it causes that block to provide weak power to all of its neighbours. For example – the button provides strong power to the stone block, and the stone block provides weak power to the adjacent lamps.

Weak power - when activated, the lever provides weak power to the adjacent lamps (in this case north, south, east, west)





Strong power - when activated, the button provides strong power to the stone it's attached to. The stone then provides weak power to the adjacent lamps.

getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side)

Redstone block provides weak power to the lamp

getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side)

Button provides strong power to the stone. This will cause the stone to provide weak power to all of the stone's neighbours.

canProvidePower()

Optional methods that can help you tweak your block’s behaviour

canConnectRedstone(side)

shouldCheckWeakPower(IBlockAccess world, BlockPos pos, EnumFacing side)

If you return true: Forge checks whether this block is being strongly powered by any of its neighbours. If not, the power level is zero.

If you return false: Forge instead checks whether this block itself is generating weak power.

Power consumers

For non-direction blocks such as Redstone Lamp-

a. World.isBlockPowered(pos) for an on/off answer; or

b. World.getRedstonePowerFromNeighbors(pos) if they need to know the strength [0 – 15] For directional blocks such as Redstone Torch or redstone repeater-

a. World.isSidePowered(side) for an on/off answer; or

b. World.getRedstonePower(side) if they need to know the strength [0-15]

An event occurs which means the redstone power needs to be recalculated. In many cases, this is caused by a change in the power provider – for example the user pushes the BlockLever -> onBlockActivated(), or the user smashes the BlockLever -> breakBlock() or similar. The block method will typically then call world.notifyNeighborsOfStateChange(). All neighbouring consumers (such as the Redstone Lamp) will then call world.isBlockPowered(BlockPos) with their own blockpos to discover whether they are being powered, either weakly or strongly. This check usually happens in onBlockAdded, onNeighbourBlockChange, and updateTick The call to World.isBlockPowered for RedstoneLampBlock will then check its neighbours one by one (in this case- the unattached lever, and the stone):

a. Check if the neighbour is providing weak power (the unattached lever).

b. Check if the neighbour can be strongly powered (yes - the stone), and if so, check if the stone has any adjacent blocks which are strongly powering it (the button attached to the stone). The RedstoneLampBlock will then change its state/ perform some action as appropriate depending on whether it is being powered or not.

If the block needs to know the strength of the signal, it will use getRedstonePowerFromNeighbors() instead of isBlockPowered().

The glowstone can be powered by weak power from the lever, or alternatively the strong power from the button can make the stone emit weak power to the glowstone.

Comparators

The comparator senses the cauldron water level from two blocks away.

getWeakChanges()

The amount of power provided is from 0 (no power) to 15 (max power), using the following Block methods:For the example in the picture below:When this method is called for the redstone, it returns the weak power level (i.e. 15) it is providing to the adjacent lamp.EAST means that the redstone is to the EAST of the lamp.pos and state are the position and state of the redstone, not the adjacent lamp.For the example in the picture below:When this method is called for the button, it returns the strong power level (i.e. 15) it is providing to the adjacent stone block.EAST means that the button is to the EAST of the stonepos and state are the position and state of the button, not the adjacent stone.– return true!- this side is a power output and redstone wire will connect to it. (Note- the Javadoc for the method says "input or output" but actually it's strictly for output only).This method is called when Forge wants to know the power level of this block Actually it is named backwards! A block which can be strongly powered (eg by an attached lever or button) should return true here. This lets you override the vanilla assumption that a block can be strongly powered if (and only if) it isNormalCube().A power consumer is a block which reacts to nearby power providers. The propagation of power is by “pull”, not push – i.e. The consumer is responsible for requesting information from its neighbouring providers, not the other way around. It usually does this in one of two ways-The typical sequence is as follows, with example picture below.Comparators function slightly differently from other redstone. The input to a comparator might be from a block that is two positions away with an isNormalCube() in between – for example the comparator senses the level of water in the cauldron, with a stone block inbetween.To create your own comparator (ComparatorBlock is the only vanilla example), you should implement- return true. This ensures that your comparator will be informed of a change two blocks away, instead of only for adjacent blocks.Blocks which can be used as the input for a redstone comparator (eg CauldronBlock) should implement the following methods·