diff --git a/TrueCraft.Core/MathHelper.cs b/TrueCraft.Core/MathHelper.cs index b301b67..4591901 100644 --- a/TrueCraft.Core/MathHelper.cs +++ b/TrueCraft.Core/MathHelper.cs @@ -184,6 +184,16 @@ namespace TrueCraft.Core return (int)Math.Floor((double)BlockCoord / Chunk.Depth); } + public static int BlockToChunkBlockX(int BlockX) + { + return BlockX % Chunk.Width; + } + + public static int BlockToChunkBlockZ(int BlockZ) + { + return BlockZ % Chunk.Depth; + } + /// /// Returns a value indicating the most extreme value of the /// provided Vector. diff --git a/TrueCraft.Core/World/World.cs b/TrueCraft.Core/World/World.cs index 111a81b..4d47642 100644 --- a/TrueCraft.Core/World/World.cs +++ b/TrueCraft.Core/World/World.cs @@ -304,9 +304,9 @@ namespace TrueCraft.Core.World chunk = GetChunk(new Coordinates2D(chunkX, chunkZ)); return new Coordinates3D( - (coordinates.X - chunkX * Chunk.Width) % Chunk.Width, + MathHelper.BlockToChunkBlockX(coordinates.X), coordinates.Y, - (coordinates.Z - chunkZ * Chunk.Depth) % Chunk.Depth); + MathHelper.BlockToChunkBlockZ(coordinates.Z)); } public bool IsValidPosition(Coordinates3D position)