BundleContentsHelper
com.jsmacrosce.jsmacros.client.api.helper.inventory.BundleContentsHelper
Reads the contents, fullness, and current selection of a bundle.
js
const bundle = Player.getPlayer()?.getMainHand().getComponents().getBundleContents();
if (bundle != null) {
Chat.log(`Bundle is ${Math.round(bundle.getFullness() * 100)}% full`);
for (const stack of bundle.getItems()) Chat.log(stack.getItemId());
}Methods
getFullness
getFullness(): double#Returns how much capacity the contents use. Item stack limits and nested bundles affect this value. This throws if Minecraft cannot calculate the weight of invalid contents.
Returns: the fraction of capacity used, with 0 for empty and 1 for full; overfilled bundles can exceed 1
getItems
getItems(): List<ItemStackHelper>#Returns copies of the bundle's stacks in the order stored by Minecraft.
Returns: the stored stacks
getSelectedIndex
getSelectedIndex(): int#Returns the selection stored on this bundle, used when taking an item out.
Returns: the zero-based index into getItems(), or -1 if no item is selected