Example #1
0
        public BlockTileTicks(BlockTileTicks bte)
        {
            _blocks = bte._blocks;
            _tileTicks = bte._tileTicks;

            BuildTileTickCache();
        }
Example #2
0
        public BlockTileTicks(IDataArray3 blocks, TagNodeList tileTicks)
        {
            _blocks    = blocks;
            _tileTicks = tileTicks;

            BuildTileTickCache();
        }
Example #3
0
        public BlockTileEntities(IDataArray3 blocks, TagNodeList tileEntities)
        {
            _blocks       = blocks;
            _tileEntities = tileEntities;

            BuildTileEntityCache();
        }
Example #4
0
        public BlockTileTicks(BlockTileTicks bte)
        {
            _blocks    = bte._blocks;
            _tileTicks = bte._tileTicks;

            BuildTileTickCache();
        }
Example #5
0
        public BlockTileEntities(IDataArray3 blocks, TagNodeList tileEntities)
        {
            _blocks = blocks;
            _tileEntities = tileEntities;

            BuildTileEntityCache();
        }
Example #6
0
        public BlockTileTicks(IDataArray3 blocks, TagNodeList tileTicks)
        {
            _blocks = blocks;
            _tileTicks = tileTicks;

            BuildTileTickCache();
        }
Example #7
0
        public BlockTileEntities(BlockTileEntities bte)
        {
            _blocks = bte._blocks;
            _tileEntities = bte._tileEntities;

            BuildTileEntityCache();
        }
Example #8
0
        /// <summary>
        /// Creates a new <see cref="AlphaBlockCollection"/> overlay on top of Alpha-specific units of data.
        /// </summary>
        /// <param name="blocks">An array of Block IDs.</param>
        /// <param name="data">An array of data nibbles.</param>
        /// <param name="blockLight">An array of block light nibbles.</param>
        /// <param name="skyLight">An array of sky light nibbles.</param>
        /// <param name="heightMap">An array of height map values.</param>
        /// <param name="tileEntities">A list of tile entities corresponding to blocks in this collection.</param>
        /// <param name="tileTicks">A list of tile ticks corresponding to blocks in this collection.</param>
        public AlphaBlockCollection(
            IDataArray3 blocks,
            IDataArray3 data,
            IDataArray3 blockLight,
            IDataArray3 skyLight,
            IDataArray2 heightMap,
            TagNodeList tileEntities,
            TagNodeList tileTicks)
        {
            _blocks       = blocks;
            _data         = data;
            _blockLight   = blockLight;
            _skyLight     = skyLight;
            _heightMap    = heightMap;
            _tileEntities = tileEntities;
            _tileTicks    = tileTicks;

            if (_tileTicks == null)
            {
                _tileTicks = new TagNodeList(TagType.TAG_COMPOUND);
            }

            _xdim = _blocks.XDim;
            _ydim = _blocks.YDim;
            _zdim = _blocks.ZDim;

            Refresh();
        }
Example #9
0
        public BlockTileEntities(BlockTileEntities bte)
        {
            _blocks       = bte._blocks;
            _tileEntities = bte._tileEntities;

            BuildTileEntityCache();
        }
Example #10
0
 /// <summary>
 /// Creates a new <see cref="AlphaBlockCollection"/> overlay on top of Alpha-specific units of data.
 /// </summary>
 /// <param name="blocks">An array of Block IDs.</param>
 /// <param name="data">An array of data nibbles.</param>
 /// <param name="blockLight">An array of block light nibbles.</param>
 /// <param name="skyLight">An array of sky light nibbles.</param>
 /// <param name="heightMap">An array of height map values.</param>
 /// <param name="tileEntities">A list of tile entities corresponding to blocks in this collection.</param>
 public AlphaBlockCollection(
     IDataArray3 blocks,
     IDataArray3 data,
     IDataArray3 blockLight,
     IDataArray3 skyLight,
     IDataArray2 heightMap,
     TagNodeList tileEntities)
     : this(blocks, data, blockLight, skyLight, heightMap, tileEntities, null)
 {
 }
Example #11
0
 /// <summary>
 /// Creates a new <see cref="AlphaBlockCollection"/> overlay on top of Alpha-specific units of data.
 /// </summary>
 /// <param name="blocks">An array of Block IDs.</param>
 /// <param name="data">An array of data nibbles.</param>
 /// <param name="blockLight">An array of block light nibbles.</param>
 /// <param name="skyLight">An array of sky light nibbles.</param>
 /// <param name="heightMap">An array of height map values.</param>
 /// <param name="tileEntities">A list of tile entities corresponding to blocks in this collection.</param>
 public AlphaBlockCollection(
     IDataArray3 blocks,
     IDataArray3 data,
     IDataArray3 blockLight,
     IDataArray3 skyLight,
     IDataArray2 heightMap,
     TagNodeList tileEntities)
     : this(blocks, data, blockLight, skyLight, heightMap, tileEntities, null)
 {
 }
Example #12
0
        public FusedDataArray3 (IDataArray3 array0, IDataArray3 array1)
        {
            if (array0 == null || array1 == null)
                throw new ArgumentException("arguments cannot be null");

            if (array0.XDim != array1.XDim || array0.YDim != array1.YDim || array0.ZDim != array1.ZDim)
                throw new ArgumentException("array0 and array1 must have matching dimensions");

            _array0 = array0;
            _array1 = array1;

            _mask1 = (1 << _array1.DataWidth) - 1;
        }
Example #13
0
        public CompositeDataArray3(IDataArray3[] sections)
        {
            for (int i = 0; i < sections.Length; i++)
                if (sections[i] == null)
                    throw new ArgumentException("sections argument cannot have null entries.");

            for (int i = 0; i < sections.Length; i++) {
                if (sections[i].Length != sections[0].Length
                    || sections[i].XDim != sections[0].XDim
                    || sections[i].YDim != sections[0].YDim
                    || sections[i].ZDim != sections[0].ZDim)
                    throw new ArgumentException("All elements in sections argument must have same metrics.");
            }

            _sections = sections;
        }
Example #14
0
        /// <summary>
        /// Creates a new <see cref="AlphaBlockCollection"/> of a given dimension.
        /// </summary>
        /// <param name="xdim">The length of the X-dimension of the collection.</param>
        /// <param name="ydim">The length of the Y-dimension of the collection.</param>
        /// <param name="zdim">The length of the Z-dimension of the collection.</param>
        public AlphaBlockCollection(int xdim, int ydim, int zdim)
        {
            _blocks       = new XZYByteArray(xdim, ydim, zdim);
            _data         = new XZYNibbleArray(xdim, ydim, zdim);
            _blockLight   = new XZYNibbleArray(xdim, ydim, zdim);
            _skyLight     = new XZYNibbleArray(xdim, ydim, zdim);
            _heightMap    = new ZXByteArray(xdim, zdim);
            _tileEntities = new TagNodeList(TagType.TAG_COMPOUND);
            _tileTicks    = new TagNodeList(TagType.TAG_COMPOUND);

            _xdim = xdim;
            _ydim = ydim;
            _zdim = zdim;

            Refresh();
        }
Example #15
0
        public AlphaBlockCollection(int xdim, int ydim, int zdim)
        {
            _blocks = new XZYByteArray(xdim, ydim, zdim);
            _data = new XZYNibbleArray(xdim, ydim, zdim);
            _blockLight = new XZYNibbleArray(xdim, ydim, zdim);
            _skyLight = new XZYNibbleArray(xdim, ydim, zdim);
            _heightMap = new ZXByteArray(xdim, zdim);
            _tileEntities = new TagNodeList(TagType.TAG_COMPOUND);
            _tileTicks = new TagNodeList(TagType.TAG_COMPOUND);

            _xdim = xdim;
            _ydim = ydim;
            _zdim = zdim;

            Refresh();
        }
Example #16
0
        public FusedDataArray3(IDataArray3 array0, IDataArray3 array1)
        {
            if (array0 == null || array1 == null)
            {
                throw new ArgumentException("arguments cannot be null");
            }

            if (array0.XDim != array1.XDim || array0.YDim != array1.YDim || array0.ZDim != array1.ZDim)
            {
                throw new ArgumentException("array0 and array1 must have matching dimensions");
            }

            _array0 = array0;
            _array1 = array1;

            _mask1 = (1 << _array1.DataWidth) - 1;
        }
Example #17
0
        /// <summary>
        /// Creates a new <see cref="AlphaBlockCollection"/> overlay on top of Alpha-specific units of data.
        /// </summary>
        /// <param name="blocks">An array of Block IDs.</param>
        /// <param name="data">An array of data nibbles.</param>
        /// <param name="blockLight">An array of block light nibbles.</param>
        /// <param name="skyLight">An array of sky light nibbles.</param>
        /// <param name="heightMap">An array of height map values.</param>
        /// <param name="tileEntities">A list of tile entities corresponding to blocks in this collection.</param>
        /// <param name="tileTicks">A list of tile ticks corresponding to blocks in this collection.</param>
        public AlphaBlockCollection(
            IDataArray3 blocks,
            IDataArray3 data,
            IDataArray3 blockLight,
            IDataArray3 skyLight,
            IDataArray2 heightMap,
            TagNodeList tileEntities,
            TagNodeList tileTicks)
        {
            _blocks = blocks;
            _data = data;
            _blockLight = blockLight;
            _skyLight = skyLight;
            _heightMap = heightMap;
            _tileEntities = tileEntities;
            _tileTicks = tileTicks;

            if (_tileTicks == null)
                _tileTicks = new TagNodeList(TagType.TAG_COMPOUND);

            _xdim = _blocks.XDim;
            _ydim = _blocks.YDim;
            _zdim = _blocks.ZDim;

            Refresh();
        }
Example #18
0
        public AnvilChunk LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            _tree = new NbtTree(ctree);

            TagNodeCompound level = _tree.Root["Level"] as TagNodeCompound;

            TagNodeList sections = level["Sections"] as TagNodeList;

            foreach (TagNodeCompound section in sections)
            {
                AnvilSection anvilSection = new AnvilSection(section);
                if (anvilSection.Y < 0 || anvilSection.Y >= _sections.Length)
                {
                    continue;
                }
                _sections[anvilSection.Y] = anvilSection;
            }

            FusedDataArray3[] blocksBA     = new FusedDataArray3[_sections.Length];
            YZXNibbleArray[]  dataBA       = new YZXNibbleArray[_sections.Length];
            YZXNibbleArray[]  skyLightBA   = new YZXNibbleArray[_sections.Length];
            YZXNibbleArray[]  blockLightBA = new YZXNibbleArray[_sections.Length];

            for (int i = 0; i < _sections.Length; i++)
            {
                if (_sections[i] == null)
                {
                    _sections[i] = new AnvilSection(i);
                }

                blocksBA[i]     = new FusedDataArray3(_sections[i].AddBlocks, _sections[i].Blocks);
                dataBA[i]       = _sections[i].Data;
                skyLightBA[i]   = _sections[i].SkyLight;
                blockLightBA[i] = _sections[i].BlockLight;
            }

            _blocks     = new CompositeDataArray3(blocksBA);
            _data       = new CompositeDataArray3(dataBA);
            _skyLight   = new CompositeDataArray3(skyLightBA);
            _blockLight = new CompositeDataArray3(blockLightBA);

            _heightMap = new ZXIntArray(XDIM, ZDIM, level["HeightMap"] as TagNodeIntArray);

            if (level.ContainsKey("Biomes"))
            {
                _biomes = new ZXByteArray(XDIM, ZDIM, level["Biomes"] as TagNodeByteArray);
            }
            else
            {
                level["Biomes"] = new TagNodeByteArray(new byte[256]);
                _biomes         = new ZXByteArray(XDIM, ZDIM, level["Biomes"] as TagNodeByteArray);
                for (int x = 0; x < XDIM; x++)
                {
                    for (int z = 0; z < ZDIM; z++)
                    {
                        _biomes[x, z] = BiomeType.Default;
                    }
                }
            }

            _entities     = level["Entities"] as TagNodeList;
            _tileEntities = level["TileEntities"] as TagNodeList;

            if (level.ContainsKey("TileTicks"))
            {
                _tileTicks = level["TileTicks"] as TagNodeList;
            }
            else
            {
                _tileTicks = new TagNodeList(TagType.TAG_COMPOUND);
            }

            // List-type patch up
            if (_entities.Count == 0)
            {
                level["Entities"] = new TagNodeList(TagType.TAG_COMPOUND);
                _entities         = level["Entities"] as TagNodeList;
            }

            if (_tileEntities.Count == 0)
            {
                level["TileEntities"] = new TagNodeList(TagType.TAG_COMPOUND);
                _tileEntities         = level["TileEntities"] as TagNodeList;
            }

            if (_tileTicks.Count == 0)
            {
                level["TileTicks"] = new TagNodeList(TagType.TAG_COMPOUND);
                _tileTicks         = level["TileTicks"] as TagNodeList;
            }

            _cx = level["xPos"].ToTagInt();
            _cz = level["zPos"].ToTagInt();

            _blockManager  = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities, _tileTicks);
            _entityManager = new EntityCollection(_entities);
            _biomeManager  = new AnvilBiomeCollection(_biomes);

            return(this);
        }
Example #19
0
        private void BuildNBTTree()
        {
            int elements2 = XDIM * ZDIM;

            _sections = new AnvilSection[16];
            TagNodeList sections = new TagNodeList(TagType.TAG_COMPOUND);

            for (int i = 0; i < _sections.Length; i++)
            {
                _sections[i] = new AnvilSection(i);
                sections.Add(_sections[i].BuildTree());
            }

            FusedDataArray3[] blocksBA     = new FusedDataArray3[_sections.Length];
            YZXNibbleArray[]  dataBA       = new YZXNibbleArray[_sections.Length];
            YZXNibbleArray[]  skyLightBA   = new YZXNibbleArray[_sections.Length];
            YZXNibbleArray[]  blockLightBA = new YZXNibbleArray[_sections.Length];

            for (int i = 0; i < _sections.Length; i++)
            {
                blocksBA[i]     = new FusedDataArray3(_sections[i].AddBlocks, _sections[i].Blocks);
                dataBA[i]       = _sections[i].Data;
                skyLightBA[i]   = _sections[i].SkyLight;
                blockLightBA[i] = _sections[i].BlockLight;
            }

            _blocks     = new CompositeDataArray3(blocksBA);
            _data       = new CompositeDataArray3(dataBA);
            _skyLight   = new CompositeDataArray3(skyLightBA);
            _blockLight = new CompositeDataArray3(blockLightBA);

            TagNodeIntArray heightMap = new TagNodeIntArray(new int[elements2]);

            _heightMap = new ZXIntArray(XDIM, ZDIM, heightMap);

            TagNodeByteArray biomes = new TagNodeByteArray(new byte[elements2]);

            _biomes = new ZXByteArray(XDIM, ZDIM, biomes);
            for (int x = 0; x < XDIM; x++)
            {
                for (int z = 0; z < ZDIM; z++)
                {
                    _biomes[x, z] = BiomeType.Default;
                }
            }

            _entities     = new TagNodeList(TagType.TAG_COMPOUND);
            _tileEntities = new TagNodeList(TagType.TAG_COMPOUND);
            _tileTicks    = new TagNodeList(TagType.TAG_COMPOUND);

            TagNodeCompound level = new TagNodeCompound();

            level.Add("Sections", sections);
            level.Add("HeightMap", heightMap);
            level.Add("Biomes", biomes);
            level.Add("Entities", _entities);
            level.Add("TileEntities", _tileEntities);
            level.Add("TileTicks", _tileTicks);
            level.Add("LastUpdate", new TagNodeLong(Timestamp()));
            level.Add("xPos", new TagNodeInt(_cx));
            level.Add("zPos", new TagNodeInt(_cz));
            level.Add("TerrainPopulated", new TagNodeByte());

            _tree = new NbtTree();
            _tree.Root.Add("Level", level);

            _blockManager  = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities);
            _entityManager = new EntityCollection(_entities);
        }