Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-17 13:30:14 +01:00
Allow platforms to use BackwardsMappingDataLoader (#701)
Dieser Commit ist enthalten in:
Ursprung
d8b7e7d9ff
Commit
59a621315b
@ -26,12 +26,12 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class VBMappingDataLoader extends MappingDataLoader {
|
||||
public class BackwardsMappingDataLoader extends MappingDataLoader {
|
||||
|
||||
public static final VBMappingDataLoader INSTANCE = new VBMappingDataLoader();
|
||||
public static final BackwardsMappingDataLoader INSTANCE = new BackwardsMappingDataLoader(BackwardsMappingDataLoader.class, "assets/viabackwards/data/");
|
||||
|
||||
public VBMappingDataLoader() {
|
||||
super(VBMappingDataLoader.class, "assets/viabackwards/data/");
|
||||
public BackwardsMappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
|
||||
super(dataLoaderClass, dataPath);
|
||||
}
|
||||
|
||||
@Override
|
@ -168,6 +168,6 @@ public class BackwardsMappings extends MappingDataBase {
|
||||
|
||||
@Override
|
||||
protected @Nullable CompoundTag readMappingsFile(final String name) {
|
||||
return VBMappingDataLoader.INSTANCE.loadNBTFromDir(name);
|
||||
return BackwardsMappingDataLoader.INSTANCE.loadNBTFromDir(name);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||
import com.viaversion.viabackwards.utils.Block;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
@ -52,7 +52,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData; // Raw id -> mapped data
|
||||
|
||||
static {
|
||||
JsonObject jsonObject = VBMappingDataLoader.INSTANCE.loadFromDataDir("legacy-mappings.json");
|
||||
JsonObject jsonObject = BackwardsMappingDataLoader.INSTANCE.loadFromDataDir("legacy-mappings.json");
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
||||
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
||||
|
@ -19,7 +19,7 @@ package com.viaversion.viabackwards.api.rewriters;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
@ -34,7 +34,7 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
private final Map<String, String> translatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
final JsonObject jsonObject = VBMappingDataLoader.INSTANCE.loadFromDataDir("translation-mappings.json");
|
||||
final JsonObject jsonObject = BackwardsMappingDataLoader.INSTANCE.loadFromDataDir("translation-mappings.json");
|
||||
for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||
final Map<String, String> versionMappings = new HashMap<>();
|
||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
@ -117,7 +117,7 @@ public final class BiomeMappings {
|
||||
MODERN_TO_LEGACY_ID.put(entry.getKey(), entry.getIntValue());
|
||||
}
|
||||
|
||||
final JsonObject mappings = VBMappingDataLoader.INSTANCE.loadFromDataDir("biome-mappings.json");
|
||||
final JsonObject mappings = BackwardsMappingDataLoader.INSTANCE.loadFromDataDir("biome-mappings.json");
|
||||
for (final Map.Entry<String, JsonElement> entry : mappings.entrySet()) {
|
||||
final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString());
|
||||
if (legacyBiome == -1) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@ -38,7 +38,7 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
|
||||
final ListTag<CompoundTag> chatTypes = VBMappingDataLoader.INSTANCE.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
||||
final ListTag<CompoundTag> chatTypes = BackwardsMappingDataLoader.INSTANCE.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class);
|
||||
for (final CompoundTag chatType : chatTypes) {
|
||||
final NumberTag idTag = chatType.getNumberTag("id");
|
||||
defaultChatTypes.put(idTag.asInt(), chatType);
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.data;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
@ -39,7 +39,7 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
|
||||
final JsonArray sounds = VBMappingDataLoader.INSTANCE.loadData("sounds-1.19.json").getAsJsonArray("sounds");
|
||||
final JsonArray sounds = BackwardsMappingDataLoader.INSTANCE.loadData("sounds-1.19.json").getAsJsonArray("sounds");
|
||||
int i = 0;
|
||||
for (final JsonElement sound : sounds) {
|
||||
mappedSounds.put(sound.getAsString(), i++);
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.data;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
||||
|
||||
@ -33,7 +33,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
|
||||
protected void loadExtras(CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
|
||||
trimPatternRegistry = VBMappingDataLoader.INSTANCE.loadNBT("trim_pattern-1.19.4.nbt");
|
||||
trimPatternRegistry = BackwardsMappingDataLoader.INSTANCE.loadNBT("trim_pattern-1.19.4.nbt");
|
||||
}
|
||||
|
||||
public CompoundTag getTrimPatternRegistry() {
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.data;
|
||||
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@ -36,7 +36,7 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
super.loadExtras(data);
|
||||
|
||||
final JsonArray sounds = VBMappingDataLoader.INSTANCE.loadData("sounds-1.20.3.json").getAsJsonArray("sounds");
|
||||
final JsonArray sounds = BackwardsMappingDataLoader.INSTANCE.loadData("sounds-1.20.3.json").getAsJsonArray("sounds");
|
||||
this.sounds = new String[sounds.size()];
|
||||
int i = 0;
|
||||
for (final JsonElement sound : sounds) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren