Skip to content

Dispenser 5.46.0 ​

class · pocketmine\block\Dispenser · source

Extends Opaque
Implements AnyFacing

Dispenser: on a rising redstone edge, waits Dispenser::DISPENSE_DELAY_TICKS game ticks, then uses a random non-empty slot (Minecraft Wiki "Dispenser"). What happens to the item is decided by DispenseBehaviorRegistry.

Constants ​

DISPENSE_DELAY_TICKS ​

php
public const DISPENSE_DELAY_TICKS = 4

2 redstone ticks

Properties ​

$triggered protected ​

php
protected bool $triggered

Methods ​

describeBlockOnlyState() protected ​

php
protected function describeBlockOnlyState(\pocketmine\data\runtime\RuntimeDataDescriber $w) : void

dispense() ​

php
public function dispense() : void

Dispenses one item from a random non-empty slot. The slot is chosen now, not when the dispenser was powered.

dispenseItem() protected ​

php
protected function dispenseItem(\pocketmine\block\dispenser\DispenseContext $context, \pocketmine\item\Item $stack) : ?\pocketmine\item\Item

Returns the new contents of the slot, or null if nothing happened.

getPlacementFacing() ​

php
public static function getPlacementFacing(\pocketmine\math\Vector3 $blockPos, \pocketmine\player\Player $player) : int

Facing of a dispenser-like block placed by the given player: towards the player, or up/down when the player stands close and above/below it (same rule as barrels).

isTriggered() ​

php
public function isTriggered() : bool

Whether the dispenser is powered (Bedrock "triggered_bit"). Only a rising edge makes it dispense.

onInteract() ​

php
public function onInteract(\pocketmine\item\Item $item, int $face, \pocketmine\math\Vector3 $clickVector, ?\pocketmine\player\Player $player = null, array &$returnedItems = []) : bool

onNearbyBlockChange() ​

php
public function onNearbyBlockChange() : void

onScheduledUpdate() ​

php
public function onScheduledUpdate() : void

place() ​

php
public function place(\pocketmine\world\BlockTransaction $tx, \pocketmine\item\Item $item, \pocketmine\block\Block $blockReplace, \pocketmine\block\Block $blockClicked, int $face, \pocketmine\math\Vector3 $clickVector, ?\pocketmine\player\Player $player = null) : bool

setTriggered() ​

php
public function setTriggered(bool $triggered) : self

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