From 719a9693103b6604041d7e615784bdc4b360eb40 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 10 Nov 2012 12:11:43 -0500 Subject: [PATCH] Fixed bug where empty chunks below the heightmap were not written. --- SubstrateCS/Source/AnvilChunk.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SubstrateCS/Source/AnvilChunk.cs b/SubstrateCS/Source/AnvilChunk.cs index 9ff47e0..f0971f5 100644 --- a/SubstrateCS/Source/AnvilChunk.cs +++ b/SubstrateCS/Source/AnvilChunk.cs @@ -304,6 +304,16 @@ namespace Substrate return LoadTree(tree); } + private bool ShouldIncludeSection (AnvilSection section) + { + int y = (section.Y + 1) * section.Blocks.YDim; + for (int i = 0; i < _heightMap.Length; i++) + if (_heightMap[i] > y) + return true; + + return !section.CheckEmpty(); + } + public TagNode BuildTree () { TagNodeCompound level = _tree.Root["Level"] as TagNodeCompound; @@ -313,7 +323,7 @@ namespace Substrate TagNodeList sections = new TagNodeList(TagType.TAG_COMPOUND); for (int i = 0; i < _sections.Length; i++) - if (!_sections[i].CheckEmpty()) + if (ShouldIncludeSection(_sections[i])) sections.Add(_sections[i].BuildTree()); levelCopy["Sections"] = sections;