mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-23 17:08:00 +01:00
Allow platforms to use BackwardsMappingDataLoader (#701)
This commit is contained in:
parent
d8b7e7d9ff
commit
59a621315b
@ -26,12 +26,12 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
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() {
|
public BackwardsMappingDataLoader(final Class<?> dataLoaderClass, final String dataPath) {
|
||||||
super(VBMappingDataLoader.class, "assets/viabackwards/data/");
|
super(dataLoaderClass, dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -168,6 +168,6 @@ public class BackwardsMappings extends MappingDataBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected @Nullable CompoundTag readMappingsFile(final String name) {
|
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.BackwardsProtocol;
|
||||||
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
|
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.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||||
import com.viaversion.viabackwards.utils.Block;
|
import com.viaversion.viabackwards.utils.Block;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
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
|
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData; // Raw id -> mapped data
|
||||||
|
|
||||||
static {
|
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()) {
|
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||||
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
Int2ObjectMap<MappedLegacyBlockItem> mappings = new Int2ObjectOpenHashMap<>(8);
|
||||||
LEGACY_MAPPINGS.put(entry.getKey(), mappings);
|
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.ViaBackwards;
|
||||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
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.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
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;
|
private final Map<String, String> translatables;
|
||||||
|
|
||||||
public static void loadTranslatables() {
|
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()) {
|
for (final Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
|
||||||
final Map<String, String> versionMappings = new HashMap<>();
|
final Map<String, String> versionMappings = new HashMap<>();
|
||||||
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
TRANSLATABLES.put(entry.getKey(), versionMappings);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
package com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.ViaBackwards;
|
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.api.Via;
|
||||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
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());
|
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()) {
|
for (final Map.Entry<String, JsonElement> entry : mappings.entrySet()) {
|
||||||
final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString());
|
final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString());
|
||||||
if (legacyBiome == -1) {
|
if (legacyBiome == -1) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data;
|
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.Int2ObjectMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
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) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
super.loadExtras(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) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.getNumberTag("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
defaultChatTypes.put(idTag.asInt(), chatType);
|
defaultChatTypes.put(idTag.asInt(), chatType);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.data;
|
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.Object2IntMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonArray;
|
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) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
super.loadExtras(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;
|
int i = 0;
|
||||||
for (final JsonElement sound : sounds) {
|
for (final JsonElement sound : sounds) {
|
||||||
mappedSounds.put(sound.getAsString(), i++);
|
mappedSounds.put(sound.getAsString(), i++);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.data;
|
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.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
|
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) {
|
protected void loadExtras(CompoundTag data) {
|
||||||
super.loadExtras(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() {
|
public CompoundTag getTrimPatternRegistry() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_20_3to1_20_5.data;
|
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.JsonArray;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
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) {
|
protected void loadExtras(final CompoundTag data) {
|
||||||
super.loadExtras(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()];
|
this.sounds = new String[sounds.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final JsonElement sound : sounds) {
|
for (final JsonElement sound : sounds) {
|
||||||
|
Loading…
Reference in New Issue
Block a user