Skip to content

Bundle 5.46.0 ​

class · pocketmine\item\Bundle · source

Extends Item

A bundle stores a mixed stack of items, limited by weight rather than by slot count.

Bedrock rules (BedrockData item components of minecraft:bundle: minecraft:storage_item max_slots=64, minecraft:storage_weight_limit max_weight_limit=64, minecraft:storage_weight_modifier weight_in_storage_item=4, shulker boxes banned): each item weighs 64 / its max stack size, a bundle inside a bundle weighs 4 plus the weight of its own contents, and the total may not exceed 64.

The contents are ordered from the oldest (index 0) to the most recently added stack (last index), which is also the order of the slots of the client's dynamic container for the bundle.

Constants ​

BUNDLE_WEIGHT ​

php
public const BUNDLE_WEIGHT = 4

Weight of a bundle stored inside another bundle, not counting its contents.

MAX_SLOTS ​

php
public const MAX_SLOTS = 64

MAX_WEIGHT ​

php
public const MAX_WEIGHT = 64

TAG_BUNDLE_ID ​

php
public const TAG_BUNDLE_ID = "bundle_id"

ID of the client-side dynamic container showing the contents. Only meaningful on the network; it is assigned by the network session and stripped from saved data.

TAG_CONTENTS ​

php
public const TAG_CONTENTS = "storage_item_component_content"

List of the stored items, each with its Slot byte, as written by Bedrock and PowerNukkitX.

Methods ​

__clone() ​

php
public function __clone()

addItem() ​

php
public function addItem(\pocketmine\item\Item $item) : int

Inserts as many items of the stack as fit. A stack of the same item that still has room absorbs them and becomes the most recently added stack, as in vanilla; any remainder becomes a new stack on top.

canBeStored() ​

php
public static function canBeStored(\pocketmine\item\Item $item) : bool

Returns whether the item may be stored in a bundle at all (vanilla bans shulker boxes).

deserializeCompoundTag() protected ​

php
protected function deserializeCompoundTag(\pocketmine\nbt\tag\CompoundTag $tag) : void

getContents() ​

php
public function getContents() : array

Returns the stored items, from the oldest to the most recently added stack.

getContentsWeight() ​

php
public function getContentsWeight() : int

Returns the total weight of the stored items (0-64 for a bundle filled through normal gameplay).

getFullness() ​

php
public function getFullness() : float

Returns how full the bundle is, between 0 and 1. This is what the client shows as the fullness bar.

getItemWeight() ​

php
public static function getItemWeight(\pocketmine\item\Item $item) : int

Returns the weight of one item of the given type inside a bundle.

getMaxAddableCount() ​

php
public function getMaxAddableCount(\pocketmine\item\Item $item) : int

Returns how many items of the given stack fit in this bundle.

getMaxStackSize() ​

php
public function getMaxStackSize() : int

getStackWeight() ​

php
public static function getStackWeight(\pocketmine\item\Item $item) : int

Returns the weight of the whole stack inside a bundle.

isEmpty() ​

php
public function isEmpty() : bool

onClickAir() ​

php
public function onClickAir(\pocketmine\player\Player $player, \pocketmine\math\Vector3 $directionVector, array &$returnedItems) : \pocketmine\item\ItemUseResult

removeNewest() ​

php
public function removeNewest() : ?\pocketmine\item\Item

Removes and returns the most recently added stack, or null if the bundle is empty.

serializeCompoundTag() protected ​

php
protected function serializeCompoundTag(\pocketmine\nbt\tag\CompoundTag $tag) : void

setContents() ​

php
public function setContents(array $contents) : self

Replaces the stored items. Empty items are skipped. The weight limit is not enforced here; use Bundle::getMaxAddableCount() or Bundle::addItem() for player-driven insertions.

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