Skip to content

Commit 4bb47f9

Browse files
committed
fix: UpgradeData serialization in gcFreeChunkSerializer
1 parent 4bef67a commit 4bb47f9

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

c2me-rewrites-chunk-serializer/src/main/java/com/ishland/c2me/rewrites/chunk_serializer/common/ChunkDataSerializer.java

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public final class ChunkDataSerializer {
8383
private static final byte[] STRING_STATUS = NbtWriter.getAsciiStringBytes("Status");
8484
private static final byte[] STRING_BLENDING_DATA = NbtWriter.getAsciiStringBytes("blending_data");
8585
private static final byte[] STRING_BELOW_ZERO_RETROGEN = NbtWriter.getAsciiStringBytes("below_zero_retrogen");
86-
private static final byte[] STRING_UPGRADE_DATA = NbtWriter.getAsciiStringBytes("upgrade_data");
86+
private static final byte[] STRING_UPGRADE_DATA = NbtWriter.getAsciiStringBytes("UpgradeData");
8787
private static final byte[] STRING_IS_LIGHT_ON = NbtWriter.getAsciiStringBytes("isLightOn");
8888
private static final byte[] STRING_BLOCK_ENTITIES = NbtWriter.getAsciiStringBytes("block_entities");
8989
private static final byte[] STRING_PALETTE = NbtWriter.getAsciiStringBytes("palette");
@@ -183,10 +183,12 @@ public static void write(SerializedChunk serializable, NbtWriter writer) {
183183

184184
UpgradeData upgradeData = serializable.upgradeData();
185185
if (!upgradeData.isDone()) {
186-
// Inline serialization
187-
writer.startCompound(STRING_UPGRADE_DATA);
188-
writeUpgradeData(writer, (IUpgradeData) upgradeData);
189-
writer.finishCompound();
186+
// // Inline serialization
187+
// writer.startCompound(STRING_UPGRADE_DATA);
188+
// writeUpgradeData(writer, (IUpgradeData) upgradeData);
189+
// writer.finishCompound();
190+
// uncommon path
191+
writer.putElement(STRING_UPGRADE_DATA, upgradeData.toNbt());
190192
}
191193

192194
List<SerializedChunk.SectionData> sectionData = serializable.sectionData();
@@ -525,36 +527,36 @@ private static void writeBelowZeroRetrogen(NbtWriter writer, IBelowZeroRetrogen
525527
}
526528

527529

528-
private static void writeUpgradeData(NbtWriter writer, IUpgradeData upgradeData) {
529-
long indicesStart = -1;
530-
int indicesCount = 0;
531-
532-
int[][] centerIndicesToUpgrade = upgradeData.getCenterIndicesToUpgrade();
533-
534-
for (int i = 0; i < centerIndicesToUpgrade.length; ++i) {
535-
if (centerIndicesToUpgrade[i] != null && centerIndicesToUpgrade[i].length != 0) {
536-
String string = String.valueOf(i);
537-
if (indicesStart == -1) {
538-
indicesStart = writer.startList(STRING_INDICES, NbtElement.INT_ARRAY_TYPE);
539-
}
540-
indicesCount++;
541-
// TODO: cache this
542-
writer.putIntArray(NbtWriter.getAsciiStringBytes(string), centerIndicesToUpgrade[i]);
543-
}
544-
}
545-
546-
if (indicesStart != -1) {
547-
writer.finishList(indicesStart, indicesCount);
548-
}
549-
550-
int i = 0;
551-
552-
for (EightWayDirection eightWayDirection : upgradeData.getSidesToUpgrade()) {
553-
i |= 1 << eightWayDirection.ordinal();
554-
}
555-
556-
writer.putByte(STRING_SIDES, (byte) i);
557-
}
530+
// private static void writeUpgradeData(NbtWriter writer, IUpgradeData upgradeData) {
531+
// long indicesStart = -1;
532+
// int indicesCount = 0;
533+
//
534+
// int[][] centerIndicesToUpgrade = upgradeData.getCenterIndicesToUpgrade();
535+
//
536+
// for (int i = 0; i < centerIndicesToUpgrade.length; ++i) {
537+
// if (centerIndicesToUpgrade[i] != null && centerIndicesToUpgrade[i].length != 0) {
538+
// String string = String.valueOf(i);
539+
// if (indicesStart == -1) {
540+
// indicesStart = writer.startList(STRING_INDICES, NbtElement.INT_ARRAY_TYPE);
541+
// }
542+
// indicesCount++;
543+
// // TODO: cache this
544+
// writer.putIntArray(NbtWriter.getAsciiStringBytes(string), centerIndicesToUpgrade[i]);
545+
// }
546+
// }
547+
//
548+
// if (indicesStart != -1) {
549+
// writer.finishList(indicesStart, indicesCount);
550+
// }
551+
//
552+
// int i = 0;
553+
//
554+
// for (EightWayDirection eightWayDirection : upgradeData.getSidesToUpgrade()) {
555+
// i |= 1 << eightWayDirection.ordinal();
556+
// }
557+
//
558+
// writer.putByte(STRING_SIDES, (byte) i);
559+
// }
558560

559561
@Deprecated
560562
public static NbtList toNbt(ShortList[] lists) {

0 commit comments

Comments
 (0)