mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
Add absolute world chunk coordinate to chunk names.
This commit is contained in:
parent
975c11d3d8
commit
1fd6ec2680
3 changed files with 30 additions and 2 deletions
|
@ -1,9 +1,13 @@
|
||||||
using Substrate.Core;
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Substrate.Core;
|
||||||
|
|
||||||
namespace NBTExplorer.Model
|
namespace NBTExplorer.Model
|
||||||
{
|
{
|
||||||
public class CubicRegionFile : RegionFile
|
public class CubicRegionFile : RegionFile
|
||||||
{
|
{
|
||||||
|
private static Regex _namePattern = new Regex("r2\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mc[ar]$");
|
||||||
|
|
||||||
private const int _sectorBytes = 256;
|
private const int _sectorBytes = 256;
|
||||||
private static byte[] _emptySector = new byte[_sectorBytes];
|
private static byte[] _emptySector = new byte[_sectorBytes];
|
||||||
|
|
||||||
|
@ -20,5 +24,21 @@ namespace NBTExplorer.Model
|
||||||
{
|
{
|
||||||
get { return _emptySector; }
|
get { return _emptySector; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override RegionKey parseCoordinatesFromName ()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
int z = 0;
|
||||||
|
|
||||||
|
Match match = _namePattern.Match(fileName);
|
||||||
|
if (!match.Success) {
|
||||||
|
return RegionKey.InvalidRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = Convert.ToInt32(match.Groups[1].Value);
|
||||||
|
z = Convert.ToInt32(match.Groups[3].Value);
|
||||||
|
|
||||||
|
return new RegionKey(x, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,15 @@ namespace NBTExplorer.Model
|
||||||
|
|
||||||
public override string NodeDisplay
|
public override string NodeDisplay
|
||||||
{
|
{
|
||||||
get { return "Chunk [" + _x + ", " + _z + "]"; }
|
get
|
||||||
|
{
|
||||||
|
RegionKey key = _regionFile.parseCoordinatesFromName();
|
||||||
|
string absChunk = "";
|
||||||
|
if (key != RegionKey.InvalidRegion)
|
||||||
|
absChunk = " in world at (" + (key.X * 32 + _x) + ", " + (key.Z * 32 + _z) + ")";
|
||||||
|
|
||||||
|
return "Chunk [" + _x + ", " + _z + "]" + absChunk;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ExpandCore ()
|
protected override void ExpandCore ()
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue