Exemplo n.º 1
0
        public BlockTileEntities(BlockTileEntities bte)
        {
            _blocks = bte._blocks;
            _tileEntities = bte._tileEntities;

            BuildTileEntityCache();
        }
Exemplo n.º 2
0
        public BlockTileEntities(XZYByteArray blocks, TagNodeList tileEntities)
        {
            _blocks = blocks;
            _tileEntities = tileEntities;

            BuildTileEntityCache();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the Chunk from an NBT tree rooted at the given TagValue node.
        /// </summary>
        /// <param name="tree">Root node of an NBT tree.</param>
        /// <returns>A reference to the current Chunk, or null if the tree is unparsable.</returns>
        public Chunk LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

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

            _tree = new NbtTree(ctree);

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

            _blocks     = new XZYByteArray(XDIM, YDIM, ZDIM, level["Blocks"] as TagNodeByteArray);
            _data       = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["Data"] as TagNodeByteArray);
            _blockLight = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["BlockLight"] as TagNodeByteArray);
            _skyLight   = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["SkyLight"] as TagNodeByteArray);
            _heightMap  = new ZXByteArray(XDIM, ZDIM, level["HeightMap"] as TagNodeByteArray);

            _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);

            return(this);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create an empty, exportable schematic of given dimensions.
        /// </summary>
        /// <param name="xdim">The length of the X-dimension in blocks.</param>
        /// <param name="ydim">The length of the Y-dimension in blocks.</param>
        /// <param name="zdim">The length of the Z-dimension in blocks.</param>
        public Schematic(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);

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

            _blockset  = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities);
            _entityset = new EntityCollection(_entities);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create an empty, exportable schematic of given dimensions.
        /// </summary>
        /// <param name="xdim">The length of the X-dimension in blocks.</param>
        /// <param name="ydim">The length of the Y-dimension in blocks.</param>
        /// <param name="zdim">The length of the Z-dimension in blocks.</param>
        public Schematic(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);

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

            _blockset = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities);
            _entityset = new EntityCollection(_entities);
        }
Exemplo n.º 6
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);

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

            Refresh();
        }
        /// <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);

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

            Refresh();
        }
Exemplo n.º 8
0
        private void BuildNBTTree()
        {
            int elements2 = XDIM * ZDIM;
            int elements3 = elements2 * YDIM;

            TagNodeByteArray blocks     = new TagNodeByteArray(new byte[elements3]);
            TagNodeByteArray data       = new TagNodeByteArray(new byte[elements3 >> 1]);
            TagNodeByteArray blocklight = new TagNodeByteArray(new byte[elements3 >> 1]);
            TagNodeByteArray skylight   = new TagNodeByteArray(new byte[elements3 >> 1]);
            TagNodeByteArray heightMap  = new TagNodeByteArray(new byte[elements2]);

            _blocks     = new XZYByteArray(XDIM, YDIM, ZDIM, blocks);
            _data       = new XZYNibbleArray(XDIM, YDIM, ZDIM, data);
            _blockLight = new XZYNibbleArray(XDIM, YDIM, ZDIM, blocklight);
            _skyLight   = new XZYNibbleArray(XDIM, YDIM, ZDIM, skylight);
            _heightMap  = new ZXByteArray(XDIM, ZDIM, heightMap);

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

            TagNodeCompound level = new TagNodeCompound();

            level.Add("Blocks", blocks);
            level.Add("Data", data);
            level.Add("SkyLight", blocklight);
            level.Add("BlockLight", skylight);
            level.Add("HeightMap", heightMap);
            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);
        }
Exemplo n.º 9
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(
            XZYByteArray blocks,
            XZYNibbleArray data,
            XZYNibbleArray blockLight,
            XZYNibbleArray skyLight,
            ZXByteArray heightMap,
            TagNodeList tileEntities)
        {
            _blocks       = blocks;
            _data         = data;
            _blockLight   = blockLight;
            _skyLight     = skyLight;
            _heightMap    = heightMap;
            _tileEntities = tileEntities;

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

            Refresh();
        }
Exemplo n.º 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(
            XZYByteArray blocks,
            XZYNibbleArray data,
            XZYNibbleArray blockLight,
            XZYNibbleArray skyLight,
            ZXByteArray heightMap,
            TagNodeList tileEntities)
        {
            _blocks = blocks;
            _data = data;
            _blockLight = blockLight;
            _skyLight = skyLight;
            _heightMap = heightMap;
            _tileEntities = tileEntities;

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

            Refresh();
        }