Bundle 5.46.0
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
public const BUNDLE_WEIGHT = 4Weight of a bundle stored inside another bundle, not counting its contents.
MAX_SLOTS
public const MAX_SLOTS = 64MAX_WEIGHT
public const MAX_WEIGHT = 64TAG_BUNDLE_ID
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
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()
public function __clone()addItem()
public function addItem(\pocketmine\item\Item $item) : intInserts 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()
public static function canBeStored(\pocketmine\item\Item $item) : boolReturns whether the item may be stored in a bundle at all (vanilla bans shulker boxes).
deserializeCompoundTag() protected
protected function deserializeCompoundTag(\pocketmine\nbt\tag\CompoundTag $tag) : voidgetContents()
public function getContents() : arrayReturns the stored items, from the oldest to the most recently added stack.
getContentsWeight()
public function getContentsWeight() : intReturns the total weight of the stored items (0-64 for a bundle filled through normal gameplay).
getFullness()
public function getFullness() : floatReturns how full the bundle is, between 0 and 1. This is what the client shows as the fullness bar.
getItemWeight()
public static function getItemWeight(\pocketmine\item\Item $item) : intReturns the weight of one item of the given type inside a bundle.
getMaxAddableCount()
public function getMaxAddableCount(\pocketmine\item\Item $item) : intReturns how many items of the given stack fit in this bundle.
getMaxStackSize()
public function getMaxStackSize() : intgetStackWeight()
public static function getStackWeight(\pocketmine\item\Item $item) : intReturns the weight of the whole stack inside a bundle.
isEmpty()
public function isEmpty() : boolonClickAir()
public function onClickAir(\pocketmine\player\Player $player, \pocketmine\math\Vector3 $directionVector, array &$returnedItems) : \pocketmine\item\ItemUseResultremoveNewest()
public function removeNewest() : ?\pocketmine\item\ItemRemoves and returns the most recently added stack, or null if the bundle is empty.
serializeCompoundTag() protected
protected function serializeCompoundTag(\pocketmine\nbt\tag\CompoundTag $tag) : voidsetContents()
public function setContents(array $contents) : selfReplaces the stored items. Empty items are skipped. The weight limit is not enforced here; use Bundle::getMaxAddableCount() or Bundle::addItem() for player-driven insertions.
