/// <inheritdoc/> public void SetTileEntity(int x, int y, int z, TileEntity te) { _tileEntityManager.SetTileEntity(x, y, z, te); _dirty = true; }
/// <summary> /// Sets a new Tile Entity record for the block. /// </summary> /// <param name="te">A Tile Entity record compatible with the block's type.</param> public void SetTileEntity(TileEntity te) { _collection.SetTileEntity(_index, te); }
/// <summary> /// Updates the chunk's global world coordinates. /// </summary> /// <param name="x">Global X-coordinate.</param> /// <param name="z">Global Z-coordinate.</param> public void SetLocation(int x, int z) { int diffx = (x - _cx) * XDIM; int diffz = (z - _cz) * ZDIM; // Update chunk position _cx = x; _cz = z; _tree.Root["Level"].ToTagCompound()["xPos"].ToTagInt().Data = x; _tree.Root["Level"].ToTagCompound()["zPos"].ToTagInt().Data = z; // Update tile entity coordinates List <TileEntity> tileEntites = new List <TileEntity>(); foreach (TagNodeCompound tag in _tileEntities) { TileEntity te = TileEntityFactory.Create(tag); if (te == null) { te = TileEntity.FromTreeSafe(tag); } if (te != null) { te.MoveBy(diffx, 0, diffz); tileEntites.Add(te); } } _tileEntities.Clear(); foreach (TileEntity te in tileEntites) { _tileEntities.Add(te.BuildTree()); } // Update tile tick coordinates if (_tileTicks != null) { List <TileTick> tileTicks = new List <TileTick>(); foreach (TagNodeCompound tag in _tileTicks) { TileTick tt = TileTick.FromTreeSafe(tag); if (tt != null) { tt.MoveBy(diffx, 0, diffz); tileTicks.Add(tt); } } _tileTicks.Clear(); foreach (TileTick tt in tileTicks) { _tileTicks.Add(tt.BuildTree()); } } // Update entity coordinates List <TypedEntity> entities = new List <TypedEntity>(); foreach (TypedEntity entity in _entityManager) { entity.MoveBy(diffx, 0, diffz); entities.Add(entity); } _entities.Clear(); foreach (TypedEntity entity in entities) { _entityManager.Add(entity); } }
/// <summary> /// Removes any Tile Entity currently attached to the block. /// </summary> public void ClearTileEntity() { _tileEntity = null; }