use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class AddPlayerPacket method encode.
@Override
public void encode() {
setShouldSendImmidate(true);
setChannel(NetworkChannel.CHANNEL_ENTITY_SPAWNING);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
try {
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeUUID(uuid);
writer.writeString(this.username);
writer.writeLong(this.eid);
writer.writeFloat(this.x);
writer.writeFloat(this.y);
writer.writeFloat(this.z);
writer.writeFloat(this.speedX);
writer.writeFloat(this.speedY);
writer.writeFloat(this.speedZ);
writer.writeFloat(this.yaw);
//Head rotation
writer.writeFloat(this.yaw);
writer.writeFloat(this.pitch);
PEInventorySlot.writeSlot(writer, this.item);
// TODO Fix metadata, one of the reasons why skins didn't work properly!
writer.writeByte((byte) 0x00);
//writer.write(this.metadata.encode());
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class ChatPacket method encode.
@Override
public void encode() {
try {
setChannel(NetworkChannel.CHANNEL_TEXT);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeByte((byte) (this.type.getType() & 0xFF));
switch(this.type) {
case POPUP:
case CHAT:
writer.writeString(this.source);
case RAW:
case TIP:
case SYSTEM:
writer.writeString(this.message);
break;
case TRANSLATION:
writer.writeString(this.message);
if (this.params == null) {
writer.writeByte((byte) 0);
break;
}
writer.writeByte((byte) (this.params.length & 0xFF));
for (int i = 0; i < this.params.length; i++) {
writer.writeString(this.params[i]);
}
break;
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class LoginStatusPacket method encode.
@Override
public void encode() {
setShouldSendImmidate(true);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeInt(this.status);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class MoveEntitiesPacket 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.writeInt(this.entities.length);
for (MoveEntityData d : this.entities) {
writer.writeLong(d.eid);
writer.writeFloat(d.x);
writer.writeFloat(d.y);
writer.writeFloat(d.z);
writer.writeFloat(d.yaw);
writer.writeFloat(d.pitch);
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class PingPongPacket method encode.
@Override
public void encode() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeLong(this.pingID);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
Aggregations