From 13fecf9d1dc0c9224ba6cf49ae75a5b9a7dc6c6b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 19 Jun 2021 20:24:46 -0500 Subject: [PATCH] Add constructors and a don't save flag to LodChunk --- .../java/com/seibel/lod/objects/LodChunk.java | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/seibel/lod/objects/LodChunk.java b/src/main/java/com/seibel/lod/objects/LodChunk.java index 5b280fb51..86bd9668d 100644 --- a/src/main/java/com/seibel/lod/objects/LodChunk.java +++ b/src/main/java/com/seibel/lod/objects/LodChunk.java @@ -12,7 +12,7 @@ import net.minecraft.util.math.ChunkPos; * and color data for an LOD object. * * @author James Seibel - * @version 6-13-2021 + * @version 6-19-2021 */ public class LodChunk { @@ -28,9 +28,12 @@ public class LodChunk private static final Color DEBUG_WHITE = new Color(255, 255, 255, DEBUG_ALPHA); private static final Color INVISIBLE = new Color(0,0,0,0); - public LodDetail detail = LodDetail.SINGLE; + /** If this is set to true then toData will return + * the empty string */ + public boolean dontSave = false; + /** The x coordinate of the chunk. */ public int x = 0; @@ -46,10 +49,11 @@ public class LodChunk /** - * Create an empty invisible LodChunk at (0,0) + * Create an empty, invisible, non-saving LodChunk at (0,0) */ public LodChunk() { + dontSave = true; empty = true; x = 0; @@ -60,6 +64,28 @@ public class LodChunk dataPoints = new LodDataPoint[detail.lengthCount][detail.lengthCount]; } + /** + * Create an empty, invisible, non-saving LodChunk at the given ChunkPos + */ + public LodChunk(ChunkPos pos) + { + this(); + + x = pos.x; + z = pos.z; + } + + /** + * Create an empty, invisible, non-saving LodChunk at the given ChunkPos + */ + public LodChunk(int newX, int newZ) + { + this(); + + x = newX; + z = newZ; + } + /** * Creates an LodChunk from the string @@ -79,6 +105,8 @@ public class LodChunk * 5,8, 4, 0, 255,255,255, 4, 0, 255, 255, 255, ... */ + dontSave = false; + // make sure there are the correct number of entries // in the data string int count = 0; @@ -172,6 +200,7 @@ public class LodChunk dataPoints = newDataPoints; + dontSave = false; detail = newDetail; empty = determineIfEmtpy(); @@ -376,7 +405,8 @@ public class LodChunk /** * Outputs all data in a csv format - * with the given delimiter.

+ * with the given delimiter, if + * dontSave is false.

* * data format:
* x, z, dataPoint[0][0], dataPoint[0][1], ...
@@ -387,8 +417,10 @@ public class LodChunk */ public String toData() { - String s = ""; + if (dontSave) + return ""; + String s = ""; s += Integer.toString(x) + DATA_DELIMITER + Integer.toString(z) + DATA_DELIMITER; for (int i = 0; i < dataPoints.length; i++)