Search in sources :

Example 36 with PEBinaryWriter

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

the class WindowClosePacket method encode.

@Override
public void encode() {
    try {
        setChannel(NetworkChannel.CHANNEL_PRIORITY);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PEBinaryWriter writer = new PEBinaryWriter(bos);
        writer.writeByte((byte) (this.pid() & 0xFF));
        writer.writeByte(this.windowID);
        this.setData(bos.toByteArray());
    } catch (IOException e) {
    }
}
Also used : PEBinaryWriter(org.dragonet.utilities.io.PEBinaryWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 37 with PEBinaryWriter

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

the class InteractPacket method encode.

@Override
public void encode() {
    try {
        setChannel(NetworkChannel.CHANNEL_WORLD_EVENTS);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PEBinaryWriter writer = new PEBinaryWriter(bos);
        writer.writeByte((byte) (this.pid() & 0xFF));
        writer.writeByte(action);
        writer.writeLong(target);
        this.setData(bos.toByteArray());
    } catch (IOException e) {
    }
}
Also used : PEBinaryWriter(org.dragonet.utilities.io.PEBinaryWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 38 with PEBinaryWriter

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

the class SetEntityMotionPacket method encode.

@Override
public void encode() {
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PEBinaryWriter writer = new PEBinaryWriter(bos);
        writer.writeByte((byte) (this.pid() & 0xFF));
        writer.writeInt(this.motions.length);
        for (EntityMotionData d : this.motions) {
            if (d == null) {
                continue;
            }
            writer.writeLong(d.eid);
            writer.writeFloat(d.motionX);
            writer.writeFloat(d.motionY);
            writer.writeFloat(d.motionZ);
        }
        this.setData(bos.toByteArray());
    } catch (IOException e) {
    }
}
Also used : PEBinaryWriter(org.dragonet.utilities.io.PEBinaryWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 39 with PEBinaryWriter

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

the class SetSpawnPositionPacket method encode.

@Override
public void encode() {
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PEBinaryWriter writer = new PEBinaryWriter(bos);
        writer.writeByte((byte) (this.pid() & 0xFF));
        writer.writeInt(this.x);
        writer.writeInt(this.y);
        writer.writeInt(this.z);
        this.setData(bos.toByteArray());
    } catch (IOException e) {
    }
}
Also used : PEBinaryWriter(org.dragonet.utilities.io.PEBinaryWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)39 IOException (java.io.IOException)39 PEBinaryWriter (org.dragonet.utilities.io.PEBinaryWriter)39 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Deflater (java.util.zip.Deflater)1 Enchantment (org.bukkit.enchantments.Enchantment)1 FurnaceRecipe (org.bukkit.inventory.FurnaceRecipe)1 ItemStack (org.bukkit.inventory.ItemStack)1 Recipe (org.bukkit.inventory.Recipe)1 ShapedRecipe (org.bukkit.inventory.ShapedRecipe)1 ShapelessRecipe (org.bukkit.inventory.ShapelessRecipe)1 PEInventorySlot (org.dragonet.inventory.PEInventorySlot)1