Require a ILevelWrapper when deserializing BlockStateWrappers
This commit is contained in:
+3
-3
@@ -85,9 +85,9 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
|
||||
* Please run your generator in game at least once to confirm the objects you are returning are correct. <br><br>
|
||||
*
|
||||
* Consumer expected inputs for each minecraft version (in order): <br>
|
||||
* <strong>1.18:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
* <strong>1.19:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
* <strong>1.20:</strong> [net.minecraft.world.level.chunk.ChunkAccess] and [net.minecraft.world.level.LevelReader] <br>
|
||||
* <strong>1.16</strong>, <strong>1.17</strong>, <strong>1.18</strong>, <strong>1.19</strong>, <strong>1.20</strong>: <br>
|
||||
* - [net.minecraft.world.level.chunk.ChunkAccess] <br>
|
||||
* - [net.minecraft.world.level.ServerLevel] or [net.minecraft.world.level.ClientLevel] <br>
|
||||
*/
|
||||
CompletableFuture<Void> generateChunks(
|
||||
int chunkPosMinX, int chunkPosMinZ,
|
||||
|
||||
+7
-6
@@ -7,6 +7,7 @@ import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStre
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -182,7 +183,7 @@ public class FullDataPointIdMap
|
||||
}
|
||||
|
||||
/** Creates a new IdBiomeBlockStateMap from the given UTF formatted stream */
|
||||
public static FullDataPointIdMap deserialize(DhDataInputStream inputStream, DhSectionPos pos) throws IOException, InterruptedException
|
||||
public static FullDataPointIdMap deserialize(DhDataInputStream inputStream, DhSectionPos pos, ILevelWrapper levelWrapper) throws IOException, InterruptedException
|
||||
{
|
||||
int entityCount = inputStream.readInt();
|
||||
|
||||
@@ -193,7 +194,7 @@ public class FullDataPointIdMap
|
||||
for (int i = 0; i < entityCount; i++)
|
||||
{
|
||||
String entryString = inputStream.readUTF();
|
||||
Entry newEntry = Entry.deserialize(entryString);
|
||||
Entry newEntry = Entry.deserialize(entryString, levelWrapper);
|
||||
newMap.entryList.add(newEntry);
|
||||
|
||||
if (RUN_SERIALIZATION_DUPLICATE_VALIDATION)
|
||||
@@ -280,7 +281,7 @@ public class FullDataPointIdMap
|
||||
|
||||
Entry other = (Entry) otherObj;
|
||||
return other.biome.serialize().equals(this.biome.serialize())
|
||||
&& other.blockState.serialize().equals(this.blockState.serialize());
|
||||
&& other.blockState.getSerialString().equals(this.blockState.getSerialString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,9 +289,9 @@ public class FullDataPointIdMap
|
||||
|
||||
|
||||
|
||||
public String serialize() { return this.biome.serialize() + BLOCK_STATE_SEPARATOR_STRING + this.blockState.serialize(); }
|
||||
public String serialize() { return this.biome.serialize() + BLOCK_STATE_SEPARATOR_STRING + this.blockState.getSerialString(); }
|
||||
|
||||
public static Entry deserialize(String str) throws IOException, InterruptedException
|
||||
public static Entry deserialize(String str, ILevelWrapper levelWrapper) throws IOException, InterruptedException
|
||||
{
|
||||
String[] stringArray = str.split(BLOCK_STATE_SEPARATOR_STRING);
|
||||
if (stringArray.length != 2)
|
||||
@@ -305,7 +306,7 @@ public class FullDataPointIdMap
|
||||
}
|
||||
|
||||
IBiomeWrapper biome = WRAPPER_FACTORY.deserializeBiomeWrapper(stringArray[0]);
|
||||
IBlockStateWrapper blockState = WRAPPER_FACTORY.deserializeBlockStateWrapper(stringArray[1]);
|
||||
IBlockStateWrapper blockState = WRAPPER_FACTORY.deserializeBlockStateWrapper(stringArray[1], levelWrapper);
|
||||
return new Entry(biome, blockState);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ 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;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -232,7 +233,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
this.mapping.serialize(outputStream);
|
||||
}
|
||||
@Override
|
||||
public FullDataPointIdMap readIdMappings(long[][] dataPoints, DhDataInputStream inputStream) throws IOException, InterruptedException
|
||||
public FullDataPointIdMap readIdMappings(long[][] dataPoints, DhDataInputStream inputStream, ILevelWrapper levelWrapper) throws IOException, InterruptedException
|
||||
{
|
||||
int guardByte = inputStream.readInt();
|
||||
if (guardByte != IFullDataSource.DATA_GUARD_BYTE)
|
||||
@@ -240,7 +241,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
|
||||
throw new IOException("Invalid data content end guard for ID mapping");
|
||||
}
|
||||
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos);
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos, levelWrapper);
|
||||
}
|
||||
@Override
|
||||
public void setIdMapping(FullDataPointIdMap mappings) { this.mapping.mergeAndReturnRemappedEntityIds(mappings); }
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ 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;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -350,7 +351,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
|
||||
|
||||
@Override
|
||||
public FullDataPointIdMap readIdMappings(long[][][] dataPoints, DhDataInputStream inputStream) throws IOException, InterruptedException
|
||||
public FullDataPointIdMap readIdMappings(long[][][] dataPoints, DhDataInputStream inputStream, ILevelWrapper levelWrapper) throws IOException, InterruptedException
|
||||
{
|
||||
// mark the start of the ID data
|
||||
int idMappingStartByte = inputStream.readInt();
|
||||
@@ -361,7 +362,7 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
|
||||
}
|
||||
|
||||
// deserialize the ID data
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos);
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos, levelWrapper);
|
||||
}
|
||||
@Override
|
||||
public void writeIdMappings(DhDataOutputStream dataOutputStream) throws IOException
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ 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;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -244,7 +245,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
|
||||
}
|
||||
@Override
|
||||
public FullDataPointIdMap readIdMappings(StreamDataPointContainer streamDataPointContainer, DhDataInputStream inputStream) throws IOException, InterruptedException
|
||||
public FullDataPointIdMap readIdMappings(StreamDataPointContainer streamDataPointContainer, DhDataInputStream inputStream, ILevelWrapper levelWrapper) throws IOException, InterruptedException
|
||||
{
|
||||
// Id mapping
|
||||
int dataPresentFlag = inputStream.readInt();
|
||||
@@ -252,7 +253,7 @@ public class LowDetailIncompleteFullDataSource extends FullDataArrayAccessor imp
|
||||
{
|
||||
throw new IOException("invalid ID mapping end guard");
|
||||
}
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos);
|
||||
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos, levelWrapper);
|
||||
}
|
||||
@Override
|
||||
public void setIdMapping(FullDataPointIdMap mappings) { this.mapping.mergeAndReturnRemappedEntityIds(mappings); }
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@ import com.seibel.distanthorizons.core.file.fullDatafile.FullDataMetaFile;
|
||||
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataInputStream;
|
||||
import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream;
|
||||
import com.seibel.distanthorizons.core.util.objects.dataStreams.*;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -54,7 +55,7 @@ public interface IStreamableFullDataSource<SummaryDataType extends IStreamableFu
|
||||
this.setDataPoints(dataPoints);
|
||||
|
||||
|
||||
FullDataPointIdMap mapping = this.readIdMappings(dataPoints, inputStream);
|
||||
FullDataPointIdMap mapping = this.readIdMappings(dataPoints, inputStream, level.getLevelWrapper());
|
||||
this.setIdMapping(mapping);
|
||||
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public interface IStreamableFullDataSource<SummaryDataType extends IStreamableFu
|
||||
|
||||
|
||||
void writeIdMappings(DhDataOutputStream outputStream) throws IOException;
|
||||
FullDataPointIdMap readIdMappings(DataContainerType dataPoints, DhDataInputStream inputStream) throws IOException, InterruptedException;
|
||||
FullDataPointIdMap readIdMappings(DataContainerType dataPoints, DhDataInputStream inputStream, ILevelWrapper levelWrapper) throws IOException, InterruptedException;
|
||||
void setIdMapping(FullDataPointIdMap mappings);
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public interface IWrapperFactory extends IBindable
|
||||
{
|
||||
AbstractBatchGenerationEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel);
|
||||
IBiomeWrapper deserializeBiomeWrapper(String str) throws IOException;
|
||||
IBlockStateWrapper deserializeBlockStateWrapper(String str) throws IOException;
|
||||
IBlockStateWrapper deserializeBlockStateWrapper(String str, ILevelWrapper levelWrapper) throws IOException;
|
||||
IBlockStateWrapper getAirBlockStateWrapper();
|
||||
/**
|
||||
* Returns the set of {@link IBlockStateWrapper}'s that shouldn't be rendered. <br>
|
||||
|
||||
+1
-2
@@ -5,8 +5,7 @@ import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||
/** A Minecraft version independent way of handling Blocks. */
|
||||
public interface IBlockStateWrapper extends IDhApiBlockStateWrapper
|
||||
{
|
||||
/** will only work if a level is currently loaded */
|
||||
String serialize();
|
||||
String getSerialString();
|
||||
|
||||
/**
|
||||
* Returning a value of 0 means the block is completely transparent. <br.
|
||||
|
||||
Reference in New Issue
Block a user