Example #1
0
        internal static McpeWrapper CreateMcpeBatch(byte[] bytes)
        {
            McpeWrapper batch = BatchUtils.CreateBatchPacket(new Memory <byte>(bytes, 0, (int)bytes.Length), CompressionLevel.Optimal, true);

            batch.MarkPermanent();
            batch.Encode();
            return(batch);
        }
Example #2
0
        internal void ClearCache()
        {
            lock (_cacheSync)
            {
                if (_cachedBatch != null)
                {
                    _cachedBatch.MarkPermanent(false);
                    _cachedBatch.PutPool();

                    _cachedBatch = null;
                }
            }
        }
Example #3
0
        public object Clone()
        {
            ChunkColumn cc = (ChunkColumn)MemberwiseClone();

            cc.chunks = new Chunk[16];
            for (int i = 0; i < chunks.Length; i++)
            {
                cc.chunks[i] = (Chunk)chunks[i].Clone();
            }

            cc.biomeId = (byte[])biomeId.Clone();
            cc.height  = (short[])height.Clone();

            cc.BlockEntities = new Dictionary <BlockCoordinates, NbtCompound>();
            foreach (KeyValuePair <BlockCoordinates, NbtCompound> blockEntityPair in BlockEntities)
            {
                cc.BlockEntities.Add(blockEntityPair.Key, (NbtCompound)blockEntityPair.Value.Clone());
            }

            if (_cache != null)
            {
                cc._cache = (byte[])_cache.Clone();
            }

            McpeWrapper batch = McpeWrapper.CreateObject();

            batch.payload = _cachedBatch.payload;
            batch.Encode();
            batch.MarkPermanent();

            cc._cachedBatch = batch;

            cc._cacheSync = new object();

            return(cc);
        }