From 6a1b0e044afa0a2100b6304cd6eb94ee1fa158a9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 23 Feb 2022 18:12:15 +0100 Subject: [PATCH] 1.18.2-pre3 --- build.gradle.kts | 2 +- .../Protocol1_18To1_18_2.java | 5 +- .../data/CommandRewriter1_18_2.java | 48 +++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java diff --git a/build.gradle.kts b/build.gradle.kts index e4e433da..c88617f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.2.0-1.18.2-pre1-SNAPSHOT" + version = "4.2.0-1.18.2-pre3-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 6f1c69e5..8b228c01 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 @@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2; import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.data.CommandRewriter1_18_2; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; @@ -38,6 +39,8 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol { final int id = wrapper.read(Type.VAR_INT); if ((byte) id != id) { @@ -78,8 +81,6 @@ 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) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java new file mode 100644 index 00000000..2e6d657a --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java @@ -0,0 +1,48 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2022 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.data; + +import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.rewriter.CommandRewriter; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class CommandRewriter1_18_2 extends CommandRewriter { + + public CommandRewriter1_18_2(Protocol protocol) { + super(protocol); + + // Uncompletable without the full list + this.parserHandlers.put("minecraft:resource", wrapper -> { + wrapper.read(Type.STRING); + wrapper.write(Type.VAR_INT, 1); // Quotable string + }); + this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> { + wrapper.read(Type.STRING); + wrapper.write(Type.VAR_INT, 1); // Quotable string + }); + } + + @Override + protected @Nullable String handleArgumentType(String argumentType) { + if (argumentType.equals("minecraft:resource") || argumentType.equals("minecraft:resource_or_tag")) { + return "brigadier:string"; + } + return super.handleArgumentType(argumentType); + } +}