refactor: Re-add old serialization method

This is used by some override methods that don't have access to the level.
These old serialization methods have `FIXME`s so they're easy to find in the future.
This commit is contained in:
Steveplays28
2023-08-13 23:18:55 +02:00
parent d839b6e4bd
commit 8dcec7a1bd
5 changed files with 26 additions and 16 deletions
@@ -165,7 +165,7 @@ public class FullDataPointIdMap
}
if (dataPointEntryBySerialization.containsValue(entry))
{
LOGGER.error("Duplicate serialized entry found with value: " + entry.serialize());
LOGGER.error("Duplicate serialized entry found with value: " + entry.serialize(levelWrapper));
}
dataPointEntryBySerialization.put(entryString, entry);
}
@@ -187,7 +187,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)
@@ -198,7 +198,7 @@ public class FullDataPointIdMap
}
if (dataPointEntryBySerialization.containsValue(newEntry))
{
LOGGER.error("Duplicate deserialized entry found with value: " + newEntry.serialize());
LOGGER.error("Duplicate deserialized entry found with value: " + newEntry.serialize(levelWrapper));
}
dataPointEntryBySerialization.put(entryString, newEntry);
}
@@ -278,10 +278,17 @@ public class FullDataPointIdMap
}
@Override
public String toString() { return this.serialize(); }
public String toString() {
return this.serialize();
}
public String serialize(ILevelWrapper levelWrapper) { return this.biome.serialize(levelWrapper) + SEPARATOR_STRING + this.blockState.serialize(levelWrapper); }
public String serialize(ILevelWrapper levelWrapper) {
return this.biome.serialize(levelWrapper) + BLOCK_STATE_SEPARATOR_STRING + this.blockState.serialize(levelWrapper);
}
public String serialize() {
return this.biome.serialize() + BLOCK_STATE_SEPARATOR_STRING + this.blockState.serialize();
}
public static Entry deserialize(String str, ILevelWrapper levelWrapper) throws IOException, InterruptedException
{
@@ -242,8 +242,7 @@ public class CompleteFullDataSource extends FullDataArrayAccessor implements IFu
throw new IOException("Invalid data content end guard for ID mapping");
}
return FullDataPointIdMap.deserialize(inputStream, levelWrapper);
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos);
return FullDataPointIdMap.deserialize(inputStream, this.sectionPos, levelWrapper);
}
@Override
public void setIdMapping(FullDataPointIdMap mappings) { this.mapping.mergeAndReturnRemappedEntityIds(mappings); }
@@ -365,10 +365,10 @@ public class HighDetailIncompleteFullDataSource implements IIncompleteFullDataSo
}
@Override
public void writeIdMappings(DhDataOutputStream dataOutputStream) throws IOException
public void writeIdMappings(DhDataOutputStream outputStream, ILevelWrapper levelWrapper) throws IOException
{
dataOutputStream.writeInt(IFullDataSource.DATA_GUARD_BYTE);
this.mapping.serialize(dataOutputStream);
outputStream.writeInt(IFullDataSource.DATA_GUARD_BYTE);
this.mapping.serialize(outputStream, levelWrapper);
}
@Override
@@ -7,13 +7,15 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
public interface IBlockStateWrapper extends IDhApiBlockStateWrapper
{
String serialize(ILevelWrapper levelWrapper);
/**
* Returning a value of 0 means the block is completely transparent. <br.
// FIXME: Old code that might create a nullpointer exception
String serialize();
/**
* Returning a value of 0 means the block is completely transparent. <br.
* Returning a value of 15 means the block is completely opaque.
*/
int getOpacity();
int getLightEmission();
}
@@ -30,4 +30,6 @@ public interface IBiomeWrapper extends IDhApiBiomeWrapper, IBindable
{
String getName();
String serialize(ILevelWrapper levelWrapper);
// FIXME: Old code that might create a nullpointer exception
String serialize();
}