Search in sources :

Example 1 with Int2IntBiHashMap

use of com.viaversion.viaversion.util.Int2IntBiHashMap in project ViaVersion by ViaVersion.

the class MappingDataBase method load.

@Override
public void load() {
    getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
    JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
    JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
    JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
    blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
    blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
    blockEntityMappings = loadFromArray(oldMappings, newMappings, diffmapping, "blockentities");
    soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
    statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
    Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
    if (particles != null) {
        particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
    }
    if (loadItems && newMappings.has("items")) {
        itemMappings = new Int2IntBiHashMap();
        itemMappings.defaultReturnValue(-1);
        MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"), diffmapping != null ? diffmapping.getAsJsonObject("items") : null, true);
    }
    if (diffmapping != null && diffmapping.has("tags")) {
        this.tags = new EnumMap<>(RegistryType.class);
        JsonObject tags = diffmapping.getAsJsonObject("tags");
        if (tags.has(RegistryType.ITEM.resourceLocation())) {
            loadTags(RegistryType.ITEM, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("items")));
        }
        if (tags.has(RegistryType.BLOCK.resourceLocation())) {
            loadTags(RegistryType.BLOCK, tags, MappingDataLoader.indexedObjectToMap(newMappings.getAsJsonObject("blocks")));
        }
    }
    loadExtras(oldMappings, newMappings, diffmapping);
}
Also used : RegistryType(com.viaversion.viaversion.api.minecraft.RegistryType) JsonObject(com.google.gson.JsonObject) Int2IntBiHashMap(com.viaversion.viaversion.util.Int2IntBiHashMap)

Aggregations

JsonObject (com.google.gson.JsonObject)1 RegistryType (com.viaversion.viaversion.api.minecraft.RegistryType)1 Int2IntBiHashMap (com.viaversion.viaversion.util.Int2IntBiHashMap)1