use of net.glowstone.net.message.play.game.ExplosionMessage.Record in project Glowstone by GlowstoneMC.
the class Explosion method playOutExplosion.
private void playOutExplosion(GlowPlayer player, Iterable<BlockVector> blocks) {
Collection<Record> records = new ArrayList<>();
for (BlockVector block : blocks) {
byte x = (byte) (block.getBlockX() - location.getBlockX());
byte y = (byte) (block.getBlockY() - location.getBlockY());
byte z = (byte) (block.getBlockZ() - location.getBlockZ());
records.add(new Record(x, y, z));
}
Vector velocity = player.getVelocity();
ExplosionMessage message = new ExplosionMessage((float) location.getX(), (float) location.getY(), (float) location.getZ(), power, (float) velocity.getX(), (float) velocity.getY(), (float) velocity.getZ(), records);
player.getSession().send(message);
}
use of net.glowstone.net.message.play.game.ExplosionMessage.Record in project Glowstone by GlowstoneMC.
the class ExplosionCodec method encode.
@Override
public ByteBuf encode(ByteBuf buf, ExplosionMessage message) throws IOException {
buf.writeFloat(message.getX());
buf.writeFloat(message.getY());
buf.writeFloat(message.getZ());
buf.writeFloat(message.getRadius());
Collection<Record> records = message.getRecords();
buf.writeInt(records.size());
for (Record record : records) {
buf.writeByte(record.getX());
buf.writeByte(record.getY());
buf.writeByte(record.getZ());
}
buf.writeFloat(message.getPlayerMotionX());
buf.writeFloat(message.getPlayerMotionY());
buf.writeFloat(message.getPlayerMotionZ());
return buf;
}
Aggregations