Search in sources :

Example 1 with CombatEventMessage

use of net.glowstone.net.message.play.player.CombatEventMessage in project Glowstone by GlowstoneMC.

the class CombatEventCodec method decode.

@Override
public CombatEventMessage decode(ByteBuf buffer) throws IOException {
    int eventId = ByteBufUtils.readVarInt(buffer);
    Event event = Event.getAction(eventId);
    switch(event) {
        case END_COMBAT:
            {
                int duration = ByteBufUtils.readVarInt(buffer);
                int entityID = buffer.readInt();
                return new CombatEventMessage(event, duration, entityID);
            }
        case ENTITY_DEAD:
            int playerID = ByteBufUtils.readVarInt(buffer);
            int entityID = buffer.readInt();
            TextMessage message = GlowBufUtils.readChat(buffer);
            return new CombatEventMessage(event, playerID, entityID, message);
        default:
            return new CombatEventMessage(event);
    }
}
Also used : CombatEventMessage(net.glowstone.net.message.play.player.CombatEventMessage) Event(net.glowstone.net.message.play.player.CombatEventMessage.Event) TextMessage(net.glowstone.util.TextMessage)

Aggregations

CombatEventMessage (net.glowstone.net.message.play.player.CombatEventMessage)1 Event (net.glowstone.net.message.play.player.CombatEventMessage.Event)1 TextMessage (net.glowstone.util.TextMessage)1