Update mappings

This commit is contained in:
Nassim Jahnke 2024-09-25 17:21:09 +02:00
parent fe79b8192b
commit 9a046e2ba3
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
5 changed files with 34 additions and 26 deletions

View File

@ -78,23 +78,23 @@
"crafting_transmute": ""
},
"entities": {
"acacia_boat": "",
"acacia_chest_boat": "",
"bamboo_chest_raft": "",
"bamboo_raft": "",
"birch_boat": "",
"birch_chest_boat": "",
"cherry_boat": "",
"cherry_chest_boat": "",
"dark_oak_boat": "",
"dark_oak_chest_boat": "",
"jungle_boat": "",
"jungle_chest_boat": "",
"mangrove_boat": "",
"mangrove_chest_boat": "",
"oak_boat": "",
"oak_chest_boat": "",
"spruce_boat": "",
"spruce_chest_boat": ""
"acacia_boat": "boat",
"acacia_chest_boat": "chest_boat",
"bamboo_chest_raft": "chest_boat",
"bamboo_raft": "boat",
"birch_boat": "boat",
"birch_chest_boat": "chest_boat",
"cherry_boat": "boat",
"cherry_chest_boat": "chest_boat",
"dark_oak_boat": "boat",
"dark_oak_chest_boat": "chest_boat",
"jungle_boat": "boat",
"jungle_chest_boat": "chest_boat",
"mangrove_boat": "boat",
"mangrove_chest_boat": "chest_boat",
"oak_boat": "boat",
"oak_chest_boat": "chest_boat",
"spruce_boat": "boat",
"spruce_chest_boat": "chest_boat"
}
}

View File

@ -44,7 +44,7 @@
"fire_resistant": ""
},
"entities": {
"boat": "",
"chest_boat": ""
"boat": "oak_boat",
"chest_boat": "oak_chest_boat"
}
}

View File

@ -232,11 +232,11 @@
"size": 5331
},
"1.21:1.21.2": {
"object-hash": -1943693336,
"object-hash": -837786509,
"size": 942
},
"1.21.2:1.21": {
"object-hash": 581622620,
"object-hash": 316311361,
"size": 1513
}
}

View File

@ -44,6 +44,7 @@ public final class ManualRunner {
public static void main(final String[] args) throws IOException {
if (ALL) {
runAll(ErrorStrategy.WARN);
MappingsOptimizer.printStats();
return;
}

View File

@ -32,9 +32,6 @@ import com.viaversion.nbt.tag.Tag;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@ -44,6 +41,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Optimizes mapping files as nbt files with only the necessary data (mostly int to int mappings in form of int arrays).
@ -82,6 +81,7 @@ public final class MappingsOptimizer {
"tags",
"attributes"
);
private static final int[] storageStrategyCounts = new int[IDENTITY_ID + 1];
private static final Set<String> savedIdentifierFiles = new HashSet<>();
private static JsonObject globalIdentifiersObject;
private static JsonObject fileHashesObject;
@ -590,6 +590,7 @@ public final class MappingsOptimizer {
if (!hasChanges) {
tag.putByte("id", IDENTITY_ID);
tag.putInt("size", mappings.length);
storageStrategyCounts[IDENTITY_ID]++;
return;
}
@ -598,12 +599,14 @@ public final class MappingsOptimizer {
final int plainFormatSize = mappings.length;
if (changedFormatSize < plainFormatSize && changedFormatSize < shiftFormatSize) {
writeChangedFormat(tag, result, key, numberOfChanges);
storageStrategyCounts[CHANGES_ID]++;
} else if (shiftFormatSize < changedFormatSize && shiftFormatSize < plainFormatSize) {
writeShiftFormat(tag, result, key);
storageStrategyCounts[SHIFTS_ID]++;
} else {
LOGGER.debug("{}: Storing as direct values", key);
tag.putByte("id", DIRECT_ID);
tag.put("val", new IntArrayTag(mappings));
storageStrategyCounts[DIRECT_ID]++;
}
}
@ -683,6 +686,10 @@ public final class MappingsOptimizer {
tag.put("to", new IntArrayTag(shiftsTo));
}
public static void printStats() {
LOGGER.info("Storage format counts: direct={}, shifts={}, changes={}, identity={}", storageStrategyCounts[DIRECT_ID], storageStrategyCounts[SHIFTS_ID], storageStrategyCounts[CHANGES_ID], storageStrategyCounts[IDENTITY_ID]);
}
public static void write(final CompoundTag tag, final Path path) throws IOException {
TAG_WRITER.write(path, tag, false);
}