Search in sources :

Example 16 with PEBinaryReader

use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.

the class CraftingEventPacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.windowId = reader.readByte();
        this.craftType = reader.readInt();
        this.uuid = reader.readUUID();
        int size = reader.readInt();
        input = new PEInventorySlot[size > 128 ? 128 : size];
        for (int i = 0; i < size; i++) {
            input[i] = PEInventorySlot.readSlot(reader);
        }
        size = reader.readInt();
        output = new PEInventorySlot[size > 128 ? 128 : size];
        for (int i = 0; i < size; i++) {
            output[i] = PEInventorySlot.readSlot(reader);
        }
        this.setLength(reader.totallyRead());
    } catch (IOException e) {
    }
}
Also used : PEBinaryReader(org.dragonet.utilities.io.PEBinaryReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException)

Example 17 with PEBinaryReader

use of org.dragonet.utilities.io.PEBinaryReader in project Dragonet-Legacy by DragonetMC.

the class InteractPacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.action = reader.readByte();
        this.target = reader.readLong();
        this.setLength(reader.totallyRead());
    } catch (IOException e) {
    }
}
Also used : PEBinaryReader(org.dragonet.utilities.io.PEBinaryReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)17 IOException (java.io.IOException)17 PEBinaryReader (org.dragonet.utilities.io.PEBinaryReader)17 DataFormatException (java.util.zip.DataFormatException)1 Inflater (java.util.zip.Inflater)1