1.18.2 pre1

This commit is contained in:
Nassim Jahnke 2022-02-18 18:33:34 +01:00
parent d8096e7f2e
commit afe3584b70
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 32 additions and 1 deletions

View File

@ -5,7 +5,7 @@ plugins {
allprojects { allprojects {
group = "com.viaversion" 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." description = "Allow older clients to join newer server versions."
} }

View File

@ -17,7 +17,10 @@
*/ */
package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2; package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol; 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.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@ -35,6 +38,34 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
@Override @Override
protected void registerPackets() { protected void registerPackets() {
final PacketHandler entityEffectIdHandler = wrapper -> {
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() { registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {