Skip to content

RedstoneEngine 5.46.0 ​

final class · pocketmine\world\redstone\RedstoneEngine · source

Per-world redstone power engine.

Power model: every block may emit weak and strong power out of each of its faces (see \pocketmine\block\Block::getWeakPower() and \pocketmine\block\Block::getStrongPower()). A redstone conductor (a full solid block) which receives strong power gives that power to all of its neighbours.

Components react to power changes from \pocketmine\block\Block::onNearbyBlockChange(); delays (repeaters, torches, comparators) use the world's scheduled block updates.

Redstone wire is solved per network: wires only mark themselves dirty when a neighbour changes, and the engine recomputes each dirty network once after the world's neighbour updates have been processed, so a change never recurses wire by wire. The number of wire blocks recomputed per tick is capped; extra work waits for the next tick.

Constants ​

MAX_FLUSH_ROUNDS_PER_TICK ​

php
public const MAX_FLUSH_ROUNDS_PER_TICK = 16

Maximum number of wire flush rounds (wire solve + resulting neighbour updates) per world tick.

MAX_WIRE_NETWORK_SIZE ​

php
public const MAX_WIRE_NETWORK_SIZE = 65536

Networks bigger than this are truncated to protect the server from absurd circuits.

RAIL_POWER_RANGE ​

php
public const RAIL_POWER_RANGE = 8

Number of rails a powered or activator rail passes power on to.

REDSTONE_TICK ​

php
public const REDSTONE_TICK = 2

Number of game ticks in one redstone tick.

TORCH_BURNOUT_COOLDOWN_TICKS ​

php
public const TORCH_BURNOUT_COOLDOWN_TICKS = 160

TORCH_BURNOUT_TOGGLES ​

php
public const TORCH_BURNOUT_TOGGLES = 8

TORCH_BURNOUT_WINDOW_TICKS ​

php
public const TORCH_BURNOUT_WINDOW_TICKS = 60

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\World $world, int $maxWireUpdatesPerTick = 20000)

clearTorchState() ​

php
public function clearTorchState(int $x, int $y, int $z) : void

consumeObserverRetrigger() ​

php
public function consumeObserverRetrigger(int $x, int $y, int $z) : bool

Returns whether the observer at x/y/z must pulse again, and forgets it.

getCurrentTick() ​

php
public function getCurrentTick() : int

getMaxWireUpdatesPerTick() ​

php
public function getMaxWireUpdatesPerTick() : int

getPower() ​

php
public function getPower(int $x, int $y, int $z) : int

Returns the highest power received by the block at x/y/z from any side.

getPowerFrom() ​

php
public function getPowerFrom(int $x, int $y, int $z, int $face, bool $ignoreWires = false) : int

Returns the power that reaches the block at x/y/z from its neighbour on the given face: the neighbour's weak power towards this block, or, if the neighbour is a conductor, the strong power the neighbour receives.

Only blocks which declare themselves as power sources (\pocketmine\block\Block::isRedstoneSource()) are asked for their power.

getRememberedPowered() ​

php
public function getRememberedPowered(int $x, int $y, int $z) : bool

getStatistics() ​

php
public function getStatistics() : array

getStrongPowerInto() ​

php
public function getStrongPowerInto(int $x, int $y, int $z, bool $ignoreWires = false) : int

Returns the highest strong power delivered into the block at x/y/z by any of its neighbours.

getTransientPower() ​

php
public function getTransientPower(int $x, int $y, int $z) : int

getWirePoweredFaces() ​

php
public function getWirePoweredFaces(int $x, int $y, int $z) : int

Returns a bitmask of the horizontal faces (1 << face) that the wire at x/y/z powers. A wire with no connections (a dot) powers all four sides; a wire with a single connection powers both ends of its line.

getWorld() ​

php
public function getWorld() : \pocketmine\world\World

hasDirtyWires() ​

php
public function hasDirtyWires() : bool

isConductorAt() ​

php
public function isConductorAt(int $x, int $y, int $z) : bool

Returns whether the block at the given position is a redstone conductor.

isPowered() ​

php
public function isPowered(int $x, int $y, int $z) : bool

Returns whether the block at x/y/z receives any power from any side.

isTorchBurnedOut() ​

php
public function isTorchBurnedOut(int $x, int $y, int $z) : bool

Returns whether the torch at x/y/z is burned out. Once the cooldown is over the burnout is forgotten, and the torch relights on its next update.

isWireAt() ​

php
public function isWireAt(int $x, int $y, int $z) : bool

Returns whether the block at the given position is redstone wire.

markWireDirty() ​

php
public function markWireDirty(int $x, int $y, int $z) : void

Marks the wire at x/y/z as needing its network to be recalculated.

recordTorchTurnOff() ​

php
public function recordTorchTurnOff(int $x, int $y, int $z) : bool

Records that the torch at x/y/z was turned off by its input. Returns true if the torch toggled too often and must burn out.

resetStatistics() ​

php
public function resetStatistics() : void

setMaxWireUpdatesPerTick() ​

php
public function setMaxWireUpdatesPerTick(int $max) : void

setObserverRetrigger() ​

php
public function setObserverRetrigger(int $x, int $y, int $z) : void

Remembers that the observer at x/y/z saw a change while it was already pulsing, so that it pulses again.

setRememberedPowered() ​

php
public function setRememberedPowered(int $x, int $y, int $z, bool $powered) : void

setTransientPower() ​

php
public function setTransientPower(int $x, int $y, int $z, int $power) : void

updateAround() ​

php
public function updateAround(int $x, int $y, int $z) : void

Queues neighbour updates for the block at x/y/z and its six neighbours. Used by components whose output strongly powers a block, so that the components around that block notice the change.

updateAroundSide() ​

php
public function updateAroundSide(\pocketmine\math\Vector3 $pos, int $face) : void

Same as RedstoneEngine::updateAround(), for the block on the given side of the given position.

updateComparatorsReading() ​

php
public function updateComparatorsReading(int $x, int $y, int $z) : void

Queues neighbour updates for the comparators that read the block at x/y/z, directly or through a conductor.

wireConnects() ​

php
public function wireConnects(int $x, int $y, int $z, int $face, ?bool $aboveIsConductor = null) : bool

Returns whether wire at x/y/z connects through the given horizontal face (to another wire, stepping up or down, or to a power source which accepts wire connections).

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.