Skip to content

Commit

Permalink
Update mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Sep 25, 2024
1 parent fe79b81 commit 9a046e2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 26 deletions.
36 changes: 18 additions & 18 deletions mappings/diff/mapping-1.21.2to1.21.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions mappings/diff/mapping-1.21to1.21.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"fire_resistant": ""
},
"entities": {
"boat": "",
"chest_boat": ""
"boat": "oak_boat",
"chest_boat": "oak_chest_boat"
}
}
4 changes: 2 additions & 2 deletions output_hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
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;
Expand All @@ -44,6 +41,8 @@
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).
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -590,6 +590,7 @@ private static void serialize(final MappingsResult result, final CompoundTag par
if (!hasChanges) {
tag.putByte("id", IDENTITY_ID);
tag.putInt("size", mappings.length);
storageStrategyCounts[IDENTITY_ID]++;
return;
}

Expand All @@ -598,12 +599,14 @@ private static void serialize(final MappingsResult result, final CompoundTag par
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]++;
}
}

Expand Down Expand Up @@ -683,6 +686,10 @@ private static void writeShiftFormat(final CompoundTag tag, final MappingsResult
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);
}
Expand Down

0 comments on commit 9a046e2

Please sign in to comment.