Search in sources :

Example 1 with PEBinaryReader

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

the class WindowItemsPacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.windowID = reader.readByte();
        short cnt = reader.readShort();
        slots = new PEInventorySlot[cnt];
        for (int i = 0; i < cnt; i++) {
            slots[i] = PEInventorySlot.readSlot(reader);
        }
        if (this.windowID == PEWindowConstantID.PLAYER_INVENTORY) {
            short hcnt = reader.readShort();
            hotbar = new int[hcnt];
            for (int i = 0; i < hcnt; i++) {
                hotbar[i] = reader.readInt();
            }
        }
        this.setLength(reader.totallyRead());
    } catch (IOException e) {
    }
}
Also used : PEBinaryReader(org.dragonet.utilities.io.PEBinaryReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException)

Example 2 with PEBinaryReader

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

the class WindowSetSlotPacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.windowID = reader.readByte();
        this.slot = reader.readShort();
        this.hotbarSlot = reader.readShort();
        this.item = 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 3 with PEBinaryReader

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

the class RemoveBlockPacket method decode.

@Override
public void decode() {
    try {
        setChannel(NetworkChannel.CHANNEL_WORLD_EVENTS);
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.eid = reader.readLong();
        this.x = reader.readInt();
        this.z = reader.readInt();
        this.y = reader.readByte();
        this.setLength(reader.totallyRead());
    } catch (IOException e) {
    }
}
Also used : PEBinaryReader(org.dragonet.utilities.io.PEBinaryReader) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException)

Example 4 with PEBinaryReader

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

the class ClientHandshakePacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        //PID
        reader.readByte();
        this.address = reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        reader.readAddress();
        this.session2 = reader.readLong();
        this.session = 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)

Example 5 with PEBinaryReader

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

the class PlayerEquipmentPacket method decode.

@Override
public void decode() {
    try {
        PEBinaryReader reader = new PEBinaryReader(new ByteArrayInputStream(this.getData()));
        reader.readByte();
        this.eid = reader.readLong();
        this.item = PEInventorySlot.readSlot(reader);
        this.slot = reader.readByte() & 0xFF;
        this.selectedSlot = reader.readByte() & 0xFF;
        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