Fixed ViaBedrock implementation not working

This commit is contained in:
FlorianMichael 2023-10-07 23:27:26 +02:00
parent 0f4a042ed6
commit b3bd7c16f7
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 9 additions and 12 deletions

View File

@ -36,7 +36,7 @@ public class MixinClientConnection_1 {
@Shadow
ClientConnection field_11663;
@Inject(method = "initChannel", at = @At("TAIL"))
@Inject(method = "initChannel", at = @At("RETURN"))
public void hackNettyPipeline(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
ProtocolHack.injectVLBPipeline(field_11663, channel, ((IClientConnection) field_11663).viafabricplus_capturedAddress());

View File

@ -26,9 +26,6 @@ import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.handler.PacketSizeLogger;
import net.minecraft.util.Lazy;
import net.minecraft.util.profiler.PerformanceLog;
import org.cloudburstmc.netty.channel.raknet.RakChannelFactory;
import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
import org.jetbrains.annotations.NotNull;
@ -45,6 +42,10 @@ public class RakNetClientConnection {
final Bootstrap nettyBoostrap = new Bootstrap().group(eventLoopGroup).handler(new ChannelInitializer<>() {
@Override
protected void initChannel(@NotNull Channel channel) {
// Mojang Code start
ClientConnection.setHandlers(channel);
// Mojang Code end
try {
channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11);
channel.config().setOption(RakChannelOption.RAK_CONNECT_TIMEOUT, 4_000L);
@ -52,10 +53,12 @@ public class RakNetClientConnection {
channel.config().setOption(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong());
} catch (Exception ignored) {
}
// Mojang Code start
ChannelPipeline channelPipeline = channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30));
ClientConnection.addHandlers(channelPipeline, NetworkSide.CLIENTBOUND, clientConnection.packetSizeLogger);
channelPipeline.addLast("packet_handler", clientConnection);
clientConnection.addFlowControlHandler(channelPipeline);
// Mojang Code end
ProtocolHack.injectVLBPipeline(clientConnection, channel, address);
}

View File

@ -31,20 +31,14 @@ import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.NetworkState;
import net.minecraft.network.handler.PacketSizeLogger;
import net.minecraft.network.listener.ClientQueryPacketListener;
import net.minecraft.network.packet.c2s.handshake.ConnectionIntent;
import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket;
import net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket;
import net.minecraft.network.packet.s2c.query.PingResultS2CPacket;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.minecraft.text.Text;
import net.minecraft.util.profiler.PerformanceLog;
import net.raphimc.vialoader.util.VersionEnum;
import org.jetbrains.annotations.NotNull;