diff --git a/SubstrateCS/Properties/AssemblyInfo.cs b/SubstrateCS/Properties/AssemblyInfo.cs index 94b4191..0df902e 100644 --- a/SubstrateCS/Properties/AssemblyInfo.cs +++ b/SubstrateCS/Properties/AssemblyInfo.cs @@ -30,8 +30,8 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.8.0.0")] -[assembly: AssemblyFileVersion("0.8.0.0")] +[assembly: AssemblyVersion("0.8.1.0")] +[assembly: AssemblyFileVersion("0.8.1.0")] // This library is compatible with all CLS-compliant .NET programming languages. [assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/SubstrateCS/Source/Chunk.cs b/SubstrateCS/Source/Chunk.cs index 59a3bbf..eb59eda 100644 --- a/SubstrateCS/Source/Chunk.cs +++ b/SubstrateCS/Source/Chunk.cs @@ -158,11 +158,37 @@ namespace Substrate /// Global Z-coordinate. public virtual void SetLocation (int x, int z) { + int diffx = (x - _cx) * XDIM; + int diffz = (z - _cz) * ZDIM; + + // Update chunk position + _cx = x; _cz = z; _tree.Root["Level"].ToTagCompound()["xPos"].ToTagInt().Data = x; _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; + } + } + } } ///