use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class SetDifficultyPacket 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.difficulty);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class SetHealthPacket 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.health);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class SetTimePacket method encode.
@Override
public void encode() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PEBinaryWriter writer = new PEBinaryWriter(bos);
writer.writeByte((byte) (this.pid() & 0xFF));
//writer.writeInt((int)(((this.time / GlowWorld.DAY_LENGTH) * 19200) & 0xFFFFFFFF));
//We hack for now :P
writer.writeInt(20 * 60);
if (this.isTimeFreezed) {
writer.writeByte((byte) 0);
} else {
writer.writeByte((byte) 1);
}
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class AddItemEntityPacket 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);
PEInventorySlot.writeSlot(writer, item);
writer.writeFloat(x);
writer.writeFloat(y);
writer.writeFloat(z);
writer.writeFloat(speedX);
writer.writeFloat(speedY);
writer.writeFloat(speedZ);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
use of org.dragonet.utilities.io.PEBinaryWriter in project Dragonet-Legacy by DragonetMC.
the class AddPaintingPacket 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(x);
writer.writeInt(y);
writer.writeInt(z);
writer.writeInt(direction);
writer.writeString(title == null ? "" : title);
this.setData(bos.toByteArray());
} catch (IOException e) {
}
}
Aggregations