Beispiel #1
0
 /// <summary>
 /// Sets the value of the block at the given position, relative to this chunk.
 /// </summary>
 public void SetBlock(Vector3 position, Block value)
 {
     byte y = (byte)position.Y;
     y /= 16;
     position.Y = position.Y % 16;
     Sections[y].SetBlock(position, value);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 public BlockChangePacket(Vector3 Position, Block Value)
 {
     this.Position = Position;
     this.Value = Value;
 }
Beispiel #4
0
        public void SetBlock(Vector3 position, Block value)
        {
            Chunk chunk;
            Vector3 blockPosition = FindBlockPosition(position, out chunk);

            chunk.SetBlock(blockPosition, value);

            if (OnBlockChanged != null)
                OnBlockChanged(this, new BlockChangedEventArgs(this, position, value));
        }
Beispiel #5
0
 /// <summary>
 /// Allows libraries to implement their own version
 /// of any block's logic.
 /// </summary>
 public static void OverrideBlock(Block Block)
 {
     Blocks[Block.BlockID] = Block;
 }