/// <summary> /// Sets the value of the block at the given position, relative to this chunk. /// </summary> public void SetBlock(Vector3 position, Block value) { var y = (byte)position.Y; y /= 16; position.Y = position.Y % 16; Sections[y].SetBlock(position, value); var heightIndex = (byte)(position.Z * Depth) + (byte)position.X; if (HeightMap[heightIndex] < position.Y) HeightMap[heightIndex] = (byte)position.Y; IsModified = true; }
/// <summary> /// Sets the value of the block at the given position, relative to this chunk. /// </summary> public void SetBlock(Vector3 position, Block value) { var y = GetSectionNumber(position.Y); position.Y = GetPositionInSection(position.Y); Sections[y].SetBlock(position, value); var heightIndex = (byte)(position.Z * Depth) + (byte)position.X; if (HeightMap[heightIndex] < position.Y) HeightMap[heightIndex] = (byte)position.Y; if (TileEntities.ContainsKey(position) && value.TileEntity == null) TileEntities.Remove(position); if (value.TileEntity != null) TileEntities[position] = value.TileEntity; IsModified = true; }
/// <summary> /// Sets the block at the given local position. /// </summary> public void SetBlock(Vector3 position, Block value) { position = position.Floor(); Vector3 relativePosition = position; position.X = (int)(position.X) / Chunk.Width; position.Y = 0; position.Z = (int)(position.Z) / Chunk.Depth; relativePosition.X = (int)(relativePosition.X) % Chunk.Width; relativePosition.Z = (int)(relativePosition.Z) % Chunk.Depth; if (!Chunks.ContainsKey(position)) Chunks.Add(position, WorldGenerator.GenerateChunk(position, this)); Chunks[position].SetBlock(relativePosition, value); }
public BlockChangePacket(Vector3 position, Block value) { this.Position = position; this.Value = value; }
/// <summary> /// Sets the block at the specified position. /// </summary> public void SetBlock(Vector3 position, Block value) { Chunk chunk; Vector3 blockPosition = FindBlockPosition(position, out chunk); chunk.SetBlock(blockPosition, value); if (BlockChanged != null) BlockChanged(this, new BlockChangedEventArgs(this, position, value)); DoBlockUpdates(position); }
/// <summary> /// Creates a new instance of <see cref="Craft.Net.Data.BlockChangedEventArgs"/>. /// </summary> /// <param name="world">The world the changed occurs in.</param> /// <param name="position">The position of the change.</param> /// <param name="value">The new block.</param> public BlockChangedEventArgs(World world, Vector3 position, Block value) { this.World = world; this.Position = position; this.Value = value; }