Bedrock Energistics Core
    Preparing search index...

    Function setMachineSlotItem

    • Beta

      Sets an item in a machine inventory.

      Parameters

      • loc: DimensionLocation

        The location of the machine.

      • elementId: string

        The ID of the item slot element.

      • OptionalnewItemStack: MachineItemStack

        The MachineItemStack to put in the slot. Pass undefined to remove the item in the slot.

      • Optionaloptions: MachineSlotItemExpectOptions

        Conditions the slot must meet.

      Returns Promise<boolean>

      Whether the item was set. Only false if options gave a condition the slot didn't meet, so a write with no conditions always resolves true.

      Without conditions in options, this replaces whatever is in the slot, including a change the player made since you last looked at it - which can duplicate an item they are already holding. For anything derived from the slot's current contents, prefer takeMachineSlotItem or addMachineSlotItem, or state what you expected to replace.

      Throws a PublicError of type PublicErrorType.NotFound if there is no block at the given location, including when that location's chunk is not loaded.

      Throws a PublicError of type PublicErrorType.NotRegistered if the block is not registered as a machine.

      Throws a PublicError of type PublicErrorType.InvalidArgument if the element is not an item slot, if the item is not allowed in that slot, if the item does not exist, or if its amount exceeds the item's maximum stack size.

      Throws a PublicError of type PublicErrorType.InvalidState if this package has not been initialized (see init).