Search in sources :

Example 1 with MessagePlayInDropHeldItem

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

the class CodecPlayInPlayerDigging method decode.

@Override
public Message decode(CodecContext context, ByteBuffer buf) throws CodecException {
    int action = buf.readByte();
    Vector3i position = buf.read(Types.VECTOR_3_I);
    int face = buf.readByte();
    switch(action) {
        case 0:
        case 1:
        case 2:
            return new MessagePlayInPlayerDigging(MessagePlayInPlayerDigging.Action.values()[action], position, fromFace(face));
        case 3:
        case 4:
            return new MessagePlayInDropHeldItem(action == 3);
        case 5:
            return new MessagePlayInOutFinishUsingItem();
        case 6:
            return new MessagePlayInSwapHandItems();
        default:
            throw new DecoderException("Unknown player digging message action: " + action);
    }
}
Also used : DecoderException(io.netty.handler.codec.DecoderException) MessagePlayInOutFinishUsingItem(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutFinishUsingItem) Vector3i(com.flowpowered.math.vector.Vector3i) MessagePlayInPlayerDigging(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInPlayerDigging) MessagePlayInSwapHandItems(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInSwapHandItems) MessagePlayInDropHeldItem(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInDropHeldItem)

Aggregations

Vector3i (com.flowpowered.math.vector.Vector3i)1 DecoderException (io.netty.handler.codec.DecoderException)1 MessagePlayInDropHeldItem (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInDropHeldItem)1 MessagePlayInOutFinishUsingItem (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutFinishUsingItem)1 MessagePlayInPlayerDigging (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInPlayerDigging)1 MessagePlayInSwapHandItems (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInSwapHandItems)1