forked from mirrors/NBTExplorer
Fixing chunks to update entity, tileentity coordinates along with chunk coordinates
This commit is contained in:
parent
08febcf6c4
commit
73ab937783
2 changed files with 28 additions and 2 deletions
|
@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("0.8.0.0")]
|
[assembly: AssemblyVersion("0.8.1.0")]
|
||||||
[assembly: AssemblyFileVersion("0.8.0.0")]
|
[assembly: AssemblyFileVersion("0.8.1.0")]
|
||||||
|
|
||||||
// This library is compatible with all CLS-compliant .NET programming languages.
|
// This library is compatible with all CLS-compliant .NET programming languages.
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
|
@ -158,11 +158,37 @@ namespace Substrate
|
||||||
/// <param name="z">Global Z-coordinate.</param>
|
/// <param name="z">Global Z-coordinate.</param>
|
||||||
public virtual void SetLocation (int x, int z)
|
public virtual void SetLocation (int x, int z)
|
||||||
{
|
{
|
||||||
|
int diffx = (x - _cx) * XDIM;
|
||||||
|
int diffz = (z - _cz) * ZDIM;
|
||||||
|
|
||||||
|
// Update chunk position
|
||||||
|
|
||||||
_cx = x;
|
_cx = x;
|
||||||
_cz = z;
|
_cz = z;
|
||||||
|
|
||||||
_tree.Root["Level"].ToTagCompound()["xPos"].ToTagInt().Data = x;
|
_tree.Root["Level"].ToTagCompound()["xPos"].ToTagInt().Data = x;
|
||||||
_tree.Root["Level"].ToTagCompound()["zPos"].ToTagInt().Data = z;
|
_tree.Root["Level"].ToTagCompound()["zPos"].ToTagInt().Data = z;
|
||||||
|
|
||||||
|
// Update tile entity coordinates
|
||||||
|
|
||||||
|
foreach (TagNodeCompound te in _tileEntities) {
|
||||||
|
if (te != null && te.ContainsKey("x") && te.ContainsKey("z")) {
|
||||||
|
te["x"].ToTagInt().Data += diffx;
|
||||||
|
te["z"].ToTagInt().Data += diffz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update entity coordinates
|
||||||
|
|
||||||
|
foreach (TagNodeCompound entity in _entities) {
|
||||||
|
if (entity != null && entity.ContainsKey("Pos")) {
|
||||||
|
TagNodeList pos = entity["Pos"].ToTagList();
|
||||||
|
if (pos != null && pos.ValueType == TagType.TAG_DOUBLE && pos.Count == 3) {
|
||||||
|
pos[0].ToTagDouble().Data += diffx;
|
||||||
|
pos[2].ToTagDouble().Data += diffz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue