diff --git a/SubstrateCS/Source/AlphaWorld.cs b/SubstrateCS/Source/AlphaWorld.cs index 577d06f..9599b42 100644 --- a/SubstrateCS/Source/AlphaWorld.cs +++ b/SubstrateCS/Source/AlphaWorld.cs @@ -175,7 +175,7 @@ namespace Substrate } AlphaChunkManager cm = new AlphaChunkManager(path); - BlockManager bm = new BlockManager(cm); + BlockManager bm = new AlphaBlockManager(cm); _chunkMgrs[dim] = cm; _blockMgrs[dim] = bm; diff --git a/SubstrateCS/Source/AnvilWorld.cs b/SubstrateCS/Source/AnvilWorld.cs index 04a015e..e59b024 100644 --- a/SubstrateCS/Source/AnvilWorld.cs +++ b/SubstrateCS/Source/AnvilWorld.cs @@ -295,7 +295,7 @@ namespace Substrate AnvilRegionManager rm = new AnvilRegionManager(path, cc); RegionChunkManager cm = new RegionChunkManager(rm, cc); - BlockManager bm = new BlockManager(cm); + BlockManager bm = new AnvilBlockManager(cm); _regionMgrs[dim] = rm; _chunkMgrs[dim] = cm; diff --git a/SubstrateCS/Source/BetaWorld.cs b/SubstrateCS/Source/BetaWorld.cs index ec30ecb..bde0bd1 100644 --- a/SubstrateCS/Source/BetaWorld.cs +++ b/SubstrateCS/Source/BetaWorld.cs @@ -295,7 +295,7 @@ namespace Substrate BetaRegionManager rm = new BetaRegionManager(path, cc); RegionChunkManager cm = new RegionChunkManager(rm, cc); - BlockManager bm = new BlockManager(cm); + BlockManager bm = new AlphaBlockManager(cm); _regionMgrs[dim] = rm; _chunkMgrs[dim] = cm; diff --git a/SubstrateCS/Source/BlockManager.cs b/SubstrateCS/Source/BlockManager.cs index a10eecd..ac128cf 100644 --- a/SubstrateCS/Source/BlockManager.cs +++ b/SubstrateCS/Source/BlockManager.cs @@ -3,10 +3,48 @@ using Substrate.Core; namespace Substrate { + public class AlphaBlockManager : BlockManager + { + public AlphaBlockManager (IChunkManager cm) + : base(cm) + { + IChunk c = AlphaChunk.Create(0, 0); + + chunkXDim = c.Blocks.XDim; + chunkYDim = c.Blocks.YDim; + chunkZDim = c.Blocks.ZDim; + chunkXMask = chunkXDim - 1; + chunkYMask = chunkYDim - 1; + chunkZMask = chunkZDim - 1; + chunkXLog = Log2(chunkXDim); + chunkYLog = Log2(chunkYDim); + chunkZLog = Log2(chunkZDim); + } + } + + public class AnvilBlockManager : BlockManager + { + public AnvilBlockManager (IChunkManager cm) + : base(cm) + { + IChunk c = AnvilChunk.Create(0, 0); + + chunkXDim = c.Blocks.XDim; + chunkYDim = c.Blocks.YDim; + chunkZDim = c.Blocks.ZDim; + chunkXMask = chunkXDim - 1; + chunkYMask = chunkYDim - 1; + chunkZMask = chunkZDim - 1; + chunkXLog = Log2(chunkXDim); + chunkYLog = Log2(chunkYDim); + chunkZLog = Log2(chunkZDim); + } + } + /// /// Represents an Alpha-compatible interface for globally managing blocks. /// - public class BlockManager : IVersion10BlockManager, IBlockManager + public abstract class BlockManager : IVersion10BlockManager, IBlockManager { public const int MIN_X = -32000000; public const int MAX_X = 32000000; @@ -67,18 +105,6 @@ namespace Substrate public BlockManager (IChunkManager cm) { chunkMan = cm; - - IChunk c = AlphaChunk.Create(0, 0); - - chunkXDim = c.Blocks.XDim; - chunkYDim = c.Blocks.YDim; - chunkZDim = c.Blocks.ZDim; - chunkXMask = chunkXDim - 1; - chunkYMask = chunkYDim - 1; - chunkZMask = chunkZDim - 1; - chunkXLog = Log2(chunkXDim); - chunkYLog = Log2(chunkYDim); - chunkZLog = Log2(chunkZDim); } /// @@ -151,7 +177,7 @@ namespace Substrate return chunkMan.GetChunkRef(x, z); } - private int Log2 (int x) + protected int Log2 (int x) { int c = 0; while (x > 1) {