/// <summary> /// Überschreibt den Block an der angegebenen Koordinate. /// </summary> /// <param name="x">X-Anteil der Koordinate des Blocks innerhalb des Chunks</param> /// <param name="y">Y-Anteil der Koordinate des Blocks innerhalb des Chunks</param> /// <param name="z">Z-Anteil der Koordinate des Blocks innerhalb des Chunks</param> /// <param name="block">Die neue Block-ID</param> public void SetBlock(int x, int y, int z, ushort block) { IChunk chunk = GetChunk(x >> Chunk.LimitX, y >> Chunk.LimitY, z >> Chunk.LimitZ); if (chunk != null) chunk.SetBlock(x, y, z, block); }
public void Load(string worldName) { if (_isLoaded) { throw new InvalidOperationException("Maps have been already loded."); } string worldPath = Path.Combine(MapPath, worldName); DirectoryUtilities.CreateDirectoryIfNotExist(MapPath); DirectoryUtilities.CreateDirectoryIfNotExist(worldPath); Overworld = new WorldMap("minecraft:overworld", _serviceProvider); Overworld.StartUpdate(); // DEBUG IRegion region = Overworld.AddRegion(0, 0); IChunk chunk = region.AddChunk(0, 0); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { chunk.SetBlock(BlockType.Dirt, x, 0, z); } } _isLoaded = true; Name = worldName; }
public bool SetBlock(int x, int y, int z, BlockSet data) { IChunk chunk = _chunkCache.GetChunk(new ChunkCoord(x >> 4, z >> 4)); bool r = chunk.SetBlock(x & 15, y, z & 15, data); chunk.IsModified = true; RelightCheck(); return(r); }
public void Generate(ChunkPosition position, IChunk chunk, Random random) { for (var x = 0; x < Minecraft.Units.Chunk.Size; x++) { for (var z = 0; z < Minecraft.Units.Chunk.Size; z++) { chunk.SetBlock(x, 0, z, _blockState); } } }
public IBlock SetBlock(BlockType blockType, int x, int y, int z) { var chunkX = x / Chunk.Size; var chunkZ = z / Chunk.Size; IChunk chunk = GetChunk(chunkX, chunkZ); if (chunk is null) { throw new InvalidOperationException($"Cannot find chunk at position: X={chunkX};Z={chunkZ}"); } return(chunk.SetBlock(blockType, x % Chunk.Size, y, z % Chunk.Size)); }