Skip to content

Commit

Permalink
Fixed ViaBedrock implementation not working
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 7, 2023
1 parent 0f4a042 commit b3bd7c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
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;
Expand All @@ -45,17 +42,23 @@ public static ChannelFuture connectRakNet(final ClientConnection clientConnectio
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);
channel.config().setOption(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L);
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,14 @@
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;

Expand Down

0 comments on commit b3bd7c1

Please sign in to comment.