Java Code Examples for protocolsupport.protocol.serializer.ArraySerializer#writeVarIntByteArray()
The following examples show how to use
protocolsupport.protocol.serializer.ArraySerializer#writeVarIntByteArray() .
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: ChunkLight.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { int blockMask = ((setSkyLightMask | setBlockLightMask | emptySkyLightMask | emptyBlockLightMask) >> 1) & 0xFFFF; boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(false); //full VarNumberSerializer.writeVarInt(chunkdata, blockMask); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVariesWithLight.writeSectionsCompactPreFlattening( to, blockMask, 13, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> cachedChunk.getTiles(sectionNumber).values() .forEach(tile -> blocktileupdates.add(BlockTileUpdate.create(version, tile))) ); }); codec.write(chunkdata); for (ClientBoundPacketData blocktileupdate : blocktileupdates) { codec.write(blocktileupdate); } }
Example 2
Source File: ChunkLight.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunklight = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_LIGHT); PositionSerializer.writeVarIntChunkCoord(chunklight, coord); VarNumberSerializer.writeVarInt(chunklight, setSkyLightMask); VarNumberSerializer.writeVarInt(chunklight, setBlockLightMask); VarNumberSerializer.writeVarInt(chunklight, emptySkyLightMask); VarNumberSerializer.writeVarInt(chunklight, emptyBlockLightMask); for (int i = 0; i < ChunkConstants.SECTION_COUNT_LIGHT; i++) { if (BitUtils.isIBitSet(setSkyLightMask, i)) { ArraySerializer.writeVarIntByteArray(chunklight, skyLight[i]); } } for (int i = 0; i < ChunkConstants.SECTION_COUNT_LIGHT; i++) { if (BitUtils.isIBitSet(setBlockLightMask, i)) { ArraySerializer.writeVarIntByteArray(chunklight, blockLight[i]); } } codec.write(chunklight); }
Example 3
Source File: UpdateMap.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData updatemap = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_MAP); VarNumberSerializer.writeVarInt(updatemap, id); updatemap.writeByte(scale); updatemap.writeBoolean(showIcons); ArraySerializer.writeVarIntTArray(updatemap, icons, (to, icon) -> { to.writeByte(((icon.type <= 9 ? icon.type : 0) << 4) | icon.direction); to.writeByte(icon.x); to.writeByte(icon.z); }); updatemap.writeByte(columns); if (columns > 0) { ArrayBasedIdRemappingTable colorRemapper = MapColorRemapper.REMAPPER.getTable(version); for (int i = 0; i < colors.length; i++) { colors[i] = (byte) colorRemapper.getRemap(colors[i] & 0xFF); } updatemap.writeByte(rows); updatemap.writeByte(xstart); updatemap.writeByte(zstart); ArraySerializer.writeVarIntByteArray(updatemap, colors); } codec.write(updatemap); }
Example 4
Source File: ChunkLight.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunklight = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_LIGHT); PositionSerializer.writeVarIntChunkCoord(chunklight, coord); chunklight.writeBoolean(trustEdges); VarNumberSerializer.writeVarInt(chunklight, setSkyLightMask); VarNumberSerializer.writeVarInt(chunklight, setBlockLightMask); VarNumberSerializer.writeVarInt(chunklight, emptySkyLightMask); VarNumberSerializer.writeVarInt(chunklight, emptyBlockLightMask); for (int i = 0; i < ChunkConstants.SECTION_COUNT_LIGHT; i++) { if (BitUtils.isIBitSet(setSkyLightMask, i)) { ArraySerializer.writeVarIntByteArray(chunklight, skyLight[i]); } } for (int i = 0; i < ChunkConstants.SECTION_COUNT_LIGHT; i++) { if (BitUtils.isIBitSet(setBlockLightMask, i)) { ArraySerializer.writeVarIntByteArray(chunklight, blockLight[i]); } } codec.write(chunklight); }
Example 5
Source File: ChunkLight.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { int blockMask = ((setSkyLightMask | setBlockLightMask | emptySkyLightMask | emptyBlockLightMask) >> 1) & 0xFFFF; boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(false); //full chunkdata.writeShort(blockMask); ArraySerializer.writeVarIntByteArray(chunkdata, ChunkWriterShort.serializeSections( blockMask, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> cachedChunk.getTiles(sectionNumber).values().forEach(tile -> blocktileupdates.add(BlockTileUpdate.create(version, tile))) )); codec.write(chunkdata); for (ClientBoundPacketData blocktileupdate : blocktileupdates) { codec.write(blocktileupdate); } }
Example 6
Source File: UpdateMap.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData updatemap = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_MAP); VarNumberSerializer.writeVarInt(updatemap, id); updatemap.writeByte(scale); ArraySerializer.writeVarIntTArray(updatemap, icons, (to, icon) -> { to.writeByte(((icon.type <= 9 ? icon.type : 0) << 4) | icon.direction); to.writeByte(icon.x); to.writeByte(icon.z); }); updatemap.writeByte(columns); if (columns > 0) { ArrayBasedIdRemappingTable colorRemapper = MapColorRemapper.REMAPPER.getTable(version); for (int i = 0; i < colors.length; i++) { colors[i] = (byte) colorRemapper.getRemap(colors[i] & 0xFF); } updatemap.writeByte(rows); updatemap.writeByte(xstart); updatemap.writeByte(zstart); ArraySerializer.writeVarIntByteArray(updatemap, colors); } codec.write(updatemap); }
Example 7
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); VarNumberSerializer.writeVarInt(chunkdata, blockMask); boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVariesWithLight.writeSectionsCompactFlattening( to, blockMask, 14, blockDataRemappingTable, flatteningBlockDataTable, cachedChunk, hasSkyLight, sectionNumber -> {} ); if (full) { int[] legacyBiomeData = LegacyBiomeData.toLegacyBiomeData(biomes); for (int biomeId : legacyBiomeData) { to.writeInt(biomeRemappingTable.getRemap(biomeId)); } } }); ArraySerializer.writeVarIntTArray(chunkdata, lTo -> { int count = 0; for (Map<Position, TileEntity> sectionTiles : cachedChunk.getTiles()) { for (TileEntity tile : sectionTiles.values()) { ItemStackSerializer.writeDirectTag(lTo, tile.getNBT()); } count += sectionTiles.size(); } return count; }); codec.write(chunkdata); }
Example 8
Source File: MiddleEncryptionResponse.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToServer() { ServerBoundPacketData encryptionresponse = ServerBoundPacketData.create(PacketType.SERVERBOUND_LOGIN_ENCRYPTION_BEGIN); ArraySerializer.writeVarIntByteArray(encryptionresponse, sharedSecret); ArraySerializer.writeVarIntByteArray(encryptionresponse, verifyToken); codec.read(encryptionresponse); }
Example 9
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); if ((blockMask == 0) && full) { chunkdata.writeShort(1); ArraySerializer.writeVarIntByteArray(chunkdata, ChunkWriterUtils.getEmptySectionShort(hasSkyLight)); } else { chunkdata.writeShort(blockMask); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { to.writeBytes(ChunkWriterShort.serializeSections(blockMask, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> {})); if (full) { int[] legacyBiomeData = LegacyBiomeData.toLegacyBiomeData(biomes); for (int biomeId : legacyBiomeData) { to.writeByte(biomeRemappingTable.getRemap(biomeId)); } } }); } codec.write(chunkdata); for (Map<Position, TileEntity> sectionTiles : cachedChunk.getTiles()) { for (TileEntity tile : sectionTiles.values()) { codec.write(BlockTileUpdate.create(version, tile)); } } }
Example 10
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); VarNumberSerializer.writeVarInt(chunkdata, blockMask); ItemStackSerializer.writeDirectTag(chunkdata, HeightMapTransformer.transform(heightmaps)); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVaries.writeSectionsCompact( to, blockMask, 14, blockDataRemappingTable, flatteningBlockDataTable, sections ); if (full) { int[] legacyBiomeData = LegacyBiomeData.toLegacyBiomeData(biomes); for (int biomeId : legacyBiomeData) { to.writeInt(biomeRemappingTable.getRemap(biomeId)); } } }); ArraySerializer.writeVarIntTArray( chunkdata, tiles, (to, tile) -> ItemStackSerializer.writeDirectTag(to, tileRemapper.remap(tile).getNBT()) ); codec.write(chunkdata); }
Example 11
Source File: ResourcePackDataInfoPacket.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, pack.getPackId()); serializer.writeIntLE(ResourcePackChunkDataPacket.CHUNK_SIZE); //max chunk size 1MB serializer.writeIntLE((int) Math.ceil(pack.getPackSize() / ResourcePackChunkDataPacket.CHUNK_SIZE)); //chunk count serializer.writeLongLE(pack.getPackSize()); //res pack size byte[] hash = pack.getSha256(); ArraySerializer.writeVarIntByteArray(serializer, hash); }
Example 12
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunksingle = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunksingle, coord); chunksingle.writeBoolean(full); VarNumberSerializer.writeVarInt(chunksingle, blockMask); boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ArraySerializer.writeVarIntByteArray(chunksingle, to -> { ChunkWriterVariesWithLight.writeSectionsCompactPreFlattening( to, blockMask, 13, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> {} ); if (full) { int[] legacyBiomeData = LegacyBiomeData.toLegacyBiomeData(biomes); for (int biomeId : legacyBiomeData) { to.writeByte(biomeRemappingTable.getRemap(biomeId)); } } }); codec.write(chunksingle); for (Map<Position, TileEntity> sectionTiles : cachedChunk.getTiles()) { for (TileEntity tile : sectionTiles.values()) { codec.write(BlockTileUpdate.create(version, tile)); } } }
Example 13
Source File: UpdateMap.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData updatemap = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_MAP); VarNumberSerializer.writeVarInt(updatemap, id); updatemap.writeByte(scale); updatemap.writeBoolean(showIcons); ArraySerializer.writeVarIntTArray(updatemap, icons, (to, icon) -> { VarNumberSerializer.writeVarInt(to, icon.type); to.writeByte(icon.x); to.writeByte(icon.z); to.writeByte(icon.direction); to.writeBoolean(icon.displayName != null); if (icon.displayName != null) { StringSerializer.writeVarIntUTF8String(to, icon.displayName); } }); updatemap.writeByte(columns); if (columns > 0) { ArrayBasedIdRemappingTable colorRemapper = MapColorRemapper.REMAPPER.getTable(version); for (int i = 0; i < colors.length; i++) { colors[i] = (byte) colorRemapper.getRemap(colors[i] & 0xFF); } updatemap.writeByte(rows); updatemap.writeByte(xstart); updatemap.writeByte(zstart); ArraySerializer.writeVarIntByteArray(updatemap, colors); } codec.write(updatemap); }
Example 14
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); chunkdata.writeBoolean(useExistingLight); VarNumberSerializer.writeVarInt(chunkdata, blockMask); ItemStackSerializer.writeDirectTag(chunkdata, heightmaps); if (full) { for (int biome : biomes) { chunkdata.writeInt(biomeRemappingTable.getRemap(biome)); } } ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVaries.writeSectionsPadded( to, blockMask, 14, blockDataRemappingTable, flatteningBlockDataTable, sections ); }); ArraySerializer.writeVarIntTArray( chunkdata, tiles, (to, tile) -> ItemStackSerializer.writeDirectTag(to, tileRemapper.remap(tile).getNBT()) ); codec.write(chunkdata); }
Example 15
Source File: EncryptionRequest.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData encryptionrequest = ClientBoundPacketData.create(PacketType.CLIENTBOUND_LOGIN_ENCRYPTION_BEGIN); StringSerializer.writeVarIntUTF8String(encryptionrequest, serverId); ArraySerializer.writeVarIntByteArray(encryptionrequest, publicKey); ArraySerializer.writeVarIntByteArray(encryptionrequest, verifyToken); codec.write(encryptionrequest); }
Example 16
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); VarNumberSerializer.writeVarInt(chunkdata, blockMask); ItemStackSerializer.writeDirectTag(chunkdata, HeightMapTransformer.transform(heightmaps)); if (full) { for (int biome : biomes) { chunkdata.writeInt(biomeRemappingTable.getRemap(biome)); } } ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVaries.writeSectionsCompact( to, blockMask, 14, blockDataRemappingTable, flatteningBlockDataTable, sections ); }); ArraySerializer.writeVarIntTArray( chunkdata, tiles, (to, tile) -> ItemStackSerializer.writeDirectTag(to, tileRemapper.remap(tile).getNBT()) ); codec.write(chunkdata); }
Example 17
Source File: UpdateMap.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData updatemap = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_MAP); VarNumberSerializer.writeVarInt(updatemap, id); updatemap.writeByte(scale); updatemap.writeBoolean(showIcons); updatemap.writeBoolean(locked); ArraySerializer.writeVarIntTArray(updatemap, icons, (to, icon) -> { VarNumberSerializer.writeVarInt(to, icon.type); to.writeByte(icon.x); to.writeByte(icon.z); to.writeByte(icon.direction); to.writeBoolean(icon.displayName != null); if (icon.displayName != null) { StringSerializer.writeVarIntUTF8String(to, icon.displayName); } }); updatemap.writeByte(columns); if (columns > 0) { ArrayBasedIdRemappingTable colorRemapper = MapColorRemapper.REMAPPER.getTable(version); for (int i = 0; i < colors.length; i++) { colors[i] = (byte) colorRemapper.getRemap(colors[i] & 0xFF); } updatemap.writeByte(rows); updatemap.writeByte(xstart); updatemap.writeByte(zstart); ArraySerializer.writeVarIntByteArray(updatemap, colors); } codec.write(updatemap); }
Example 18
Source File: ChunkLight.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { int blockMask = ((setSkyLightMask | setBlockLightMask | emptySkyLightMask | emptyBlockLightMask) >> 1) & 0xFFFF; boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); List<Collection<TileEntity>> resendTiles = new ArrayList<>(); ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(false); //full VarNumberSerializer.writeVarInt(chunkdata, blockMask); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVariesWithLight.writeSectionsCompactPreFlattening( to, blockMask, 13, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> resendTiles.add(cachedChunk.getTiles(sectionNumber).values()) ); }); ArraySerializer.writeVarIntTArray(chunkdata, lTo -> { int count = 0; for (Collection<TileEntity> sectionTiles : resendTiles) { for (TileEntity tile : sectionTiles) { ItemStackSerializer.writeDirectTag(lTo, tile.getNBT()); } count += sectionTiles.size(); } return count; }); codec.write(chunkdata); }
Example 19
Source File: ChunkData.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData chunkdata = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHUNK_SINGLE); PositionSerializer.writeIntChunkCoord(chunkdata, coord); chunkdata.writeBoolean(full); VarNumberSerializer.writeVarInt(chunkdata, blockMask); boolean hasSkyLight = cache.getClientCache().hasSkyLightInCurrentDimension(); ArraySerializer.writeVarIntByteArray(chunkdata, to -> { ChunkWriterVariesWithLight.writeSectionsCompactPreFlattening( to, blockMask, 13, blockDataRemappingTable, cachedChunk, hasSkyLight, sectionNumber -> {} ); if (full) { int[] legacyBiomeData = LegacyBiomeData.toLegacyBiomeData(biomes); for (int biomeId : legacyBiomeData) { to.writeByte(biomeRemappingTable.getRemap(biomeId)); } } }); ArraySerializer.writeVarIntTArray(chunkdata, lTo -> { int count = 0; for (Map<Position, TileEntity> sectionTiles : cachedChunk.getTiles()) { for (TileEntity tile : sectionTiles.values()) { ItemStackSerializer.writeDirectTag(lTo, tile.getNBT()); } count += sectionTiles.size(); } return count; }); codec.write(chunkdata); }
Example 20
Source File: SkinPacket.java From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 | 5 votes |
@Override public void toData(ConnectionImpl connection, ByteBuf serializer) { ProtocolVersion version = connection.getVersion(); MiscSerializer.writePEUUID(serializer, uuid); StringSerializer.writeString(serializer, version, skinId); StringSerializer.writeString(serializer, version, skinName); StringSerializer.writeString(serializer, version, previousName); ArraySerializer.writeVarIntByteArray(serializer, skinData); ArraySerializer.writeVarIntByteArray(serializer, capeData); StringSerializer.writeString(serializer, version, geometryId); StringSerializer.writeString(serializer, version, geometryData); serializer.writeBoolean(false); //premium skin }