Package net.glowstone.net.codec.play.entity

Source Code of net.glowstone.net.codec.play.entity.AnimateEntityCodec

package net.glowstone.net.codec.play.entity;

import com.flowpowered.networking.Codec;
import com.flowpowered.networking.util.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import net.glowstone.net.message.play.entity.AnimateEntityMessage;

import java.io.IOException;

public final class AnimateEntityCodec implements Codec<AnimateEntityMessage> {
    @Override
    public AnimateEntityMessage decode(ByteBuf buf) throws IOException {
        int id = ByteBufUtils.readVarInt(buf);
        int animation = buf.readUnsignedByte();
        return new AnimateEntityMessage(id, animation);
    }

    @Override
    public ByteBuf encode(ByteBuf buf, AnimateEntityMessage message) throws IOException {
        ByteBufUtils.writeVarInt(buf, message.getId());
        buf.writeByte(message.getAnimation());
        return buf;
    }
}
TOP

Related Classes of net.glowstone.net.codec.play.entity.AnimateEntityCodec

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.