// Custom function to add an item to the inventory functionaddItemToInventory(itemStack) { returninventoryContainer.addItem(itemStack); }
// Custom function to move an item within the inventory functionmoveItemWithinInventory(fromSlot, toSlot) { inventoryContainer.moveItem(fromSlot, toSlot, inventoryContainer); }
// Custom function to transfer an item from inventory to another container functiontransferItemToContainer(fromSlot, targetContainer) { returninventoryContainer.transferItem(fromSlot, targetContainer); }
// Example usage of the custom functions constnewItemStack = newItemStack("apple", 10); // Assuming "apple" is a valid item constaddedItem = addItemToInventory(newItemStack); if (addedItem) { console.log("Item added to inventory:", addedItem); }
consttargetContainer = someOtherContainer; // Assuming 'someOtherContainer' is an instance of another container consttransferredItem = transferItemToContainer(0, targetContainer); if (transferredItem) { console.log("Item transferred to another container:", transferredItem); }
Returns whether the component is valid. A component is
considered valid if its owner is valid, in addition to any
addition to any additional validation required by the
component.
Defines this entity's inventory properties.
Example: getEntityInventoryComponent.js