diff --git a/NBToolkit/Dump.cs b/NBToolkit/Dump.cs index 7e56e49..3190f6b 100644 --- a/NBToolkit/Dump.cs +++ b/NBToolkit/Dump.cs @@ -96,8 +96,9 @@ namespace NBToolkit public override void Run () { - NBTWorld world = GetWorld(opt); - FilteredChunkManager fcm = new FilteredChunkManager(world.ChunkManager, opt.GetChunkFilter()); + INBTWorld world = GetWorld(opt); + IChunkManager cm = world.GetChunkManager(opt.OPT_DIM); + FilteredChunkManager fcm = new FilteredChunkManager(cm, opt.GetChunkFilter()); StreamWriter fstr; try { diff --git a/NBToolkit/GenOres.cs b/NBToolkit/GenOres.cs index e675e79..18681f7 100644 --- a/NBToolkit/GenOres.cs +++ b/NBToolkit/GenOres.cs @@ -7,7 +7,7 @@ namespace NBToolkit { public interface IGenerator { - bool Generate (BlockManager blockMan, Random rand, int x, int y, int z); + bool Generate (IBlockManager blockMan, Random rand, int x, int y, int z); } /** @@ -49,7 +49,7 @@ namespace NBToolkit } } - public bool Generate (BlockManager blockMan, Random rand, int x, int y, int z) + public bool Generate (IBlockManager blockMan, Random rand, int x, int y, int z) { float rpi = (float)(rand.NextDouble() * Math.PI); diff --git a/NBToolkit/NBToolkit.csproj b/NBToolkit/NBToolkit.csproj index afe642c..93c1d1e 100644 --- a/NBToolkit/NBToolkit.csproj +++ b/NBToolkit/NBToolkit.csproj @@ -53,8 +53,6 @@ - - diff --git a/NBToolkit/Oregen.cs b/NBToolkit/Oregen.cs index b30d25d..e82a2e3 100644 --- a/NBToolkit/Oregen.cs +++ b/NBToolkit/Oregen.cs @@ -181,8 +181,9 @@ namespace NBToolkit public override void Run () { - NBTWorld world = GetWorld(opt); - FilteredChunkManager fcm = new FilteredChunkManager(world.ChunkManager, opt.GetChunkFilter()); + INBTWorld world = GetWorld(opt); + IChunkManager cm = world.GetChunkManager(opt.OPT_DIM); + FilteredChunkManager fcm = new FilteredChunkManager(cm, opt.GetChunkFilter()); int affectedChunks = 0; foreach (ChunkRef chunk in fcm) { @@ -204,7 +205,7 @@ namespace NBToolkit Console.WriteLine("Affected Chunks: " + affectedChunks); } - public void ApplyChunk (NBTWorld world, ChunkRef chunk) + public void ApplyChunk (INBTWorld world, ChunkRef chunk) { if (opt.OPT_V) { Console.WriteLine("Generating {0} size {1} deposits of {2} between {3} and {4}", @@ -221,7 +222,8 @@ namespace NBToolkit ((NativeGenOre)generator).MathFix = opt.OPT_MATHFIX; } - BlockManager bm = new GenOreBlockManager(world.ChunkManager, opt); + IChunkManager cm = world.GetChunkManager(opt.OPT_DIM); + IBlockManager bm = new GenOreBlockManager(cm, opt); for (int i = 0; i < opt.OPT_ROUNDS; i++) { if (opt.OPT_VV) { @@ -292,84 +294,5 @@ namespace NBToolkit return false; } - /*public override BlockRef GetBlockRef (int x, int y, int z) - { - BlockRef block; - try { - block = base.GetBlockRef(x, y, z); - } - catch { - return null; - } - - if (block == null) { - return null; - } - - int blockID = block.ID; - - if ( - ((opt.OPT_OA) && (blockID != opt.OPT_ID)) || - ((opt.OPT_OO) && ( - blockID == BLOCK_COAL || blockID == BLOCK_IRON || - blockID == BLOCK_GOLD || blockID == BLOCK_REDSTONE || - blockID == BLOCK_DIAMOND || blockID == BLOCK_LAPIS || - blockID == BLOCK_DIRT || blockID == BLOCK_GRAVEL) && (blockID != opt.OPT_ID)) || - (opt.OPT_OB_INCLUDE.Count > 0) || - (blockID == BLOCK_STONE) - ) { - // If overriding list of ores, check membership - if (opt.OPT_OB_INCLUDE.Count > 0 && !opt.OPT_OB_INCLUDE.Contains(blockID)) { - return null; - } - - // Check for any excluded block - if (opt.OPT_OB_EXCLUDE.Contains(blockID)) { - return null; - } - - // We're allowed to update the block - return block; - } - - return null; - } - - public override bool SetBlockID (int x, int y, int z, int id) - { - int blockID = 0; - try { - blockID = GetBlockID(x, y, z); - } - catch { - return false; - } - - if ( - ((opt.OPT_OA) && (blockID != opt.OPT_ID)) || - ((opt.OPT_OO) && ( - blockID == BLOCK_COAL || blockID == BLOCK_IRON || - blockID == BLOCK_GOLD || blockID == BLOCK_REDSTONE || - blockID == BLOCK_DIAMOND || blockID == BLOCK_LAPIS || - blockID == BLOCK_DIRT || blockID == BLOCK_GRAVEL) && (blockID != opt.OPT_ID)) || - (opt.OPT_OB_INCLUDE.Count > 0) || - (blockID == BLOCK_STONE) - ) { - // If overriding list of ores, check membership - if (opt.OPT_OB_INCLUDE.Count > 0 && !opt.OPT_OB_INCLUDE.Contains(blockID)) { - return false; - } - - // Check for any excluded block - if (opt.OPT_OB_EXCLUDE.Contains(blockID)) { - return false; - } - - // We're allowed to update the block - return base.SetBlockID(x, y, z, id); - } - - return false; - }*/ } } diff --git a/NBToolkit/Purge.cs b/NBToolkit/Purge.cs index e5718ec..79df1e6 100644 --- a/NBToolkit/Purge.cs +++ b/NBToolkit/Purge.cs @@ -69,8 +69,9 @@ namespace NBToolkit public override void Run () { - NBTWorld world = GetWorld(opt); - FilteredChunkManager fcm = new FilteredChunkManager(world.ChunkManager, opt.GetChunkFilter()); + INBTWorld world = GetWorld(opt); + IChunkManager cm = world.GetChunkManager(opt.OPT_DIM); + FilteredChunkManager fcm = new FilteredChunkManager(cm, opt.GetChunkFilter()); int affectedChunks = 0; foreach (ChunkRef chunk in fcm) { diff --git a/NBToolkit/Replace.cs b/NBToolkit/Replace.cs index 759f702..5e39660 100644 --- a/NBToolkit/Replace.cs +++ b/NBToolkit/Replace.cs @@ -149,8 +149,9 @@ namespace NBToolkit public override void Run () { - NBTWorld world = GetWorld(opt); - FilteredChunkManager fcm = new FilteredChunkManager(world.ChunkManager, opt.GetChunkFilter()); + INBTWorld world = GetWorld(opt); + IChunkManager cm = world.GetChunkManager(opt.OPT_DIM); + FilteredChunkManager fcm = new FilteredChunkManager(cm, opt.GetChunkFilter()); int affectedChunks = 0; foreach (ChunkRef chunk in fcm) { @@ -164,7 +165,7 @@ namespace NBToolkit Console.WriteLine("Affected Chunks: " + affectedChunks); } - public void ApplyChunk (World world, ChunkRef chunk) + public void ApplyChunk (INBTWorld world, ChunkRef chunk) { int xBase = chunk.X * chunk.XDim; int zBase = chunk.Z * chunk.ZDim; @@ -242,7 +243,8 @@ namespace NBToolkit chunk.SetBlockID(lx, ly, lz, (int)opt.OPT_AFTER); if (opt.OPT_VV) { - Console.WriteLine("Replaced block at {0},{1},{2}", lx, ly, lz); + Console.WriteLine("Replaced block at {0},{1},{2}", + chunk.BlockGlobalX(lx), chunk.BlockGlobalY(ly), chunk.BlockGlobalZ(lz)); } if (opt.OPT_DATA != null) { diff --git a/NBToolkit/TKFilter.cs b/NBToolkit/TKFilter.cs index 90293a7..41a5775 100644 --- a/NBToolkit/TKFilter.cs +++ b/NBToolkit/TKFilter.cs @@ -11,15 +11,15 @@ namespace NBToolkit public abstract void Run (); - public NBTWorld GetWorld (TKOptions opt) + public INBTWorld GetWorld (TKOptions opt) { - NBTWorld world = null; + INBTWorld world = null; try { if (opt.OPT_ALPHA) { - world = new AlphaWorld(opt.OPT_WORLD, opt.OPT_DIM); + world = AlphaWorld.Open(opt.OPT_WORLD); } else { - world = new BetaWorld(opt.OPT_WORLD, opt.OPT_REGION, opt.OPT_DIM); + world = BetaWorld.Open(opt.OPT_WORLD); } } catch (Exception ex) { diff --git a/NBToolkit/TKOptions.cs b/NBToolkit/TKOptions.cs index 5361e48..a2f495e 100644 --- a/NBToolkit/TKOptions.cs +++ b/NBToolkit/TKOptions.cs @@ -17,8 +17,7 @@ namespace NBToolkit private OptionSet commonOpt = null; public string OPT_WORLD = ""; - public string OPT_REGION = "region"; - public string OPT_DIM = ""; + public int OPT_DIM = 0; // Verbosity public bool OPT_V = false; @@ -37,9 +36,7 @@ namespace NBToolkit { "alpha", "Specify that the world is stored as individual chunk files", v => OPT_ALPHA = true }, { "nether", "Update the Nether instead of the main region", - v => OPT_DIM = "DIM-1" }, - { "region", "Specify the name of the region directory", - v => OPT_REGION = v }, + v => OPT_DIM = -1 }, { "v", "Verbose output", v => OPT_V = true }, { "vv", "Very verbose output",