From 5bb3e8a1fcb9b25b6a3e8a10026f5c86657d2494 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:13:12 +0100 Subject: [PATCH 1/7] paste.gg -> mclo.gs (#689) --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 01efb78f..62d5052b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -21,11 +21,11 @@ body: attributes: label: Console Error description: | - If you encounter warnings/errors in your console, **paste them with https://paste.gg/ and put the paste link here**. + If you encounter warnings/errors in your console, **paste them with https://mclo.gs/ and put the paste link here**. If the error is small/less than 10 lines, you may put it directly into this field. value: | ``` - Put the paste.gg link or text here. + Put the mclo.gs link or text here. ``` placeholder: Please do not remove the grave accents; simply replace the line of text in the middle. validations: From 2f60c79ed81dd34f334e3dd3d84425d0a1cb47c3 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:09:50 +0100 Subject: [PATCH 2/7] Use equals for legacy custom payload channel handlers (#693) --- .../protocol1_10to1_11/packets/BlockItemPackets1_11.java | 2 +- .../protocol1_11_1to1_12/packets/BlockItemPackets1_12.java | 2 +- .../protocol1_11to1_11_1/packets/ItemPackets1_11_1.java | 2 +- .../protocol1_9_4to1_10/packets/BlockItemPackets1_10.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java index e7aee953..cb194858 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java @@ -115,7 +115,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { - if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) { + if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { wrapper.passthrough(Type.INT); // Passthrough Window ID int size = wrapper.passthrough(Type.UNSIGNED_BYTE); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java index 1b0912e3..f7e9abe8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java @@ -91,7 +91,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { - if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) { + if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { wrapper.passthrough(Type.INT); // Passthrough Window ID int size = wrapper.passthrough(Type.UNSIGNED_BYTE); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java index cc25278c..e04c4a90 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java @@ -49,7 +49,7 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter { - if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) { + if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { wrapper.passthrough(Type.INT); // Passthrough Window ID int size = wrapper.passthrough(Type.UNSIGNED_BYTE); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java index 8dbd1800..9d2d1661 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java @@ -49,7 +49,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { - if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) { + if (wrapper.get(Type.STRING, 0).equals("MC|TrList")) { wrapper.passthrough(Type.INT); // Passthrough Window ID int size = wrapper.passthrough(Type.UNSIGNED_BYTE); From bf3834ab211e6fa6e15658641e0c1f8a177d92ca Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:25:31 +0100 Subject: [PATCH 3/7] Tidy up fabric.mod.json file of fabric platform (#695) --- fabric/src/main/resources/fabric.mod.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index bff84f96..73e60e2c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -6,7 +6,7 @@ "description": "Allow older Minecraft versions to connect to a newer server version.", "license": "GPL-3.0", "contact": { - "homepage": "https://github.com/ViaVersion/ViaBackwards", + "homepage": "https://viaversion.com/backwards", "issues": "https://github.com/ViaVersion/ViaBackwards/issues", "sources": "https://github.com/ViaVersion/ViaBackwards" }, @@ -30,5 +30,12 @@ }, "recommends": { "viarewind": "*" - } + }, + "custom": { + "modmenu:api": true, + "modmenu": { + "badges": [ "library" ], + "parent": "viafabric" + } + } } From ab742c794f88585e2563789a6199a8b29f49fff5 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:26:59 +0100 Subject: [PATCH 4/7] Update description included in platforms (#694) --- build.gradle.kts | 2 +- bukkit/src/main/resources/plugin.yml | 2 +- fabric/src/main/resources/fabric.mod.json | 2 +- .../main/java/com/viaversion/viabackwards/VelocityPlugin.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b605067c..23ffb0e4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { allprojects { group = "com.viaversion" version = property("projectVersion") as String // from gradle.properties - description = "Allow older clients to join newer server versions." + description = "Allows older Minecraft client versions to connect to newer server versions." } val main = setOf( diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 5c6bcd26..4439d93a 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: ViaBackwards version: ${version} -description: Allow older Minecraft versions to connect to a newer server version. +description: ${description} main: com.viaversion.viabackwards.BukkitPlugin api-version: 1.13 folia-supported: true diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 73e60e2c..fe5204c7 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "viabackwards", "name": "ViaBackwards", "version": "${version}", - "description": "Allow older Minecraft versions to connect to a newer server version.", + "description": "${description}", "license": "GPL-3.0", "contact": { "homepage": "https://viaversion.com/backwards", diff --git a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java index 87ac645a..4e11ba38 100644 --- a/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viabackwards/VelocityPlugin.java @@ -37,7 +37,7 @@ import java.util.logging.Logger; name = "ViaBackwards", version = VersionInfo.VERSION, authors = {"Matsv", "kennytv", "Gerrygames", "creeper123123321", "ForceUpdate1"}, - description = "Allow older Minecraft versions to connect to a newer server version.", + description = "Allows older Minecraft client versions to connect to newer server versions.", dependencies = {@Dependency(id = "viaversion")} ) public class VelocityPlugin implements ViaBackwardsPlatform { From 64e68830bc4a25464589d6f3e27366fb08416325 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 4 Mar 2024 17:32:32 +0100 Subject: [PATCH 5/7] Create FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..b1361d12 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: kennytv +patreon: kennytv From 79a2881a0206f98f8a4bf1859cc1ed78b9beb995 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 5 Mar 2024 17:51:04 +0100 Subject: [PATCH 6/7] 4.9.2 Release --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index c312ff6a..001fb31a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ -projectVersion=4.9.2-SNAPSHOT +projectVersion=4.9.2 # Smile emoji -mcVersions=1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 -mcVersionRange=1.10-1.20.3 +mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 +mcVersionRange=1.10-1.20.4 waterfallVersion=1.20 velocityVersion=3.3 From c6ea04fd333d092be1dcc5fe3fb4a67ce5a2c0b9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 7 Mar 2024 13:37:42 +0100 Subject: [PATCH 7/7] Update ViaNBT --- .../api/rewriters/EnchantmentRewriter.java | 12 +-- .../api/rewriters/ItemRewriter.java | 9 +-- .../api/rewriters/ItemRewriterBase.java | 12 +-- .../rewriters/LegacyEnchantmentRewriter.java | 42 ++++------- .../block_entity_handlers/BannerHandler.java | 11 +-- .../block_entity_handlers/PistonHandler.java | 2 +- .../packets/BlockItemPackets1_13.java | 73 ++++++++----------- .../packets/BlockItemPackets1_14.java | 20 ++--- .../packets/BlockItemPackets1_16.java | 13 +--- .../packets/BlockItemPackets1_16_2.java | 2 +- .../packets/EntityPackets1_16_2.java | 9 +-- .../packets/EntityPackets1_17.java | 12 +-- .../packets/EntityPackets1_18.java | 6 +- .../Protocol1_17To1_17_1.java | 10 +-- .../data/BackwardsMappings.java | 10 +-- .../packets/EntityPackets1_19.java | 24 +++--- .../Protocol1_18To1_18_2.java | 6 +- .../packets/EntityPackets1_19_3.java | 9 +-- .../packets/EntityPackets1_19_4.java | 6 +- .../packets/BlockItemPackets1_20.java | 4 +- .../packets/EntityPackets1_20.java | 8 +- .../Protocol1_19To1_19_1.java | 9 +-- gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- 24 files changed, 130 insertions(+), 183 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java index 18d0a775..67ba509f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java @@ -78,13 +78,13 @@ public class EnchantmentRewriter { public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) { String key = storedEnchant ? "StoredEnchantments" : "Enchantments"; - ListTag enchantments = tag.getListTag(key); - List loreToAdd = new ArrayList<>(); + ListTag enchantments = tag.getListTag(key, CompoundTag.class); + List loreToAdd = new ArrayList<>(); boolean changed = false; - Iterator iterator = enchantments.iterator(); + Iterator iterator = enchantments.iterator(); while (iterator.hasNext()) { - CompoundTag enchantmentEntry = (CompoundTag) iterator.next(); + CompoundTag enchantmentEntry = iterator.next(); StringTag idTag = enchantmentEntry.getStringTag("id"); String enchantmentId = idTag.getValue(); @@ -123,9 +123,9 @@ public class EnchantmentRewriter { tag.put("display", display = new CompoundTag()); } - ListTag loreTag = display.getListTag("Lore"); + ListTag loreTag = display.getListTag("Lore", StringTag.class); if (loreTag == null) { - display.put("Lore", loreTag = new ListTag(StringTag.class)); + display.put("Lore", loreTag = new ListTag<>(StringTag.class)); } else { // Save original lore itemRewriter.saveListTag(display, loreTag, "Lore"); diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java index e78d7d62..065d9811 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java @@ -60,15 +60,10 @@ public class ItemRewriter lore = display.getListTag("Lore", StringTag.class); if (lore != null) { boolean changed = false; - for (Tag loreEntryTag : lore) { - if (!(loreEntryTag instanceof StringTag)) { - continue; - } - - StringTag loreEntry = (StringTag) loreEntryTag; + for (StringTag loreEntry : lore) { String newValue = protocol.getTranslatableRewriter().processText(loreEntry.getValue()).toString(); if (!changed && !newValue.equals(loreEntry.getValue())) { // Backup original lore before doing any modifications diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java index d7d36cb9..45249baa 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java @@ -62,17 +62,11 @@ public abstract class ItemRewriterBase original, String name) { // Multiple places might try to backup data String backupName = nbtTagName + "|o" + name; if (!displayTag.contains(backupName)) { - // Clone all tag entries - ListTag listTag = new ListTag(); - for (Tag tag : original.getValue()) { - listTag.add(tag.copy()); - } - - displayTag.put(backupName, listTag); + displayTag.put(backupName, original.copy()); } } @@ -103,7 +97,7 @@ public abstract class ItemRewriterBase) original).copy()); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java index 766f17a7..e07db10f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java @@ -47,23 +47,18 @@ public class LegacyEnchantmentRewriter { public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) { String key = storedEnchant ? "StoredEnchantments" : "ench"; - ListTag enchantments = tag.getListTag(key); - ListTag remappedEnchantments = new ListTag(CompoundTag.class); - List lore = new ArrayList<>(); - for (Tag enchantmentEntry : enchantments.copy()) { - if (!(enchantmentEntry instanceof CompoundTag)) { - continue; - } - - CompoundTag entryTag = (CompoundTag) enchantmentEntry; - NumberTag idTag = entryTag.getNumberTag("id"); + ListTag enchantments = tag.getListTag(key, CompoundTag.class); + ListTag remappedEnchantments = new ListTag<>(CompoundTag.class); + List lore = new ArrayList<>(); + for (CompoundTag enchantmentEntry : enchantments.copy()) { + NumberTag idTag = enchantmentEntry.getNumberTag("id"); if (idTag == null) continue; short newId = idTag.asShort(); String enchantmentName = enchantmentMappings.get(newId); if (enchantmentName != null) { enchantments.remove(enchantmentEntry); - NumberTag levelTag = entryTag.getNumberTag("lvl"); + NumberTag levelTag = enchantmentEntry.getNumberTag("lvl"); short level = levelTag != null ? levelTag.asShort() : 1; if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) { lore.add(new StringTag(enchantmentName)); @@ -99,9 +94,9 @@ public class LegacyEnchantmentRewriter { if (display == null) { tag.put("display", display = new CompoundTag()); } - ListTag loreTag = display.getListTag("Lore"); + ListTag loreTag = display.getListTag("Lore", StringTag.class); if (loreTag == null) { - display.put("Lore", loreTag = new ListTag(StringTag.class)); + display.put("Lore", loreTag = new ListTag<>(StringTag.class)); } lore.addAll(loreTag.getValue()); @@ -111,21 +106,15 @@ public class LegacyEnchantmentRewriter { public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) { String key = storedEnchant ? "StoredEnchantments" : "ench"; - ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key); - ListTag enchantments = tag.getListTag(key); + ListTag enchantments = tag.getListTag(key, CompoundTag.class); if (enchantments == null) { - enchantments = new ListTag(CompoundTag.class); + enchantments = new ListTag<>(CompoundTag.class); } if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) { - for (Tag enchantment : enchantments.copy()) { - if (!(enchantment instanceof CompoundTag)) { - continue; - } - - CompoundTag entryTag = (CompoundTag) enchantment; - NumberTag idTag = entryTag.getNumberTag("id"); - NumberTag levelTag = entryTag.getNumberTag("lvl"); + for (CompoundTag enchantment : enchantments.copy()) { + NumberTag idTag = enchantment.getNumberTag("id"); + NumberTag levelTag = enchantment.getNumberTag("lvl"); short id = idTag != null ? idTag.asShort() : 0; short level = levelTag != null ? levelTag.asShort() : 0; if (id == 0 && level == 0) { @@ -143,8 +132,9 @@ public class LegacyEnchantmentRewriter { CompoundTag display = tag.getCompoundTag("display"); // A few null checks just to be safe, though they shouldn't actually be - ListTag lore = display != null ? display.getListTag("Lore") : null; - for (Tag enchantment : remappedEnchantments.copy()) { + ListTag lore = display != null ? display.getListTag("Lore", StringTag.class) : null; + ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key); + for (CompoundTag enchantment : remappedEnchantments.copy()) { enchantments.add(enchantment); if (lore != null && !lore.isEmpty()) { lore.remove(lore.get(0)); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java index ee766d85..aeb70dd6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java @@ -48,14 +48,11 @@ public class BannerHandler implements BackwardsBlockEntityHandler { } // Invert colors - ListTag patternsTag = tag.getListTag("Patterns"); + ListTag patternsTag = tag.getListTag("Patterns", CompoundTag.class); if (patternsTag != null) { - for (Tag pattern : patternsTag) { - if (!(pattern instanceof CompoundTag)) continue; - - CompoundTag patternTag = (CompoundTag) pattern; - NumberTag colorTag = patternTag.getNumberTag("Color"); - patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id + for (CompoundTag pattern : patternsTag) { + NumberTag colorTag = pattern.getNumberTag("Color"); + pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java index 50fdf223..77b624c6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/PistonHandler.java @@ -47,7 +47,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc addEntries(entry.getKey(), entry.getValue()); } } else { - ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").get("blockstates"); + ListTag blockStates = MappingDataLoader.loadNBT("blockstates-1.13.nbt").getListTag("blockstates", StringTag.class); for (int id = 0; id < blockStates.size(); id++) { StringTag state = blockStates.get(id); String key = state.getValue(); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index a568340a..e6e92db2 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -597,10 +597,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) { // The tag was manually created incorrectly so ignore rewriting it - ListTag blockTag = tag.getListTag(tagName); + ListTag blockTag = tag.getListTag(tagName); if (blockTag == null) return; - ListTag newCanPlaceOn = new ListTag(StringTag.class); + ListTag newCanPlaceOn = new ListTag<>(StringTag.class); tag.put(extraNbtTag + "|" + tagName, blockTag.copy()); for (Tag oldTag : blockTag) { Object value = oldTag.getValue(); @@ -611,7 +611,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit newCanPlaceOn.add(new StringTag(newValue)); } } else { - newCanPlaceOn.add(oldTag); + newCanPlaceOn.add(new StringTag(oldTag.getValue().toString())); } } tag.put(tagName, newCanPlaceOn); @@ -620,19 +620,14 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit //TODO un-ugly all of this private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) { String key = storedEnch ? "StoredEnchantments" : "Enchantments"; - ListTag enchantments = tag.getListTag(key); + ListTag enchantments = tag.getListTag(key, CompoundTag.class); if (enchantments == null) return; - ListTag noMapped = new ListTag(CompoundTag.class); - ListTag newEnchantments = new ListTag(CompoundTag.class); - List lore = new ArrayList<>(); + ListTag noMapped = new ListTag<>(CompoundTag.class); + ListTag newEnchantments = new ListTag<>(CompoundTag.class); + List lore = new ArrayList<>(); boolean hasValidEnchants = false; - for (Tag enchantmentEntryTag : enchantments.copy()) { - if (!(enchantmentEntryTag instanceof CompoundTag)) { - continue; - } - - CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag; + for (CompoundTag enchantmentEntry : enchantments.copy()) { StringTag idTag = enchantmentEntry.getStringTag("id"); if (idTag == null) { continue; @@ -720,13 +715,13 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit tag.put("display", display = new CompoundTag()); } - ListTag loreTag = display.getListTag("Lore"); + ListTag loreTag = display.getListTag("Lore", StringTag.class); if (loreTag == null) { - display.put("Lore", loreTag = new ListTag(StringTag.class)); + display.put("Lore", loreTag = new ListTag<>(StringTag.class)); tag.put(extraNbtTag + "|DummyLore", new ByteTag()); } else if (!loreTag.isEmpty()) { - ListTag oldLore = new ListTag(StringTag.class); - for (Tag value : loreTag) { + ListTag oldLore = new ListTag<>(StringTag.class); + for (StringTag value : loreTag) { oldLore.add(value.copy()); } tag.put(extraNbtTag + "|OldLore", oldLore); @@ -854,11 +849,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) { if (tag.getListTag(tagName) == null) return; - ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName); + ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName); if (blockTag != null) { tag.put(tagName, blockTag.copy()); } else if ((blockTag = tag.getListTag(tagName)) != null) { - ListTag newCanPlaceOn = new ListTag(StringTag.class); + ListTag newCanPlaceOn = new ListTag<>(StringTag.class); for (Tag oldTag : blockTag) { Object value = oldTag.getValue(); String oldId = Key.stripMinecraftNamespace(value.toString()); @@ -884,10 +879,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) { String key = storedEnch ? "StoredEnchantments" : "Enchantments"; - ListTag enchantments = tag.getListTag(storedEnch ? key : "ench"); + ListTag enchantments = tag.getListTag(storedEnch ? key : "ench", CompoundTag.class); if (enchantments == null) return; - ListTag newEnchantments = new ListTag(CompoundTag.class); + ListTag newEnchantments = new ListTag<>(CompoundTag.class); boolean dummyEnchant = false; if (!storedEnch) { Tag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags"); @@ -900,12 +895,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit } } - for (Tag enchEntry : enchantments) { - if (!(enchEntry instanceof CompoundTag)) { - continue; - } - - CompoundTag entryTag = (CompoundTag) enchEntry; + for (CompoundTag entryTag : enchantments) { NumberTag idTag = entryTag.getNumberTag("id"); NumberTag levelTag = entryTag.getNumberTag("lvl"); CompoundTag enchantmentEntry = new CompoundTag(); @@ -925,11 +915,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit newEnchantments.add(enchantmentEntry); } - Tag noMapped = tag.remove(extraNbtTag + "|Enchantments"); - if (noMapped instanceof ListTag) { - for (Tag value : ((ListTag) noMapped)) { + ListTag noMapped = tag.getListTag(extraNbtTag + "|Enchantments", CompoundTag.class); + if (noMapped != null) { + for (CompoundTag value : noMapped) { newEnchantments.add(value); } + tag.remove(extraNbtTag + "|Enchantments"); } CompoundTag display = tag.getCompoundTag("display"); @@ -937,14 +928,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit tag.put("display", display = new CompoundTag()); } - Tag oldLore = tag.remove(extraNbtTag + "|OldLore"); - if (oldLore instanceof ListTag) { - ListTag lore = display.getListTag("Lore"); + ListTag oldLore = tag.getListTag(extraNbtTag + "|OldLore", StringTag.class); + if (oldLore != null) { + ListTag lore = display.getListTag("Lore", StringTag.class); if (lore == null) { - tag.put("Lore", lore = new ListTag()); + tag.put("Lore", lore = new ListTag<>(StringTag.class)); } - lore.setValue(((ListTag) oldLore).getValue()); + lore.setValue(oldLore.getValue()); + tag.remove(extraNbtTag + "|OldLore"); } else if (tag.remove(extraNbtTag + "|DummyLore") != null) { display.remove("Lore"); if (display.isEmpty()) { @@ -969,14 +961,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit blockEntityTag.putInt("Base", 15 - base.asInt()); // Invert color id } - ListTag patterns = blockEntityTag.getListTag("Patterns"); + ListTag patterns = blockEntityTag.getListTag("Patterns", CompoundTag.class); if (patterns != null) { - for (Tag pattern : patterns) { - if (!(pattern instanceof CompoundTag)) continue; - - CompoundTag patternTag = (CompoundTag) pattern; - NumberTag colorTag = patternTag.getNumberTag("Color"); - patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id + for (CompoundTag pattern : patterns) { + NumberTag colorTag = pattern.getNumberTag("Color"); + pattern.putInt("Color", 15 - colorTag.asInt()); // Invert color id } } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index f5d36d69..edcc9bc9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -473,17 +473,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit CompoundTag tag = item.tag(); CompoundTag display; if (tag != null && (display = tag.getCompoundTag("display")) != null) { - ListTag lore = display.getListTag("Lore"); + ListTag lore = display.getListTag("Lore", StringTag.class); if (lore != null) { saveListTag(display, lore, "Lore"); - for (Tag loreEntry : lore) { - if (!(loreEntry instanceof StringTag)) continue; - - StringTag loreEntryTag = (StringTag) loreEntry; - String value = loreEntryTag.getValue(); + for (StringTag loreEntry : lore) { + String value = loreEntry.getValue(); if (value != null && !value.isEmpty()) { - loreEntryTag.setValue(ComponentUtil.jsonToLegacy(value)); + loreEntry.setValue(ComponentUtil.jsonToLegacy(value)); } } } @@ -502,13 +499,10 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit CompoundTag display; if (tag != null && (display = tag.getCompoundTag("display")) != null) { // Transform to json if no backup tag is found (else process that in the super method) - ListTag lore = display.getListTag("Lore"); + ListTag lore = display.getListTag("Lore", StringTag.class); if (lore != null && !hasBackupTag(display, "Lore")) { - for (Tag loreEntry : lore) { - if (loreEntry instanceof StringTag) { - StringTag loreEntryTag = (StringTag) loreEntry; - loreEntryTag.setValue(ComponentUtil.legacyToJsonString(loreEntryTag.getValue())); - } + for (StringTag loreEntry : lore) { + loreEntry.setValue(ComponentUtil.legacyToJsonString(loreEntry.getValue())); } } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java index f5b0c635..e1c0442c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java @@ -309,16 +309,11 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit // Handle hover event changes in written book pages if (item.identifier() == 759 && tag != null) { - ListTag pagesTag = tag.getListTag("pages"); + ListTag pagesTag = tag.getListTag("pages", StringTag.class); if (pagesTag != null) { - for (Tag page : pagesTag) { - if (!(page instanceof StringTag)) { - continue; - } - - StringTag pageTag = (StringTag) page; - JsonElement jsonElement = protocol.getTranslatableRewriter().processText(pageTag.getValue()); - pageTag.setValue(jsonElement.toString()); + for (StringTag page : pagesTag) { + JsonElement jsonElement = protocol.getTranslatableRewriter().processText(page.getValue()); + page.setValue(jsonElement.toString()); } } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java index 9990865a..a4812623 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java @@ -149,7 +149,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr CompoundTag properties = skullOwnerTag.getCompoundTag("Properties"); if (properties == null) return; - ListTag textures = properties.getListTag("textures"); + ListTag textures = properties.getListTag("textures", CompoundTag.class); if (textures == null) return; CompoundTag first = !textures.isEmpty() ? textures.get(0) : null; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java index 54f681b0..06035e09 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java @@ -76,13 +76,12 @@ public class EntityPackets1_16_2 extends EntityRewriter biomes = biomeRegistry.getListTag("value", CompoundTag.class); BiomeStorage biomeStorage = wrapper.user().get(BiomeStorage.class); biomeStorage.clear(); - for (Tag biome : biomes) { - CompoundTag biomeCompound = (CompoundTag) biome; - StringTag name = biomeCompound.get("name"); - NumberTag id = biomeCompound.get("id"); + for (CompoundTag biome : biomes) { + StringTag name = biome.get("name"); + NumberTag id = biome.get("id"); biomeStorage.addBiome(name.getValue(), id.asInt()); } } else if (!warned) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java index 5b018c6e..e20a9c18 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java @@ -85,9 +85,9 @@ public final class EntityPackets1_17 extends EntityRewriter { CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome"); - ListTag biomes = biomeRegistry.get("value"); - for (Tag biome : biomes) { - CompoundTag biomeCompound = ((CompoundTag) biome).get("element"); + ListTag biomes = biomeRegistry.getListTag("value", CompoundTag.class); + for (CompoundTag biome : biomes) { + CompoundTag biomeCompound = biome.get("element"); StringTag category = biomeCompound.get("category"); if (category.getValue().equalsIgnoreCase("underground")) { category.setValue("none"); @@ -95,9 +95,9 @@ public final class EntityPackets1_17 extends EntityRewriter dimensions = dimensionRegistry.getListTag("value", CompoundTag.class); + for (CompoundTag dimension : dimensions) { + CompoundTag dimensionCompound = dimension.get("element"); reduceExtendedHeight(dimensionCompound, false); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java index 452e7942..b2880d01 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java @@ -62,9 +62,9 @@ public final class EntityPackets1_18 extends EntityRewriter { final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome"); - final ListTag biomes = biomeRegistry.get("value"); - for (final Tag biome : biomes.getValue()) { - final CompoundTag biomeCompound = ((CompoundTag) biome).get("element"); + final ListTag biomes = biomeRegistry.getListTag("value", CompoundTag.class); + for (final CompoundTag biome : biomes) { + final CompoundTag biomeCompound = biome.get("element"); final StringTag category = biomeCompound.get("category"); if (category.getValue().equals("mountain")) { category.setValue("extreme_hills"); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java index dd60d7bf..48fb0947 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java @@ -102,10 +102,10 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol pagesTag; StringTag titleTag = null; // Sanity checks - if (tag == null || (pagesTag = tag.getListTag("pages")) == null + if (tag == null || (pagesTag = tag.getListTag("pages", StringTag.class)) == null || (signing && (titleTag = tag.getStringTag("title")) == null)) { wrapper.write(Type.VAR_INT, 0); // Pages length wrapper.write(Type.BOOLEAN, false); // Optional title @@ -114,12 +114,12 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol MAX_PAGES) { - pagesTag = new ListTag(pagesTag.getValue().subList(0, MAX_PAGES)); + pagesTag = new ListTag<>(pagesTag.getValue().subList(0, MAX_PAGES)); } wrapper.write(Type.VAR_INT, pagesTag.size()); - for (Tag pageTag : pagesTag) { - String page = ((StringTag) pageTag).getValue(); + for (StringTag pageTag : pagesTag) { + String page = pageTag.getValue(); // Limit page length if (page.length() > MAX_PAGE_LENGTH) { page = page.substring(0, MAX_PAGE_LENGTH); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/BackwardsMappings.java index 4aa7b53a..f6a90d14 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/BackwardsMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/BackwardsMappings.java @@ -23,7 +23,6 @@ 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.ListTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; import org.checkerframework.checker.nullness.qual.Nullable; @@ -39,11 +38,10 @@ public final class BackwardsMappings extends com.viaversion.viabackwards.api.dat protected void loadExtras(final CompoundTag data) { super.loadExtras(data); - final ListTag chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").get("values"); - for (final Tag chatType : chatTypes) { - final CompoundTag chatTypeCompound = (CompoundTag) chatType; - final NumberTag idTag = chatTypeCompound.get("id"); - defaultChatTypes.put(idTag.asInt(), chatTypeCompound); + final ListTag chatTypes = VBMappingDataLoader.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class); + for (final CompoundTag chatType : chatTypes) { + final NumberTag idTag = chatType.get("id"); + defaultChatTypes.put(idTag.asInt(), chatType); } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java index 70d1b981..1d580f04 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java @@ -131,12 +131,11 @@ public final class EntityPackets1_19 extends EntityRewriter dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).getListTag("value", CompoundTag.class); boolean found = false; - for (final Tag dimension : dimensions) { - final CompoundTag dimensionCompound = (CompoundTag) dimension; - final StringTag nameTag = dimensionCompound.get("name"); - final CompoundTag dimensionData = dimensionCompound.get("element"); + for (final CompoundTag dimension : dimensions) { + final StringTag nameTag = dimension.get("name"); + final CompoundTag dimensionData = dimension.get("element"); dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.copy()); if (!found && nameTag.getValue().equals(dimensionKey)) { @@ -150,19 +149,18 @@ public final class EntityPackets1_19 extends EntityRewriter biomes = biomeRegistry.getListTag("value", CompoundTag.class); + for (final CompoundTag biome : biomes.getValue()) { + final CompoundTag biomeCompound = biome.get("element"); biomeCompound.putString("category", "none"); } tracker(wrapper.user()).setBiomesSent(biomes.size()); // Cache and remove chat types - final ListTag chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).get("value"); - for (final Tag chatType : chatTypes) { - final CompoundTag chatTypeCompound = (CompoundTag) chatType; - final NumberTag idTag = chatTypeCompound.get("id"); - dimensionRegistryStorage.addChatType(idTag.asInt(), chatTypeCompound); + final ListTag chatTypes = ((CompoundTag) registry.remove("minecraft:chat_type")).getListTag("value", CompoundTag.class); + for (final CompoundTag chatType : chatTypes) { + final NumberTag idTag = chatType.get("id"); + dimensionRegistryStorage.addChatType(idTag.asInt(), chatType); } }); map(Type.STRING); // World diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/Protocol1_18To1_18_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/Protocol1_18To1_18_2.java index db8a57ad..ac77ff83 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/Protocol1_18To1_18_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/Protocol1_18To1_18_2.java @@ -82,9 +82,9 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol { final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type"); - final ListTag dimensions = dimensionsHolder.get("value"); - for (final Tag dimension : dimensions) { - removeTagPrefix(((CompoundTag) dimension).get("element")); + final ListTag dimensions = dimensionsHolder.getListTag("value", CompoundTag.class); + for (final CompoundTag dimension : dimensions) { + removeTagPrefix(dimension.get("element")); } removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1)); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java index 229b3cb4..d8201cc4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java @@ -82,11 +82,10 @@ public final class EntityPackets1_19_3 extends EntityRewriter chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class); + for (final CompoundTag chatType : chatTypes) { + final NumberTag idTag = chatType.get("id"); + chatTypeStorage.addChatType(idTag.asInt(), chatType); } }); handler(wrapper -> { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java index 4b568f25..cc307660 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java @@ -68,9 +68,9 @@ public final class EntityPackets1_19_4 extends EntityRewriter biomes = biomeRegistry.getListTag("value", CompoundTag.class); + for (final CompoundTag biomeTag : biomes) { + final CompoundTag biomeData = biomeTag.get("element"); final NumberTag hasPrecipitation = biomeData.get("has_precipitation"); biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none"); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/BlockItemPackets1_20.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/BlockItemPackets1_20.java index 8e7f51e6..890585f4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/BlockItemPackets1_20.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/BlockItemPackets1_20.java @@ -218,13 +218,13 @@ public final class BlockItemPackets1_20 extends ItemRewriter messages = frontText.getListTag(filtered ? "filtered_messages" : "messages", StringTag.class); if (messages == null) { return; } int i = 0; - for (final Tag message : messages) { + for (final StringTag message : messages) { tag.put((filtered ? "FilteredText" : "Text") + ++i, message); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/EntityPackets1_20.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/EntityPackets1_20.java index 510c6602..ba45edf5 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/EntityPackets1_20.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_4to1_20/packets/EntityPackets1_20.java @@ -80,20 +80,20 @@ public final class EntityPackets1_20 extends EntityRewriter { final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); - final ListTag values; + final ListTag values; // A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing // on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element final CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern"); if (trimPatternTag != null) { - values = trimPatternTag.getListTag("value"); + values = trimPatternTag.getListTag("value", CompoundTag.class); } else { final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy(); registry.put("minecraft:trim_pattern", trimPatternRegistry); values = trimPatternRegistry.get("value"); } - for (final Tag entry : values) { - final CompoundTag element = ((CompoundTag) entry).get("element"); + for (final CompoundTag entry : values) { + final CompoundTag element = entry.get("element"); final StringTag templateItem = element.get("template_item"); if (newTrimPatterns.contains(Key.stripMinecraftNamespace(templateItem.getValue()))) { templateItem.setValue("minecraft:spire_armor_trim_smithing_template"); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java index 91e8fe7f..0d4fe588 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java @@ -103,11 +103,10 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol chatTypes = registry.getCompoundTag("minecraft:chat_type").getListTag("value", CompoundTag.class); + for (final CompoundTag chatType : chatTypes) { + final NumberTag idTag = chatType.get("id"); + chatTypeStorage.addChatType(idTag.asInt(), chatType); } // Replace with 1.19 chat types diff --git a/gradle.properties b/gradle.properties index 001fb31a..105f14c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=4.9.2 +projectVersion=4.9.3-SNAPSHOT # Smile emoji mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8bcfa4ca..5bbe100d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.1" [versions] # ViaVersion -viaver = "4.9.3-SNAPSHOT" +viaver = "4.9.4-SNAPSHOT" # Common provided netty = "4.0.20.Final"