Search in sources :

Example 1 with MessagePlayOutEntityCollectItem

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEntityCollectItem in project LanternServer by LanternPowered.

the class EntityProtocol method handleEvent.

@Override
protected void handleEvent(EntityProtocolUpdateContext context, EntityEvent event) {
    if (event instanceof CollectEntityEvent) {
        final LanternLiving collector = (LanternLiving) ((CollectEntityEvent) event).getCollector();
        context.getId(collector).ifPresent(id -> {
            final int count = ((CollectEntityEvent) event).getCollectedItemsCount();
            context.sendToAll(() -> new MessagePlayOutEntityCollectItem(id, getRootEntityId(), count));
        });
    } else {
        super.handleEvent(context, event);
    }
}
Also used : CollectEntityEvent(org.lanternpowered.server.entity.event.CollectEntityEvent) LanternLiving(org.lanternpowered.server.entity.LanternLiving) MessagePlayOutEntityCollectItem(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEntityCollectItem)

Aggregations

LanternLiving (org.lanternpowered.server.entity.LanternLiving)1 CollectEntityEvent (org.lanternpowered.server.entity.event.CollectEntityEvent)1 MessagePlayOutEntityCollectItem (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEntityCollectItem)1