From a98955530fbe75a5c30cd97050aa42d68834aa0a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 11 Aug 2024 22:01:24 -0500 Subject: [PATCH] Allow adding empty lists to DhApiChunk --- .../api/objects/data/DhApiChunk.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java index a6401da28..879fdad46 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java @@ -124,7 +124,7 @@ public class DhApiChunk throwIfRelativePosOutOfBounds(relX, relZ); // ignore empty inputs - if (dataPoints == null || dataPoints.size() == 0) + if (dataPoints == null) { return; } @@ -150,13 +150,17 @@ public class DhApiChunk // set datapoints // //================// - // DH expects datapoints to be in a top-down order - DhApiTerrainDataPoint first = dataPoints.get(0); - DhApiTerrainDataPoint last = dataPoints.get(dataPoints.size() - 1); - if (first.bottomYBlockPos < last.bottomYBlockPos) + // order doesn't need to be checked if there is 0 or 1 items + if (dataPoints.size() > 1) { - // flip the array if it's in bottom-up order - Collections.reverse(dataPoints); + // DH expects datapoints to be in a top-down order + DhApiTerrainDataPoint first = dataPoints.get(0); + DhApiTerrainDataPoint last = dataPoints.get(dataPoints.size() - 1); + if (first.bottomYBlockPos < last.bottomYBlockPos) + { + // flip the array if it's in bottom-up order + Collections.reverse(dataPoints); + } } this.dataPoints.set(internalArrayIndex, dataPoints);