Bedrock Energistics Core
    Preparing search index...

    Class MachineItemStackBeta

    Represents an item stack that may be stored in a machine UI item slot.

    Carries an item's type, amount, name tag, damage, lore and enchantments, and nothing else. An item holding more than that does not survive a round trip through one: a shulker box with items in it becomes an empty shulker box.

    Machine item slots store their contents this way, so restrict them with UiItemSlotElementDefinition.allowedItems, or use a persistent entity's container instead if a slot has to accept any item.

    Index
    damage: number
    enchantments: Enchantment[]
    lore: string[]
    nameTag?: string
    typeId: string

    The ID of the item type this stack holds.

    • get amount(): number
      Beta

      The number of items in this stack.

      Returns number

      Always a positive integer, as it is for Minecraft's ItemStack.amount. An empty machine item slot is represented by having no MachineItemStack at all, not by one with an amount of zero.

      This is not checked against the item's maximum stack size, so a stack you are holding may exceed it. Storing one that does in a machine item slot throws, since a slot can only show a single stack.

      Throws a PublicError of type PublicErrorType.InvalidArgument if set to anything other than a positive integer.

    • set amount(value: number): void
      Beta

      Parameters

      • value: number

      Returns void

    • Beta

      Converts this MachineItemStack to a Minecraft ItemStack.

      Returns ItemStack

      A Minecraft ItemStack with the same properties as this MachineItemStack.

      An ItemStack cannot hold more than one stack of an item, so an MachineItemStack.amount above the item's maximum stack size is reduced to fit and a warning is logged.

      Throws if the item type does not exist.