From afe3584b70745be0005b999575b6fa3abbd8db2c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 18 Feb 2022 18:33:34 +0100 Subject: [PATCH] 1.18.2 pre1 --- build.gradle.kts | 2 +- .../Protocol1_18To1_18_2.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b7c9158c..e4e433da 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.2.0-22w06a-SNAPSHOT" + version = "4.2.0-1.18.2-pre1-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 ddae054b..6f1c69e5 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 @@ -17,7 +17,10 @@ */ package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2; +import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; @@ -35,6 +38,34 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol { + final int id = wrapper.read(Type.VAR_INT); + if ((byte) id != id) { + if (!Via.getConfig().isSuppressConversionWarnings()) { + ViaBackwards.getPlatform().getLogger().warning("Cannot send entity effect id " + id + " to old client"); + } + wrapper.cancel(); + return; + } + + wrapper.write(Type.BYTE, (byte) id); + }; + registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Entity id + handler(entityEffectIdHandler); + } + }); + + registerClientbound(ClientboundPackets1_18.REMOVE_ENTITY_EFFECT, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Entity id + handler(entityEffectIdHandler); + } + }); + registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() { @Override public void registerMap() {