use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class StartGamePacket 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.seed);
writer.writeByte(this.dimension);
writer.writeInt(this.generator);
writer.writeInt(this.gamemode);
writer.writeLong(this.eid);
writer.writeInt(this.spawnX);
writer.writeInt(this.spawnY);
writer.writeInt(this.spawnZ);
writer.writeFloat(this.x);
writer.writeFloat(this.y + 1.62f);
writer.writeFloat(this.z);
writer.writeByte((byte) 0);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class UpdateBlockPacket method encode.
@Override
public void encode() {
setShouldSendImmidate(true);
try {
setChannel(NetworkChannel.CHANNEL_BLOCKS);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
if (this.records == null) {
writer.writeInt(0);
} else {
writer.writeInt(this.records.length);
for (UpdateBlockRecord rec : this.records) {
writer.writeInt(rec.x);
writer.writeInt(rec.z);
writer.writeByte(rec.y);
writer.writeByte(rec.block);
writer.writeByte((byte) (rec.flags << 4 | rec.meta));
}
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class WindowDataPacket 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);
writer.writeShort(this.property);
writer.writeShort(this.value);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class WindowItemsPacket 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);
writer.writeShort((short) (this.slots.length & 0xFFFF));
for (PEInventorySlot slot : this.slots) {
PEInventorySlot.writeSlot(writer, slot);
}
if (windowID == PEWindowConstantID.PLAYER_INVENTORY && this.hotbar.length > 0) {
writer.writeShort((short) (this.hotbar.length & 0xFFFF));
for (int slot : this.hotbar) {
writer.writeInt(slot);
}
} else {
writer.writeShort((short) 0);
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class WindowOpenPacket 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);
writer.writeByte(this.type);
writer.writeShort(this.slots);
writer.writeInt(this.x);
writer.writeInt(this.y);
writer.writeInt(this.z);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
Aggregations