Search in sources :

Example 1 with InventorySlotChangedEvent

use of org.terasology.logic.inventory.events.InventorySlotChangedEvent in project Terasology by MovingBlocks.

the class InventoryUtils method putItemIntoSlot.

static void putItemIntoSlot(EntityRef entity, EntityRef item, int slot) {
    InventoryComponent inventory = entity.getComponent(InventoryComponent.class);
    EntityRef oldItem = inventory.itemSlots.get(slot);
    inventory.itemSlots.set(slot, item);
    entity.saveComponent(inventory);
    entity.send(new InventorySlotChangedEvent(slot, oldItem, item));
}
Also used : EntityRef(org.terasology.entitySystem.entity.EntityRef) InventorySlotChangedEvent(org.terasology.logic.inventory.events.InventorySlotChangedEvent)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)1 InventorySlotChangedEvent (org.terasology.logic.inventory.events.InventorySlotChangedEvent)1