diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/accessor/FullDataArrayAccessor.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/accessor/FullDataArrayAccessor.java
deleted file mode 100644
index f3fff6741..000000000
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/accessor/FullDataArrayAccessor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * This file is part of the Distant Horizons mod
- * licensed under the GNU LGPL v3 License.
- *
- * Copyright (C) 2020-2023 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.distanthorizons.core.dataObjects.fullData.accessor;
-
-import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
-import com.seibel.distanthorizons.core.util.LodUtil;
-import com.seibel.distanthorizons.core.dataObjects.fullData.sources.CompleteFullDataSource;
-
-/**
- * Contains Full Data points and basic methods for getting and setting them.
- * Can be used standalone or as the base for Full data sources.
- *
- * @see CompleteFullDataSource
- */
-@Deprecated // TODO merge into FullDataSourceV1
-public class FullDataArrayAccessor
-{
- protected final FullDataPointIdMap mapping;
-
- /** A flattened 2D array (for the X and Z directions) containing an array for the Y direction. */
- protected final long[][] dataArrays;
-
- /** measured in data points */
- protected final int width;
- /** measured in data points */
- protected final int dataWidth;
-
- /** index offset used when getting/setting data in {@link FullDataArrayAccessor#dataArrays}. */
- protected final int offset;
-
-
-
- //==============//
- // constructors //
- //==============//
-
- public FullDataArrayAccessor(FullDataPointIdMap mapping, long[][] dataArrays, int width)
- {
- if (dataArrays.length != width * width)
- {
- throw new IllegalArgumentException("tried constructing dataArrayView with invalid input!");
- }
-
- this.dataArrays = dataArrays;
- this.width = width;
- this.dataWidth = width;
- this.mapping = mapping;
- this.offset = 0;
- }
-
- public FullDataArrayAccessor(FullDataArrayAccessor source, int width, int offsetX, int offsetZ)
- {
- if (source.width < width || source.width < width + offsetX || source.width < width + offsetZ)
- {
- throw new IllegalArgumentException("tried constructing dataArrayView subview with invalid input!");
- }
-
- this.dataArrays = source.dataArrays;
- this.width = width;
- this.dataWidth = source.dataWidth;
- this.mapping = source.mapping;
- this.offset = source.offset + offsetX * this.dataWidth + offsetZ;
- }
-
-
-
- //=========//
- // getters //
- //=========//
-
- public FullDataPointIdMap getMapping() { return this.mapping; }
-
- public long[] get(int index) { return this.get(index / this.width, index % this.width); }
- public long[] get(int relativeX, int relativeZ)
- {
- int dataArrayIndex = (relativeX * this.width) + relativeZ + this.offset;
- if (dataArrayIndex >= this.dataArrays.length)
- {
- LodUtil.assertNotReach(
- "FullDataArrayAccessor.get() called with a relative position that is outside the data source. \n" +
- "source width: [" + this.width + "] source offset: [" + this.offset + "]\n" +
- "given relative pos X: [" + relativeX + "] Z: [" + relativeZ + "]\n" +
- "dataArrays.length: [" + this.dataArrays.length + "] dataArrayIndex: [" + dataArrayIndex + "].");
- }
-
- return this.dataArrays[dataArrayIndex];
- }
-
-}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java
index f5841435b..8b691279b 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/CompleteFullDataSource.java
@@ -20,13 +20,12 @@
package com.seibel.distanthorizons.core.dataObjects.fullData.sources;
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep;
-import com.seibel.distanthorizons.core.dataObjects.fullData.accessor.FullDataArrayAccessor;
import com.seibel.distanthorizons.core.file.IDataSource;
import com.seibel.distanthorizons.core.level.IDhLevel;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.sql.dto.LegacyDataSourceDTO;
-import com.seibel.distanthorizons.core.util.FullDataPointUtil;
+import com.seibel.distanthorizons.core.util.FullDataPointUtilV1;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataInputStream;
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream;
@@ -41,9 +40,9 @@ import java.util.Arrays;
/**
* This data source contains every datapoint over its given {@link DhSectionPos}.
*
- * @see FullDataPointUtil // FullDataSourceV1
+ * @see FullDataPointUtilV1
*/
-public class CompleteFullDataSource extends FullDataArrayAccessor implements IDataSource
+public class CompleteFullDataSource implements IDataSource
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
@@ -52,6 +51,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
public static final int WIDTH = BitShiftUtil.powerOfTwo(SECTION_SIZE_OFFSET);
public static final byte DATA_FORMAT_VERSION = 3;
+ /** never used but should stay here. */
public static final String DATA_TYPE_NAME = "CompleteFullDataSource";
/**
@@ -63,10 +63,16 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
private static final int NO_DATA_FLAG_BYTE = 0x00000001;
+ public final FullDataPointIdMap mapping;
+ public EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.EMPTY;
+
+
+ /** A flattened 2D array (for the X and Z directions) containing an array for the Y direction. */
+ private final long[][] dataArrays;
+
private DhSectionPos sectionPos;
private boolean isEmpty = true;
- public EDhApiWorldGenerationStep worldGenStep = EDhApiWorldGenerationStep.EMPTY;
@@ -77,18 +83,11 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
public static CompleteFullDataSource createEmpty(DhSectionPos pos) { return new CompleteFullDataSource(pos); }
private CompleteFullDataSource(DhSectionPos sectionPos)
{
- super(new FullDataPointIdMap(sectionPos), new long[WIDTH * WIDTH][0], WIDTH);
+ this.dataArrays = new long[WIDTH * WIDTH][0];
+ this.mapping = new FullDataPointIdMap(sectionPos);
this.sectionPos = sectionPos;
}
- public CompleteFullDataSource(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data)
- {
- super(mapping, data, WIDTH);
- LodUtil.assertTrue(data.length == WIDTH * WIDTH);
-
- this.sectionPos = pos;
- this.isEmpty = false;
- }
@@ -132,6 +131,22 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
public boolean isEmpty() { return this.isEmpty; }
+ public long[] get(int index) { return this.get(index / WIDTH, index % WIDTH); }
+ public long[] get(int relativeX, int relativeZ)
+ {
+ int dataArrayIndex = (relativeX * WIDTH) + relativeZ;
+ if (dataArrayIndex >= this.dataArrays.length)
+ {
+ LodUtil.assertNotReach(
+ "FullDataArrayAccessor.get() called with a relative position that is outside the data source. \n" +
+ "given relative pos X: [" + relativeX + "] Z: [" + relativeZ + "]\n" +
+ "dataArrays.length: [" + this.dataArrays.length + "] dataArrayIndex: [" + dataArrayIndex + "].");
+ }
+
+ return this.dataArrays[dataArrayIndex];
+ }
+
+
//=================//
// stream handling //
@@ -145,7 +160,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
{
// clear/overwrite the old data
this.resizeDataStructuresForRepopulation(dto.pos);
- this.getMapping().clear(dto.pos);
+ this.mapping.clear(dto.pos);
// set the new data
this.populateFromStream(dto, inputStream, level);
@@ -189,7 +204,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
public void writeSourceSummaryInfo(IDhLevel level, DhDataOutputStream outputStream) throws IOException
{
outputStream.writeInt(this.getDataDetailLevel());
- outputStream.writeInt(this.width);
+ outputStream.writeInt(WIDTH);
outputStream.writeInt(level.getMinY());
outputStream.writeByte(this.worldGenStep.value);
@@ -241,9 +256,9 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
// Data array length
- for (int x = 0; x < this.width; x++)
+ for (int x = 0; x < WIDTH; x++)
{
- for (int z = 0; z < this.width; z++)
+ for (int z = 0; z < WIDTH; z++)
{
outputStream.writeInt(this.get(x, z).length);
}
@@ -253,9 +268,9 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
// Data array content (only on non-empty columns)
outputStream.writeInt(DATA_GUARD_BYTE);
- for (int x = 0; x < this.width; x++)
+ for (int x = 0; x < WIDTH; x++)
{
- for (int z = 0; z < this.width; z++)
+ for (int z = 0; z < WIDTH; z++)
{
long[] dataColumn = this.get(x, z);
if (dataColumn != null)
@@ -288,7 +303,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IDa
long[][] dataPointArrays;
- if (this.width == width) // attempt to use the existing dataArrays if possible
+ if (WIDTH == width) // attempt to use the existing dataArrays if possible
{
dataPointArrays = this.dataArrays;
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java
index 252a0b6eb..4c529157d 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java
@@ -175,7 +175,7 @@ public class NewFullDataSource implements IDataSource
byte blockLight = (byte) FullDataPointUtilV1.getBlockLight(dataPoint);
byte skyLight = (byte) FullDataPointUtilV1.getSkyLight(dataPoint);
- IBlockStateWrapper blockState = legacyData.getMapping().getBlockStateWrapper(id);
+ IBlockStateWrapper blockState = legacyData.mapping.getBlockStateWrapper(id);
if (blockState.isAir())
{
// air shouldn't have any light, otherwise down sampling will look weird
@@ -200,7 +200,7 @@ public class NewFullDataSource implements IDataSource
}
}
- NewFullDataSource newFullDataSource = NewFullDataSource.createWithData(legacyData.getSectionPos(), legacyData.getMapping(), dataPoints, columnGenerationSteps);
+ NewFullDataSource newFullDataSource = NewFullDataSource.createWithData(legacyData.getSectionPos(), legacyData.mapping, dataPoints, columnGenerationSteps);
// should only be used if debugging, this is a very expensive operation