List of usage examples for io.netty.buffer ByteBuf writeBoolean
public abstract ByteBuf writeBoolean(boolean value);
From source file:org.opendaylight.protocol.util.ByteBufWriteUtil.java
License:Open Source License
/** * Writes boolean <code>value</code> if not null, otherwise writes zero to * the <code>output</code> ByteBuf. ByteBuf's writerIndex is increased by 1. * * @param value//w ww .j a v a 2 s. c o m * Boolean value to be written to the output. * @param output * ByteBuf, where value or zero is written. */ public static void writeBoolean(final Boolean value, final ByteBuf output) { if (value != null) { output.writeBoolean(value); } else { output.writeZero(ONE_BYTE_LENGTH); } }
From source file:org.spongepowered.clean.network.packet.play.clientbound.ChunkDataPacket.java
License:MIT License
@Override public void write(ByteBuf buffer) { buffer.writeInt(this.chunk.getBlockMin().getX() >> 4); buffer.writeInt(this.chunk.getBlockMin().getZ() >> 4); buffer.writeBoolean(this.full); if (this.full) { this.mask = 0; for (int i = 0; i < 16; i++) { if (this.chunk.getSections()[i] != null) { this.mask |= (1 << i); }/*from w w w . j av a2 s . co m*/ } } else { for (int i = 0; i < 16; i++) { if (this.chunk.getSections()[i] == null) { this.mask &= ~(1 << i); } } } ByteBufUtil.writeVarInt(buffer, this.mask); ByteBuf chunkdata = Unpooled.buffer(); for (int i = 0; i < 16; i++) { if (((this.mask >> i) & 1) != 0) { ChunkSection section = this.chunk.getSections()[i]; chunkdata.writeByte(section.getBitsPerBlock()); if (section.getPalette() == GlobalPalette.instance) { ByteBufUtil.writeVarInt(chunkdata, 0); } else { ByteBufUtil.writeVarInt(chunkdata, section.getPalette().getHighestId() + 1); for (int p = 0; p <= section.getPalette().getHighestId(); p++) { BlockState block = section.getPalette().get(p).get(); ByteBufUtil.writeVarInt(chunkdata, GlobalPalette.instance.getOrAssign(block)); } } long[] data = section.getData(); ByteBufUtil.writeVarInt(chunkdata, data.length); for (int l = 0; l < data.length; l++) { chunkdata.writeLong(data[l]); } // block light long[] light = section.getBlockLightData(); for (int l = 0; l < light.length; l++) { chunkdata.writeLong(light[l]); } if (this.chunk.getWorld().getDimension().getType() == DimensionTypes.OVERWORLD) { // sky light long[] sky = section.getSkyLightData(); for (int l = 0; l < sky.length; l++) { chunkdata.writeLong(sky[l]); } } } } int size = chunkdata.readableBytes(); if (this.full) { size += 256; } ByteBufUtil.writeVarInt(buffer, size); buffer.writeBytes(chunkdata); if (this.full) { buffer.writeBytes(this.chunk.getBiomeArray()); } ByteBufUtil.writeVarInt(buffer, this.chunk.getTileEntities().size()); for (TileEntity te : this.chunk.getTileEntities()) { DataContainer data = te.toContainer(); ByteBufUtil.writeNBT(buffer, data); } }
From source file:org.spongepowered.clean.network.packet.play.clientbound.ConfirmTransactionPacket.java
License:MIT License
@Override public void write(ByteBuf buffer) { buffer.writeByte(this.windowid); buffer.writeShort(this.transactionid); buffer.writeBoolean(this.state); }
From source file:org.spongepowered.clean.network.packet.play.clientbound.JoinGamePacket.java
License:MIT License
@Override public void write(ByteBuf buffer) { buffer.writeInt(this.entity_id); buffer.writeByte(PacketIds.getGameModeId(this.gamemode)); buffer.writeInt(this.dimension); buffer.writeByte(PacketIds.getDifficultyId(this.difficulty)); buffer.writeByte(this.max_players); ByteBufUtil.writeString(buffer, this.level_type); buffer.writeBoolean(this.reduced_debug); }
From source file:org.spoutcraft.client.network.codec.play.PlayerCodec.java
License:MIT License
@Override public ByteBuf encode(ByteBuf buf, PlayerMessage message) throws IOException { buf.writeBoolean(message.isOnGround()); return buf;// ww w. j a va 2s . c om }
From source file:org.spoutcraft.client.network.codec.play.PositionLookCodec.java
License:MIT License
@Override public ByteBuf encode(ByteBuf buf, PositionLookMessage message) throws IOException { buf.writeDouble(message.getX());//from w w w . j av a 2 s. c om buf.writeDouble(message.getStance()); buf.writeDouble(message.getY()); buf.writeDouble(message.getZ()); buf.writeFloat(message.getYaw()); buf.writeFloat(message.getPitch()); buf.writeBoolean(message.isOnGround()); return buf; }
From source file:org.starmod.net.object.field.type.NetworkBoolean.java
License:MIT License
@Override public void encode(ByteBuf buf) { buf.writeBoolean(getValue()); }
From source file:org.starnub.starbounddata.packets.connection.ClientConnectPacket.java
License:Open Source License
/** * Recommended: For internal use with StarNub Player Sessions * <p>/*from w w w. ja v a 2s . co m*/ * Uses: This method will write to a {@link io.netty.buffer.ByteBuf} using this packets fields * <p> * * @param out ByteBuf representing the space to write out the packet reason */ @Override public void write(ByteBuf out) { writeVLQArray(out, this.assetDigest); if (this.playerUuid == null) { out.writeBoolean(false); } else { out.writeBoolean(true); writeUUID(out, this.playerUuid); } writeStringVLQ(out, this.playerName); writeStringVLQ(out, this.playerSpecies); writeVLQArray(out, this.shipData); this.shipUpgrades.write(out); writeStringVLQ(out, this.account); }
From source file:org.starnub.starbounddata.packets.connection.ConnectResponsePacket.java
License:Open Source License
/** * Recommended: For internal use with StarNub Player Sessions * <p>// w w w.j av a2 s. c o m * Uses: This method will write to a {@link io.netty.buffer.ByteBuf} using this packets fields * <p> * * @param out ByteBuf representing the space to write out the packet reason */ @Override public void write(ByteBuf out) { out.writeBoolean(this.success); out.writeBytes(VLQ.writeSignedVLQNoObject(this.clientId)); writeStringVLQ(out, this.rejectionReason); if (celestialBaseInformation == null) { out.writeBoolean(false); } else { out.writeBoolean(true); celestialBaseInformation.write(out); } }
From source file:org.starnub.starbounddata.packets.connection.ServerDisconnectPacket.java
License:Open Source License
/** * Recommended: For internal use with StarNub Player Sessions * <p>//from w w w . j a v a 2s .c om * Uses: This method will write to a {@link io.netty.buffer.ByteBuf} using this packets fields * <p> * * @param out ByteBuf representing the space to write out the packet reason */ @Override public void write(ByteBuf out) { if (reason == null) { out.writeBoolean(false); } else { out.writeBoolean(true); writeStringVLQ(out, this.reason); } }