Enable experimental 1.21 features for 1.20 clients

Fixes #790
This commit is contained in:
Nassim Jahnke 2024-06-17 11:59:38 +02:00
parent c5dacad81e
commit 14e208e9d7
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
3 changed files with 9 additions and 6 deletions

View File

@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPac
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import java.util.Arrays;
import com.viaversion.viaversion.util.ArrayUtil;
public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
@ -75,10 +75,7 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol<ClientboundPac
registerClientbound(ClientboundPackets1_19_4.UPDATE_ENABLED_FEATURES, wrapper -> {
String[] enabledFeatures = wrapper.read(Types.STRING_ARRAY);
final int length = enabledFeatures.length;
enabledFeatures = Arrays.copyOf(enabledFeatures, length + 1);
enabledFeatures[length] = "minecraft:update_1_20";
wrapper.write(Types.STRING_ARRAY, enabledFeatures);
wrapper.write(Types.STRING_ARRAY, ArrayUtil.add(enabledFeatures, "minecraft:update_1_20"));
});
registerClientbound(ClientboundPackets1_19_4.PLAYER_COMBAT_END, wrapper -> {

View File

@ -45,6 +45,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacke
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.ArrayUtil;
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
@ -174,6 +175,11 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol<ClientboundPac
wrapper.set(Types.VAR_INT, 1, newSize);
}
});
registerClientbound(ClientboundConfigurationPackets1_21.UPDATE_ENABLED_FEATURES, wrapper -> {
final String[] enabledFeatures = wrapper.read(Types.STRING_ARRAY);
wrapper.write(Types.STRING_ARRAY, ArrayUtil.add(enabledFeatures, "minecraft:update_1_21"));
});
}
@Override

View File

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions]
# ViaVersion
viaver = "5.0.0"
viaver = "5.0.1-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"