Java Code Examples for io.netty.buffer.ByteBuf#writeLongLE()
The following examples show how to use
io.netty.buffer.ByteBuf#writeLongLE() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdventureSettingsSerializer_v340.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, AdventureSettingsPacket packet) { int flags1 = 0; int flags2 = 0; for (AdventureSettingsPacket.Flag flag : packet.getFlags()) { if (FLAGS_TO_BIT_1.containsKey(flag)) { flags1 |= FLAGS_TO_BIT_1.get(flag); } else if (FLAGS_TO_BIT_2.containsKey(flag)) { flags2 |= FLAGS_TO_BIT_2.get(flag); } } VarInts.writeUnsignedInt(buffer, flags1); VarInts.writeUnsignedInt(buffer, packet.getCommandPermission().ordinal()); VarInts.writeUnsignedInt(buffer, flags2); VarInts.writeUnsignedInt(buffer, packet.getPlayerPermission().ordinal()); VarInts.writeUnsignedInt(buffer, 0); // Useless buffer.writeLongLE(packet.getUniqueEntityId()); }
Example 2
Source File: LevelChunkSerializer_v388.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, LevelChunkPacket packet) { VarInts.writeInt(buffer, packet.getChunkX()); VarInts.writeInt(buffer, packet.getChunkZ()); VarInts.writeUnsignedInt(buffer, packet.getSubChunksLength()); buffer.writeBoolean(packet.isCachingEnabled()); if (packet.isCachingEnabled()) { LongList blobIds = packet.getBlobIds(); VarInts.writeUnsignedInt(buffer, blobIds.size()); for (long blobId : blobIds) { buffer.writeLongLE(blobId); } } BedrockUtils.writeByteArray(buffer, packet.getData()); }
Example 3
Source File: BufferUtils.java From vertx-sql-client with Apache License 2.0 | 6 votes |
public static void writeLengthEncodedInteger(ByteBuf buffer, long value) { if (value < 251) { // 1-byte integer buffer.writeByte((byte) value); } else if (value <= 0xFFFF) { // 0xFC + 2-byte integer buffer.writeByte(0xFC); buffer.writeShortLE((int) value); } else if (value < 0xFFFFFF) { // 0xFD + 3-byte integer buffer.writeByte(0xFD); buffer.writeMediumLE((int) value); } else { // 0xFE + 8-byte integer buffer.writeByte(0xFE); buffer.writeLongLE(value); } }
Example 4
Source File: BedrockSession.java From Protocol with Apache License 2.0 | 6 votes |
private byte[] generateTrailer(ByteBuf buf) { VoxelwindHash hash = hashLocal.get(); ByteBuf counterBuf = null; ByteBuf keyBuf = null; try { counterBuf = PooledByteBufAllocator.DEFAULT.directBuffer(8); keyBuf = PooledByteBufAllocator.DEFAULT.directBuffer(agreedKey.getEncoded().length); counterBuf.writeLongLE(this.sentEncryptedPacketCount.getAndIncrement()); keyBuf.writeBytes(this.agreedKey.getEncoded()); hash.update(counterBuf); hash.update(buf); hash.update(keyBuf); byte[] digested = hash.digest(); return Arrays.copyOf(digested, 8); } finally { if (counterBuf != null) { counterBuf.release(); } if (keyBuf != null) { keyBuf.release(); } } }
Example 5
Source File: AdventureSettingsSerializer_v291.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, AdventureSettingsPacket packet) { int flags1 = 0; int flags2 = 0; for (AdventureSettingsPacket.Flag flag : packet.getFlags()) { if (FLAGS_TO_BIT_1.containsKey(flag)) { flags1 |= FLAGS_TO_BIT_1.get(flag); } else if (FLAGS_TO_BIT_2.containsKey(flag)) { flags2 |= FLAGS_TO_BIT_2.get(flag); } } VarInts.writeUnsignedInt(buffer, flags1); VarInts.writeUnsignedInt(buffer, packet.getCommandPermission().ordinal()); VarInts.writeUnsignedInt(buffer, flags2); VarInts.writeUnsignedInt(buffer, packet.getPlayerPermission().ordinal()); VarInts.writeUnsignedInt(buffer, 0); // Useless buffer.writeLongLE(packet.getUniqueEntityId()); }
Example 6
Source File: ResourcePackChunkDataSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, ResourcePackChunkDataPacket packet) { String packInfo = packet.getPackId().toString() + (packet.getPackVersion() == null ? "" : '_' + packet.getPackVersion()); BedrockUtils.writeString(buffer, packInfo); buffer.writeIntLE(packet.getChunkIndex()); buffer.writeLongLE(packet.getProgress()); byte[] data = packet.getData(); buffer.writeIntLE(data.length); buffer.writeBytes(data); }
Example 7
Source File: ResourcePackChunkDataPacket.java From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 | 5 votes |
@Override public void toData(ConnectionImpl connection, ByteBuf serializer) { StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, packId); serializer.writeIntLE(chunkIdx); serializer.writeLongLE(CHUNK_SIZE * chunkIdx); serializer.writeIntLE(packChunk.length); serializer.writeBytes(packChunk); }
Example 8
Source File: ResourcePackChunkDataSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, ResourcePackChunkDataPacket packet) { String packInfo = packet.getPackId().toString() + (packet.getPackVersion() == null ? "" : '_' + packet.getPackVersion()); BedrockUtils.writeString(buffer, packInfo); buffer.writeIntLE(packet.getChunkIndex()); buffer.writeLongLE(packet.getProgress()); byte[] data = packet.getData(); buffer.writeIntLE(data.length); buffer.writeBytes(data); }
Example 9
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writePacksInfoEntries(ByteBuf buffer, Collection<ResourcePacksInfoPacket.Entry> packInfoEntries) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(packInfoEntries, "packInfoEntries"); buffer.writeShortLE(packInfoEntries.size()); for (ResourcePacksInfoPacket.Entry packInfoEntry : packInfoEntries) { writeString(buffer, packInfoEntry.getPackId()); writeString(buffer, packInfoEntry.getPackVersion()); buffer.writeLongLE(packInfoEntry.getPackSize()); writeString(buffer, packInfoEntry.getEncryptionKey()); writeString(buffer, packInfoEntry.getSubpackName()); writeString(buffer, packInfoEntry.getContentId()); buffer.writeBoolean(packInfoEntry.isScripting()); } }
Example 10
Source File: ResourcePackDataInfoSerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, ResourcePackDataInfoPacket packet) { String packInfo = packet.getPackId().toString() + (packet.getPackVersion() == null ? "" : '_' + packet.getPackVersion()); BedrockUtils.writeString(buffer, packInfo); buffer.writeIntLE((int) packet.getMaxChunkSize()); buffer.writeIntLE((int) packet.getChunkCount()); buffer.writeLongLE(packet.getCompressedPackSize()); BedrockUtils.writeByteArray(buffer, packet.getHash()); }
Example 11
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 5 votes |
public static void writePacksInfoEntries(ByteBuf buffer, Collection<ResourcePacksInfoPacket.Entry> packInfoEntries) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(packInfoEntries, "packInfoEntries"); buffer.writeShortLE(packInfoEntries.size()); for (ResourcePacksInfoPacket.Entry packInfoEntry : packInfoEntries) { writeString(buffer, packInfoEntry.getPackId()); writeString(buffer, packInfoEntry.getPackVersion()); buffer.writeLongLE(packInfoEntry.getPackSize()); writeString(buffer, packInfoEntry.getEncryptionKey()); writeString(buffer, packInfoEntry.getSubpackName()); writeString(buffer, packInfoEntry.getContentId()); buffer.writeBoolean(packInfoEntry.isScripting()); } }
Example 12
Source File: Kcp.java From java-Kcp with Apache License 2.0 | 5 votes |
private static int encodeSeg(ByteBuf buf, Segment seg) { int offset = buf.writerIndex(); buf.writeIntLE(seg.conv); buf.writeByte(seg.cmd); buf.writeByte(seg.frg); buf.writeShortLE(seg.wnd); buf.writeIntLE((int) seg.ts); buf.writeIntLE((int) seg.sn); buf.writeIntLE((int) seg.una); buf.writeIntLE(seg.data.readableBytes()); switch (seg.ackMaskSize){ case 8: buf.writeByte((int) seg.ackMask); break; case 16: buf.writeShortLE((int) seg.ackMask); break; case 32: buf.writeIntLE((int) seg.ackMask); break; case 64: buf.writeLongLE(seg.ackMask); break; } Snmp.snmp.OutSegs.increment(); return buf.writerIndex() - offset; }
Example 13
Source File: ResourcePackChunkDataSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, ResourcePackChunkDataPacket packet) { String packInfo = packet.getPackId().toString() + (packet.getPackVersion() == null ? "" : '_' + packet.getPackVersion()); BedrockUtils.writeString(buffer, packInfo); buffer.writeIntLE(packet.getChunkIndex()); buffer.writeLongLE(packet.getProgress()); BedrockUtils.writeByteArray(buffer, packet.getData()); }
Example 14
Source File: EntityPickRequestSerializer_v332.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, EntityPickRequestPacket packet) { buffer.writeLongLE(packet.getRuntimeEntityId()); buffer.writeByte(packet.getHotbarSlot()); }
Example 15
Source File: EntityPickRequestSerializer_v354.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, EntityPickRequestPacket packet) { buffer.writeLongLE(packet.getRuntimeEntityId()); buffer.writeByte(packet.getHotbarSlot()); }
Example 16
Source File: NetworkStackLatencySerializer_v354.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, NetworkStackLatencyPacket packet) { buffer.writeLongLE(packet.getTimestamp()); buffer.writeBoolean(packet.isSendBack()); }
Example 17
Source File: BedrockUtils.java From Protocol with Apache License 2.0 | 4 votes |
public static void writeUuid(ByteBuf buffer, UUID uuid) { Preconditions.checkNotNull(buffer, "buffer"); Preconditions.checkNotNull(uuid, "uuid"); buffer.writeLongLE(uuid.getMostSignificantBits()); buffer.writeLongLE(uuid.getLeastSignificantBits()); }
Example 18
Source File: NetworkStackLatencySerializer_v361.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, NetworkStackLatencyPacket packet) { buffer.writeLongLE(packet.getTimestamp()); buffer.writeBoolean(packet.isSendBack()); }
Example 19
Source File: EntityPickRequestSerializer_v291.java From Protocol with Apache License 2.0 | 4 votes |
@Override public void serialize(ByteBuf buffer, EntityPickRequestPacket packet) { buffer.writeLongLE(packet.getRuntimeEntityId()); buffer.writeByte(packet.getHotbarSlot()); }
Example 20
Source File: DataTypeCodec.java From vertx-sql-client with Apache License 2.0 | 4 votes |
private static void binaryEncodeInt8(Number value, ByteBuf buffer) { buffer.writeLongLE(value.longValue()); }