use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class MovePlayerPacket method encode.
@Override
public void encode() {
try {
setChannel(NetworkChannel.CHANNEL_MOVEMENT);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeLong(this.eid);
writer.writeFloat(this.x);
writer.writeFloat(this.y + 1.62f);
writer.writeFloat(this.z);
writer.writeFloat(this.yaw);
writer.writeFloat(this.bodyYaw);
writer.writeFloat(this.pitch);
writer.writeByte(this.mode);
writer.writeByte((byte) (this.teleport ? 0x80 : 0x00));
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class PickUpItemPacket method encode.
@Override
public void encode() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeInt(target);
writer.writeInt(eid);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class PlayerEquipmentPacket method encode.
@Override
public void encode() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
writer.writeLong(eid);
PEInventorySlot.writeSlot(writer, item);
writer.writeByte((byte) (slot & 0xFF));
writer.writeByte((byte) (selectedSlot & 0xFF));
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class PlayerListPacket 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));
if (isAdding) {
writer.writeByte((byte) 0x00);
} else {
writer.writeByte((byte) 0x01);
}
writer.writeInt(players.size());
for (PlayerInfo info : players) {
info.encode(writer, isAdding);
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class EntityMetaData method encode.
public byte[] encode() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
try {
for (Map.Entry<Integer, EntityMetaDataObject> entry : this.map.entrySet()) {
writer.writeByte(((byte) (((entry.getValue().type() & 0xFF) << 5) | (entry.getKey() & 0x1F))));
writer.write(entry.getValue().encode());
}
writer.writeByte((byte) 0x7F);
return bos.toByteArray();
} catch (IOException e) {
}
return null;
}
Aggregations