use of org.terasology.logic.inventory.events.InventorySlotStackSizeChangedEvent in project Terasology by MovingBlocks.
the class InventoryUtils method adjustStackSize.
static void adjustStackSize(EntityRef entity, int slot, int newCount) {
InventoryComponent inventory = entity.getComponent(InventoryComponent.class);
EntityRef item = inventory.itemSlots.get(slot);
ItemComponent itemComponent = item.getComponent(ItemComponent.class);
byte oldSize = itemComponent.stackCount;
itemComponent.stackCount = (byte) newCount;
item.saveComponent(itemComponent);
entity.send(new InventorySlotStackSizeChangedEvent(slot, oldSize, newCount));
}
Aggregations