From 71341a9381400d363e11f954d30cbb42897b39f1 Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Mon, 12 Oct 2020 13:32:06 +0200 Subject: [PATCH 1/2] Fix 1.11.1 -> 1.12 show_achievement translation (#2120) --- .../TranslateRewriter.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java index 8a476fd93..2adcf5903 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/TranslateRewriter.java @@ -27,8 +27,15 @@ public class TranslateRewriter { return; } - String value = hoverEvent.getAsJsonPrimitive("value").getAsString(); - if (AchievementTranslationMapping.get(value) == null) { + String textValue; + JsonElement value = hoverEvent.get("value"); + if (value.isJsonObject()) { + textValue = value.getAsJsonObject().get("text").getAsString(); + } else { + textValue = value.getAsJsonPrimitive().getAsString(); + } + + if (AchievementTranslationMapping.get(textValue) == null) { JsonObject invalidText = new JsonObject(); invalidText.addProperty("text", "Invalid statistic/achievement!"); invalidText.addProperty("color", "red"); @@ -48,17 +55,17 @@ public class TranslateRewriter { baseArray.add(namePart); baseArray.add(newLine); baseArray.add(typePart); - if (value.startsWith("achievement")) { - namePart.addProperty("translate", value); - namePart.addProperty("color", AchievementTranslationMapping.isSpecial(value) ? "dark_purple" : "green"); + if (textValue.startsWith("achievement")) { + namePart.addProperty("translate", textValue); + namePart.addProperty("color", AchievementTranslationMapping.isSpecial(textValue) ? "dark_purple" : "green"); typePart.addProperty("translate", "stats.tooltip.type.achievement"); JsonObject description = new JsonObject(); typePart.addProperty("italic", true); description.addProperty("translate", value + ".desc"); baseArray.add(newLine); baseArray.add(description); - } else if (value.startsWith("stat")) { - namePart.addProperty("translate", value); + } else if (textValue.startsWith("stat")) { + namePart.addProperty("translate", textValue); namePart.addProperty("color", "gray"); typePart.addProperty("translate", "stats.tooltip.type.statistic"); typePart.addProperty("italic", true); From 54b6d1c21c176ebc9c29b3598ac8d2e23a4710c8 Mon Sep 17 00:00:00 2001 From: DaPorkchop_ Date: Wed, 14 Oct 2020 15:40:39 +0200 Subject: [PATCH 2/2] Fix entity attributes length prefix (#2136) --- .../protocol1_16to1_15_2/packets/EntityPackets.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java index b3b91a35f..e93ea1114 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/EntityPackets.java @@ -211,6 +211,7 @@ public class EntityPackets { handler(wrapper -> { wrapper.passthrough(Type.VAR_INT); int size = wrapper.passthrough(Type.INT); + int actualSize = size; for (int i = 0; i < size; i++) { // Attributes have been renamed and are now namespaced identifiers String key = wrapper.read(Type.STRING); @@ -218,7 +219,10 @@ public class EntityPackets { if (attributeIdentifier == null) { attributeIdentifier = "minecraft:" + key; if (!us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.isValid1_13Channel(attributeIdentifier)) { - Via.getPlatform().getLogger().warning("Invalid attribute: " + key); + if (!Via.getConfig().isSuppressConversionWarnings()) { + Via.getPlatform().getLogger().warning("Invalid attribute: " + key); + } + actualSize--; wrapper.read(Type.DOUBLE); int modifierSize = wrapper.read(Type.VAR_INT); for (int j = 0; j < modifierSize; j++) { @@ -240,6 +244,9 @@ public class EntityPackets { wrapper.passthrough(Type.BYTE); } } + if (size != actualSize) { + wrapper.set(Type.INT, 0, actualSize); + } }); } });