diff --git a/Substrate/SubstrateCS/Source/BlockManager.cs b/Substrate/SubstrateCS/Source/BlockManager.cs index dcc7ce5..7c18369 100644 --- a/Substrate/SubstrateCS/Source/BlockManager.cs +++ b/Substrate/SubstrateCS/Source/BlockManager.cs @@ -28,6 +28,14 @@ namespace Substrate protected ChunkRef _cache; + private bool _autoLight; + + public bool AutoRecalcLight + { + get { return _autoLight; } + set { _autoLight = value; } + } + public BlockManager (IChunkManager cm) { _chunkMan = cm; @@ -158,7 +166,14 @@ namespace Substrate return false; } - return _cache.SetBlockID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, id); + bool autolight = _cache.AutoRecalcLight; + _cache.AutoRecalcLight = _autoLight; + + bool ret = _cache.SetBlockID(x & _chunkXMask, y & _chunkYMask, z & _chunkZMask, id); + + _cache.AutoRecalcLight = autolight; + + return ret; } public bool SetBlockData (int x, int y, int z, int data) diff --git a/Substrate/SubstrateCS/Source/Chunk.cs b/Substrate/SubstrateCS/Source/Chunk.cs index abd86f1..aac26bb 100644 --- a/Substrate/SubstrateCS/Source/Chunk.cs +++ b/Substrate/SubstrateCS/Source/Chunk.cs @@ -734,72 +734,6 @@ namespace Substrate #endregion - public void ResetBlockLight () - { - for (int i = 0; i < _blocks.Length; i++) { - BlockInfo info = BlockInfo.BlockTable[_blocks[i]]; - if (info == null) { - _blockLight[i] = 0; - } - else { - _blockLight[i] = Math.Max(info.Luminance - info.Opacity, 0); - } - } - } - - public void StepBlockLight (IChunk east, IChunk north, IChunk south, IChunk west) - { - for (int x = 0; x < XDim; x++) { - for (int z = 0; z < ZDim; z++) { - for (int y = 0; y < YDim; y++) { - int lle = NeighborLight(x, y, z - 1, east); - int lln = NeighborLight(x - 1, y, z, north); - int lls = NeighborLight(x, y, z + 1, south); - int llw = NeighborLight(x + 1, y, z, west); - int lld = NeighborLight(x, y - 1, z, null); - int llu = NeighborLight(x, y + 1, z, null); - - BlockInfo info = GetBlockInfo(x, y, z); - - int light = Math.Max(info.Luminance, 0); - light = Math.Max(light, lle - 1); - light = Math.Max(light, lln - 1); - light = Math.Max(light, lls - 1); - light = Math.Max(light, llw - 1); - light = Math.Max(light, lld - 1); - light = Math.Max(light, llu - 1); - - light = Math.Max(light - info.Opacity, 0); - - SetBlockLight(x, y, z, light); - } - } - } - } - - private int NeighborLight (int x, int y, int z, IChunk n) - { - if (y < 0 || y >= YDim) { - return 0; - } - - IChunk src = this; - if (x < 0 || x >= XDim || z < 0 || z >= ZDim) { - src = n; - x = (x + XDim) % XDim; - z = (z + ZDim) % ZDim; - } - - if (src == null) { - return 0; - } - - BlockInfo info = src.GetBlockInfo(x, y, z); - int light = src.GetBlockLight(x, y, z); - - return Math.Max(light, info.Luminance); - } - private int Timestamp () { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); diff --git a/Substrate/SubstrateCS/Source/Level.cs b/Substrate/SubstrateCS/Source/Level.cs index f6a5fc8..2f62531 100644 --- a/Substrate/SubstrateCS/Source/Level.cs +++ b/Substrate/SubstrateCS/Source/Level.cs @@ -149,6 +149,10 @@ namespace Substrate { _player = new Player(); _player.World = _name; + + _player.Position.X = _spawnX; + _player.Position.Y = _spawnY + 1.7; + _player.Position.Z = _spawnZ; } public bool Save ()