Beispiel #1
0
        private bool EnsureY(int y, out IDynBitArray bitarray, out List <NamespacedBlock> palette)
        {
            bitarray = _blockStates[y];
            if (bitarray == null)
            {
                var longs = _blockStateRaw[y];
                if (longs != null)
                {
                    palette  = _palette[y] = ToNamespacedBlockList(_paletteList[y]);
                    bitarray = _blockStates[y] = DynBitArray.CreateFromLongArray(longs);

                    _paletteList[y]   = null;
                    _blockStateRaw[y] = null;
                    return(true);
                }
                else
                {
                    bitarray = null;
                    palette  = null;
                    return(false);
                }
            }

            palette = _palette[y];
            return(true);
        }
Beispiel #2
0
        public void LongResultTest()
        {
            var longs      = new[] { 2L, -1L, 2181234892347L, 10000L };
            var dyn        = DynBitArray.CreateFromLongArray(longs, 4);
            var ordinalDyn = new DynBitArray(dyn, 4);

            Assert.AreEqual(DynBitArray.ToLongArray(ordinalDyn), longs);
        }
Beispiel #3
0
 private void ReadFromNewFormat(NbtCompound heightmaps)
 {
     for (var id = 0; id < HeightMapTypes.Length; id++)
     {
         if (heightmaps.TryGet <NbtLongArray>(HeightMapTypes[id], out var longarray))
         {
             HeightMaps[id] = DynBitArray.CreateFromLongArray(longarray.Value, 9);
         }
     }
 }
Beispiel #4
0
        internal void EnsureAllSections()
        {
            for (var sy = 0; sy < 16; sy++)
            {
                var y     = sy;
                var longs = _blockStateRaw[sy];

                if (longs == null)
                {
                    continue;
                }

                _palette[y]     = ToNamespacedBlockList(_paletteList[y]);
                _blockStates[y] = DynBitArray.CreateFromLongArray(longs);

                _paletteList[y]   = null;
                _blockStateRaw[y] = null;
            }
        }
Beispiel #5
0
        private bool EnsureY(int y)
        {
            if (_blockStates[y] == null)
            {
                var longs = _blockStateRaw[y];

                if (longs != null)
                {
                    _palette[y]     = ToNamespacedBlockList(_paletteList[y]);
                    _blockStates[y] = DynBitArray.CreateFromLongArray(longs);

                    _paletteList[y]   = null;
                    _blockStateRaw[y] = null;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #6
0
        protected override bool GetBlockData(NbtCompound section)
        {
            if (!section.TryGet(FieldY, out NbtByte nbtY))
            {
                return(false);
            }
            int y = nbtY.Value;

            if (y == 255)
            {
                return(true);
            }
            if (y >= 16)
            {
                return(false);
            }

            if (!section.TryGet(FieldPalette, out NbtList list))
            {
                return(false);
            }
            if (!section.TryGet(FieldBlockStates, out NbtLongArray blocks))
            {
                return(false);
            }

            if (SnapshotStrategy == NbtSnapshotStrategy.Enable)
            {
                _paletteList[y]   = list;
                _blockStateRaw[y] = blocks.Value;
            }
            else
            {
                _palette[y]     = ToNamespacedBlockList(list);
                _blockStates[y] = DynBitArray.CreateFromLongArray(blocks.Value);
            }

            return(true);
        }