public bool HandlePacket(PacketIncomingType packetType, List <byte> packetData)
        {
            int    chunkX           = dataTypes.ReadNextInt(packetData);
            int    chunkZ           = dataTypes.ReadNextInt(packetData);
            bool   chunksContinuous = dataTypes.ReadNextBool(packetData);
            ushort chunkMask        = protocolversion >= (int)McVersion.V19
                ? (ushort)dataTypes.ReadNextVarInt(packetData)
                : dataTypes.ReadNextUShort(packetData);

            if (protocolversion < (int)McVersion.V18)
            {
                ushort addBitmap          = dataTypes.ReadNextUShort(packetData);
                int    compressedDataSize = dataTypes.ReadNextInt(packetData);
                byte[] compressed         = dataTypes.ReadData(compressedDataSize, packetData);
                byte[] decompressed       = ZlibUtils.Decompress(compressed);
                pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, worldInfo.dimension == 0, chunksContinuous, worldInfo.dimension, new List <byte>(decompressed));
            }
            else
            {
                if (protocolversion >= (int)McVersion.V114)
                {
                    dataTypes.ReadNextNbt(packetData);  // Heightmaps - 1.14 and above
                }
                int dataSize = dataTypes.ReadNextVarInt(packetData);
                pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, worldInfo.dimension, packetData);
            }

            return(true);
        }
示例#2
0
        public bool HandlePacket(PacketIncomingType packetType, List <byte> packetData)
        {
            int         chunkCount;
            bool        hasSkyLight;
            List <byte> chunkData = packetData;

            //Read global fields
            if (protocolversion < (int)McVersion.V18)
            {
                chunkCount = dataTypes.ReadNextShort(packetData);
                int compressedDataSize = dataTypes.ReadNextInt(packetData);
                hasSkyLight = dataTypes.ReadNextBool(packetData);
                byte[] compressed   = dataTypes.ReadData(compressedDataSize, packetData);
                byte[] decompressed = ZlibUtils.Decompress(compressed);
                chunkData = new List <byte>(decompressed);
            }
            else
            {
                hasSkyLight = dataTypes.ReadNextBool(packetData);
                chunkCount  = dataTypes.ReadNextVarInt(packetData);
            }

            //Read chunk records
            int[]    chunkXs    = new int[chunkCount];
            int[]    chunkZs    = new int[chunkCount];
            ushort[] chunkMasks = new ushort[chunkCount];
            ushort[] addBitmaps = new ushort[chunkCount];
            for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++)
            {
                chunkXs[chunkColumnNo]    = dataTypes.ReadNextInt(packetData);
                chunkZs[chunkColumnNo]    = dataTypes.ReadNextInt(packetData);
                chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData);
                addBitmaps[chunkColumnNo] = protocolversion < (int)McVersion.V18
                    ? dataTypes.ReadNextUShort(packetData)
                    : (ushort)0;
            }

            //Process chunk records
            for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++)
            {
                pTerrain.ProcessChunkColumnData(chunkXs[chunkColumnNo], chunkZs[chunkColumnNo], chunkMasks[chunkColumnNo], addBitmaps[chunkColumnNo], hasSkyLight, true, worldInfo.dimension, chunkData);
            }

            return(true);
        }