use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class PlayerActionPacket 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.writeLong(eid);
writer.writeInt(action);
writer.writeInt(x);
writer.writeInt(y);
writer.writeInt(z);
writer.writeInt(face);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class DisconnectPacket method encode.
@Override
public void encode() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeString(message);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class FullChunkPacket method encode.
@Override
public void encode() {
try {
setShouldSendImmidate(true);
setChannel(NetworkChannel.CHANNEL_WORLD_CHUNKS);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeInt(chunkX);
writer.writeInt(chunkZ);
//Default to COLUMNS
writer.writeByte(order != null ? order.getType() : (byte) 0);
writer.writeInt(chunkData.length);
writer.write(chunkData);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class LevelEventPacket 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.writeShort(eventID);
writer.writeFloat(x);
writer.writeFloat(y);
writer.writeFloat(z);
writer.writeInt(data);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class AddEntityPacket method encode.
@Override
public void encode() {
try {
setChannel(NetworkChannel.CHANNEL_ENTITY_SPAWNING);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeLong(eid);
writer.writeInt(type);
writer.writeFloat(x);
writer.writeFloat(y);
writer.writeFloat(z);
writer.writeFloat(speedX);
writer.writeFloat(speedY);
writer.writeFloat(speedZ);
writer.writeFloat(yaw);
writer.writeFloat(pitch);
writer.write(this.meta.encode());
writer.writeShort((short) (this.links == null ? 0 : this.links.length));
if (this.links != null) {
for (EntityLink link : links) {
link.writeTo(writer);
}
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
Aggregations