ItemTransfer 5.46.0
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
public const HOPPER_COOLDOWN_TICKS = 8Game ticks a hopper waits after moving an item (Bedrock: 8, Minecraft Wiki "Hopper").
Methods
addOneToSlots()
public static function addOneToSlots(\pocketmine\inventory\Inventory $inventory, array $slots, \pocketmine\item\Item $item) : boolAdds one of the given item to the first of the given slots that can take it. Returns whether it was added.
canReceiveItems()
public static function canReceiveItems(\pocketmine\world\World $world, int $x, int $y, int $z) : boolReturns whether something at the given position can receive items (a container or a composter).
extractFromComposter()
public static function extractFromComposter(\pocketmine\block\Composter $composter) : ?\pocketmine\item\ItemTakes bone meal out of a ready composter. Returns null if the composter is not ready.
getContainerAt()
public static function getContainerAt(\pocketmine\world\World $world, int $x, int $y, int $z) : ?\pocketmine\block\tile\ContainerReturns the container at the given position that hoppers, droppers and crafters can move items into and out of, or null.
getEntityContainerAt()
public static function getEntityContainerAt(\pocketmine\world\World $world, int $x, int $y, int $z) : ?\pocketmine\entity\vehicle\ContainerMinecartReturns 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()
public static function getExtractSlots(\pocketmine\block\tile\Container $tile, \pocketmine\inventory\Inventory $inventory, int $face) : arrayReturns the slots items may be taken out of through the given face, in the order they should be tried.
getInsertSlots()
public static function getInsertSlots(\pocketmine\block\tile\Container $tile, \pocketmine\inventory\Inventory $inventory, int $face, \pocketmine\item\Item $item) : arrayReturns the slots the given item may be inserted into through the given face, in the order they should be tried.
insertOne()
public static function insertOne(\pocketmine\world\World $world, int $x, int $y, int $z, int $face, \pocketmine\item\Item $item) : boolTries 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()
public static function insertOneIntoEntity(\pocketmine\entity\vehicle\ContainerMinecart $minecart, \pocketmine\item\Item $item) : boolAdds one of the given item to the first slot of a container minecart that can take it. Returns whether it was added.
insertStack()
public static function insertStack(\pocketmine\world\World $world, int $x, int $y, int $z, int $face, \pocketmine\item\Item $stack) : \pocketmine\item\ItemInserts 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()
public static function isBlockTypeAt(\pocketmine\world\World $world, int $x, int $y, int $z, int $blockTypeId) : boolCheap check of the block type at a position, without building a Block object. False for unloaded chunks.
isEmpty()
public static function isEmpty(\pocketmine\inventory\Inventory $inventory) : boolnotifyContainerChanged()
public static function notifyContainerChanged(\pocketmine\world\World $world, int $x, int $y, int $z) : voidWakes 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()
public static function wakeHopperAt(\pocketmine\world\World $world, int $x, int $y, int $z) : void