From face56dce124905cfdb1a191043b43d9109cc966 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Tue, 27 Apr 2021 10:29:53 +0200 Subject: [PATCH] Update VV --- .../viabackwards/api/data/BackwardsMappings.java | 13 ++++++++++--- .../api/data/VBMappingDataLoader.java | 6 +++--- .../viabackwards/api/data/VBMappings.java | 10 +++++----- .../data/BackwardsMappings.java | 15 ++++++++------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java index 51e7098b..65b981c8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java @@ -18,18 +18,20 @@ package com.viaversion.viabackwards.api.data; import com.google.common.base.Preconditions; +import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; -import org.checkerframework.checker.nullness.qual.Nullable; import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.data.MappingData; +import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.data.Mappings; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.gson.JsonObject; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Map; +import java.util.logging.Logger; -public class BackwardsMappings extends MappingData { +public class BackwardsMappings extends MappingDataBase { private final Class vvProtocolClass; private Int2ObjectMap backwardsItemMappings; @@ -101,6 +103,11 @@ public class BackwardsMappings extends MappingData { return !key.equals("blocks") && !key.equals("statistics"); } + @Override + protected Logger getLogger() { + return ViaBackwards.getPlatform().getLogger(); + } + /** * @see #getMappedItem(int) for custom backwards mappings */ diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java index cf3c5950..5b390300 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappingDataLoader.java @@ -68,11 +68,11 @@ public class VBMappingDataLoader { } } - public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { + public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true); } - public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) { + public static void mapIdentifiers(int[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) { Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers); for (Map.Entry entry : oldIdentifiers.entrySet()) { String key = entry.getValue().getAsString(); @@ -109,7 +109,7 @@ public class VBMappingDataLoader { } } - output[Integer.parseInt(entry.getKey())] = (short) mappedId; + output[Integer.parseInt(entry.getKey())] = mappedId; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappings.java b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappings.java index d518de62..d6ba1179 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/VBMappings.java @@ -17,13 +17,13 @@ */ package com.viaversion.viabackwards.api.data; -import com.viaversion.viaversion.api.data.Mappings; +import com.viaversion.viaversion.api.data.IntArrayMappings; import com.viaversion.viaversion.libs.gson.JsonArray; import com.viaversion.viaversion.libs.gson.JsonObject; import java.util.Arrays; -public class VBMappings extends Mappings { +public class VBMappings extends IntArrayMappings { public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { super(create(size, oldMapping, newMapping, diffMapping, warnOnMissing)); @@ -41,9 +41,9 @@ public class VBMappings extends Mappings { super(oldMapping.size(), oldMapping, newMapping, diffMapping, warnOnMissing); } - private static short[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { - short[] oldToNew = new short[size]; - Arrays.fill(oldToNew, (short) -1); + private static int[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) { + int[] oldToNew = new int[size]; + Arrays.fill(oldToNew, -1); VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing); return oldToNew; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java index fbba9d24..f6ec6097 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java @@ -20,18 +20,19 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data; import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.data.VBMappings; -import org.checkerframework.checker.nullness.qual.Nullable; import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.data.IntArrayMappings; import com.viaversion.viaversion.api.data.MappingDataLoader; import com.viaversion.viaversion.api.data.Mappings; -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.StatisticMappings; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonPrimitive; +import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; +import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.StatisticMappings; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Arrays; import java.util.HashMap; @@ -58,7 +59,7 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back } // Has lots of compat layers, so we can't use the default Via method - private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { + private static void mapIdentifiers(int[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers); for (Map.Entry entry : newIdentifiers.entrySet()) { String key = entry.getValue().getAsString(); @@ -97,10 +98,10 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back @Override protected @Nullable Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) { if (key.equals("blockstates")) { - short[] oldToNew = new short[8582]; - Arrays.fill(oldToNew, (short) -1); + int[] oldToNew = new int[8582]; + Arrays.fill(oldToNew, -1); mapIdentifiers(oldToNew, oldMappings.getAsJsonObject("blockstates"), newMappings.getAsJsonObject("blocks"), diffMappings.getAsJsonObject("blockstates")); - return new Mappings(oldToNew); + return new IntArrayMappings(oldToNew); } else { return super.loadFromObject(oldMappings, newMappings, diffMappings, key); }