Move out handshake accessor interface

This commit is contained in:
FlorianMichael 2024-04-21 18:26:59 +02:00
parent fc1bd8a1cc
commit 56b3e56c9f
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
4 changed files with 10 additions and 9 deletions

View File

@ -10,7 +10,7 @@
Allows the connection to/from different Minecraft versions on your Minecraft client/server (LAN worlds too) Allows the connection to/from different Minecraft versions on your Minecraft client/server (LAN worlds too)
This mod can be installed on 1.8.9, 1.12.2, 1.14.4, 1.15.2, 1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.20.4 with Fabric Loader. This mod can be installed on 1.8.9, 1.12.2, 1.14.4, 1.15.2, 1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.20.4, 1.20.5 with Fabric Loader.
## Dependencies ## Dependencies

View File

@ -1,12 +1,12 @@
package com.viaversion.fabric.mc1122.mixin.pipeline.client; package com.viaversion.fabric.mc1122.mixin.pipeline.client;
import com.viaversion.fabric.mc1122.service.ProtocolAutoDetector; import com.viaversion.fabric.mc1122.service.HandshakeInterceptor;
import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(HandshakeC2SPacket.class) @Mixin(HandshakeC2SPacket.class)
public class MixinHandshakeC2SPacket implements ProtocolAutoDetector.IHandshakeC2SPacket { public class MixinHandshakeC2SPacket implements HandshakeInterceptor {
@Shadow @Shadow
private int protocolVersion; private int protocolVersion;

View File

@ -0,0 +1,6 @@
package com.viaversion.fabric.mc1122.service;
public interface HandshakeInterceptor {
void viaFabric$setProtocolVersion(final int version);
}

View File

@ -113,7 +113,7 @@ public class ProtocolAutoDetector {
HandshakeC2SPacket handshakeC2SPacket = new HandshakeC2SPacket(address.getHostString(), HandshakeC2SPacket handshakeC2SPacket = new HandshakeC2SPacket(address.getHostString(),
address.getPort(), NetworkState.STATUS); address.getPort(), NetworkState.STATUS);
((IHandshakeC2SPacket) handshakeC2SPacket).viaFabric$setProtocolVersion( ((HandshakeInterceptor) handshakeC2SPacket).viaFabric$setProtocolVersion(
Via.getAPI().getServerVersion().lowestSupportedVersion()); Via.getAPI().getServerVersion().lowestSupportedVersion());
clientConnection.send(handshakeC2SPacket); clientConnection.send(handshakeC2SPacket);
clientConnection.send(new QueryRequestC2SPacket()); clientConnection.send(new QueryRequestC2SPacket());
@ -138,9 +138,4 @@ public class ProtocolAutoDetector {
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }
} }
public interface IHandshakeC2SPacket {
void viaFabric$setProtocolVersion(final int version);
}
} }