Example usage for com.google.common.io ByteArrayDataInput skipBytes

List of usage examples for com.google.common.io ByteArrayDataInput skipBytes

Introduction

In this page you can find the example usage for com.google.common.io ByteArrayDataInput skipBytes.

Prototype

@Override
    int skipBytes(int n);

Source Link

Usage

From source file:cpw.mods.fml.common.network.EntitySpawnPacket.java

@Override
public FMLPacket consumePacket(byte[] data) {
    ByteArrayDataInput dat = ByteStreams.newDataInput(data);
    networkId = dat.readInt();//from  w w  w  .  j  a v  a2  s  . com
    modEntityId = dat.readInt();
    entityId = dat.readInt();
    rawX = dat.readInt();
    rawY = dat.readInt();
    rawZ = dat.readInt();
    scaledX = rawX / 32D;
    scaledY = rawY / 32D;
    scaledZ = rawZ / 32D;
    scaledYaw = dat.readByte() * 360F / 256F;
    scaledPitch = dat.readByte() * 360F / 256F;
    scaledHeadYaw = dat.readByte() * 360F / 256F;
    ByteArrayInputStream bis = new ByteArrayInputStream(data, 27, data.length - 27);
    DataInputStream dis = new DataInputStream(bis);
    try {
        metadata = DataWatcher.func_75686_a(dis);
    } catch (IOException e) {
        // Nope
    }
    dat.skipBytes(data.length - bis.available() - 27);
    throwerId = dat.readInt();
    if (throwerId != 0) {
        speedScaledX = dat.readInt() / 8000D;
        speedScaledY = dat.readInt() / 8000D;
        speedScaledZ = dat.readInt() / 8000D;
    }

    this.dataStream = dat;
    return this;
}