Bedrock Energistics Core
    Preparing search index...

    Item Machines

    Item machines are a standardized system for storing storage types inside machines. Register an item machine with the registerItemMachine function.

    // Register an item machine that can store energy.
    registerItemMachine({
    description: {
    // There must be an item with this ID.
    id: "example:my_item_machine",
    defaultIo: {
    categories: ["energy"],
    },
    },
    });

    Interface with item machines via the ItemMachine class.

    // The following code assumes that `player` is holding an item machine.
    const inventory = player.getComponent("inventory");
    const itemMachine = new ItemMachine(inventory, player.selectedSlotIndex);

    // Add 1 `energy`.
    const storedEnergy = await itemMachine.getStorage("energy");
    itemMachine.setStorage("energy", storedEnergy + 1);