use of org.terasology.logic.characters.events.ChangeHeldItemRequest in project Terasology by MovingBlocks.
the class BuilderHeldItemAuthoritySystem method onGiveItemToCharacterHoldItem.
@ReceiveEvent
public void onGiveItemToCharacterHoldItem(GiveItemEvent event, EntityRef item, ItemComponent itemComponent) {
if (event.getTargetEntity().hasComponent(CharacterHeldItemComponent.class)) {
event.getTargetEntity().addOrSaveComponent(new CharacterOwnedItemComponent(item));
event.getTargetEntity().send(new ChangeHeldItemRequest(item));
event.setHandled(true);
}
}
use of org.terasology.logic.characters.events.ChangeHeldItemRequest in project Terasology by MovingBlocks.
the class CharacterInventorySystem method onChangeSelectedInventorySlotRequested.
@ReceiveEvent(netFilter = RegisterMode.AUTHORITY)
public void onChangeSelectedInventorySlotRequested(ChangeSelectedInventorySlotRequest request, EntityRef character, SelectedInventorySlotComponent selectedInventorySlotComponent) {
if (request.getSlot() >= 0 && request.getSlot() < 10 && request.getSlot() != selectedInventorySlotComponent.slot) {
EntityRef newItem = InventoryUtils.getItemAt(character, request.getSlot());
selectedInventorySlotComponent.slot = request.getSlot();
character.saveComponent(selectedInventorySlotComponent);
character.send(new ChangeHeldItemRequest(newItem));
}
}
Aggregations