|
| 1 | +/* |
| 2 | + * This file is a part of the Raknetify project, licensed under MIT. |
| 3 | + * |
| 4 | + * Copyright (c) 2022-2025 ishland |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +package com.ishland.raknetify.fabric.mixin.client; |
| 26 | + |
| 27 | +import com.ishland.raknetify.common.util.PrefixUtil; |
| 28 | +import com.ishland.raknetify.fabric.common.connection.RakNetClientConnectionUtil; |
| 29 | +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 30 | +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
| 31 | +import net.minecraft.client.network.MultiplayerServerListPinger; |
| 32 | +import net.minecraft.client.network.ServerInfo; |
| 33 | +import net.minecraft.network.ClientConnection; |
| 34 | +import net.minecraft.network.NetworkingBackend; |
| 35 | +import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl; |
| 36 | +import org.spongepowered.asm.mixin.Mixin; |
| 37 | +import org.spongepowered.asm.mixin.injection.At; |
| 38 | + |
| 39 | +import java.net.InetSocketAddress; |
| 40 | + |
| 41 | +@Mixin(MultiplayerServerListPinger.class) |
| 42 | +public class MixinMultiplayerServerListPinger1_21_11 { |
| 43 | + |
| 44 | + @WrapOperation(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;Lnet/minecraft/network/NetworkingBackend;Lnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;")) |
| 45 | + private ClientConnection redirectConnect(InetSocketAddress address, NetworkingBackend backend, MultiValueDebugSampleLogImpl packetSizeLog, Operation<ClientConnection> original, ServerInfo entry) { |
| 46 | + final PrefixUtil.Info info = PrefixUtil.getInfo(entry.address); |
| 47 | + return info.useRakNet() ? RakNetClientConnectionUtil.connect(address, backend, info.largeMTU(), original) : original.call(address, backend, null); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments