From 52698423d00955f1beec858bbed1ce9e4e3c4e5d Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 9 Feb 2022 18:57:28 +0100 Subject: [PATCH] 22w06a --- build.gradle.kts | 2 +- .../Protocol1_18To1_18_2.java | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 52b366ff..b7c9158c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.2.0-22w03a-SNAPSHOT" + version = "4.2.0-22w06a-SNAPSHOT" description = "Allow older clients to join newer server versions." } 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 d501d4bf..039685b7 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 @@ -18,6 +18,12 @@ package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2; import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; +import com.viaversion.viaversion.api.type.Type; +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.StringTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; @@ -26,4 +32,42 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol { + final CompoundTag registry = wrapper.get(Type.NBT, 0); + registry.remove("minecraft:worldgen/configured_feature"); + + final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type"); + final ListTag dimensions = dimensionsHolder.get("value"); + for (final Tag dimension : dimensions) { + removeTagPrefix(((CompoundTag) dimension).get("element")); + } + + removeTagPrefix(wrapper.get(Type.NBT, 1)); + }); + } + }); + } + + private void removeTagPrefix(CompoundTag tag) { + final Tag infiniburnTag = tag.get("infiniburn"); + if (infiniburnTag instanceof StringTag) { + final StringTag infiniburn = (StringTag) infiniburnTag; + if (infiniburn.getValue().startsWith("#")) { + infiniburn.setValue(infiniburn.getValue().substring(1)); + } + } + } }