Skip to content

ItemTransfer 5.46.0 ​

final class · pocketmine\block\utils\ItemTransfer · source

Moves items in and out of containers the way hoppers, droppers and crafters do: one item at a time, through a given face of the container, following the slot rules of each container type.

Faces are the face of the container the item passes through: an item pushed down into a furnace enters through Facing::UP, a hopper under a chest pulls through Facing::DOWN.

Constants ​

HOPPER_COOLDOWN_TICKS ​

php
public const HOPPER_COOLDOWN_TICKS = 8

Game ticks a hopper waits after moving an item (Bedrock: 8, Minecraft Wiki "Hopper").

Methods ​

addOneToSlots() ​

php
public static function addOneToSlots(\pocketmine\inventory\Inventory $inventory, array $slots, \pocketmine\item\Item $item) : bool

Adds one of the given item to the first of the given slots that can take it. Returns whether it was added.

canReceiveItems() ​

php
public static function canReceiveItems(\pocketmine\world\World $world, int $x, int $y, int $z) : bool

Returns whether something at the given position can receive items (a container or a composter).

extractFromComposter() ​

php
public static function extractFromComposter(\pocketmine\block\Composter $composter) : ?\pocketmine\item\Item

Takes bone meal out of a ready composter. Returns null if the composter is not ready.

getContainerAt() ​

php
public static function getContainerAt(\pocketmine\world\World $world, int $x, int $y, int $z) : ?\pocketmine\block\tile\Container

Returns the container at the given position that hoppers, droppers and crafters can move items into and out of, or null.

getEntityContainerAt() ​

php
public static function getEntityContainerAt(\pocketmine\world\World $world, int $x, int $y, int $z) : ?\pocketmine\entity\vehicle\ContainerMinecart

Returns a chest or hopper minecart in the block space at the given position, or null. Hoppers move items into and out of container minecarts there when there is no container block (vanilla picks one of them at random).

getExtractSlots() ​

php
public static function getExtractSlots(\pocketmine\block\tile\Container $tile, \pocketmine\inventory\Inventory $inventory, int $face) : array

Returns the slots items may be taken out of through the given face, in the order they should be tried.

getInsertSlots() ​

php
public static function getInsertSlots(\pocketmine\block\tile\Container $tile, \pocketmine\inventory\Inventory $inventory, int $face, \pocketmine\item\Item $item) : array

Returns the slots the given item may be inserted into through the given face, in the order they should be tried.

insertOne() ​

php
public static function insertOne(\pocketmine\world\World $world, int $x, int $y, int $z, int $face, \pocketmine\item\Item $item) : bool

Tries to insert one of the given item into the container (or composter) at the given position, through the given face of it. Returns whether the item was taken.

insertOneIntoEntity() ​

php
public static function insertOneIntoEntity(\pocketmine\entity\vehicle\ContainerMinecart $minecart, \pocketmine\item\Item $item) : bool

Adds one of the given item to the first slot of a container minecart that can take it. Returns whether it was added.

insertStack() ​

php
public static function insertStack(\pocketmine\world\World $world, int $x, int $y, int $z, int $face, \pocketmine\item\Item $stack) : \pocketmine\item\Item

Inserts as much of the given stack as possible into the container at the given position, one item at a time so the slot rules are respected. Returns the items that did not fit.

isBlockTypeAt() ​

php
public static function isBlockTypeAt(\pocketmine\world\World $world, int $x, int $y, int $z, int $blockTypeId) : bool

Cheap check of the block type at a position, without building a Block object. False for unloaded chunks.

isEmpty() ​

php
public static function isEmpty(\pocketmine\inventory\Inventory $inventory) : bool

notifyContainerChanged() ​

php
public static function notifyContainerChanged(\pocketmine\world\World $world, int $x, int $y, int $z) : void

Wakes up the hoppers which may want to move items because the contents of the container at x/y/z changed: the container itself if it is a hopper, a hopper below it (pulling) and hoppers pointing into it (pushing).

wakeHopperAt() ​

php
public static function wakeHopperAt(\pocketmine\world\World $world, int $x, int $y, int $z) : void

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