mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-03-14 13:49:09 +01:00
re-implemented all protocol fixes, added new HUD variables for forced version
This commit is contained in:
parent
008523c103
commit
d1ce29e76a
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.definition;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.platform.ComparableProtocolVersion;
|
||||
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
|
||||
public class ServerAddressReplacement {
|
||||
private final static ProtocolRange SRV_RANGE = new ProtocolRange(ProtocolVersion.v1_16_4, LegacyProtocolVersion.r1_3_1tor1_3_2);
|
||||
|
||||
public static ServerAddress parse(final ComparableProtocolVersion version, String address) {
|
||||
final ServerAddress mc = ServerAddress.parse(address);
|
||||
if (version != null && (SRV_RANGE.contains(version) || version.isEqualTo(BedrockProtocolVersion.bedrockLatest))) {
|
||||
if (!mc.equals(ServerAddress.INVALID)) {
|
||||
return AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(mc).orElse(mc);
|
||||
}
|
||||
}
|
||||
return mc;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ package de.florianmichael.viafabricplus.information.impl;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.information.AbstractInformationGroup;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -32,6 +33,7 @@ public class GeneralInformation extends AbstractInformationGroup {
|
||||
@Override
|
||||
public void applyInformation(UserConnection userConnection, List<String> output) {
|
||||
output.add("Pipeline count: " + userConnection.getProtocolInfo().getPipeline().pipes().size());
|
||||
output.add("Target version: " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
output.add("Selected version (in the GUI): " + ViaLoadingBase.getClassWrapper().getTargetVersion().getName() + " (" + ViaLoadingBase.getClassWrapper().getTargetVersion().getVersion() + ")");
|
||||
output.add("Connected version: " + ProtocolHack.getTargetVersion().getName() + " (" + ProtocolHack.getTargetVersion().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class MixinMultiplayerServerListPinger {
|
||||
ProtocolHack.getForcedVersions().put(inetSocketAddress, version);
|
||||
}
|
||||
|
||||
if (ProtocolHack.isSelectedOrForced(inetSocketAddress, BedrockProtocolVersion.bedrockLatest)) {
|
||||
if (ProtocolHack.isEqualToOrForced(inetSocketAddress, BedrockProtocolVersion.bedrockLatest)) {
|
||||
ProtocolHack.getRakNetPingSessions().add(inetSocketAddress);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ public class MixinAddServerScreen extends Screen {
|
||||
this.addDrawableChild(ButtonWidget.
|
||||
builder(Text.literal(forcedVersion == null ? "Set version for this server" :forcedVersion.getName()), button ->
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viafabricplus_forceVersion(version)))).
|
||||
position(width - (forcedVersion == null ? 150 : 98) - 5, 5).
|
||||
size(forcedVersion == null ? 150 : 98, 20).build());
|
||||
position(width - (forcedVersion == null ? 150 : 98) - 5, 5).size(forcedVersion == null ? 150 : 98, 20).build());
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
|
||||
import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerAddress.class)
|
||||
public class MixinServerAddress {
|
||||
|
||||
// @Shadow @Final private static ServerAddress INVALID;
|
||||
//
|
||||
// @Unique
|
||||
// private final static ProtocolRange viafabricplus_srvRange = new ProtocolRange(ProtocolVersion.v1_16_4, LegacyProtocolVersion.r1_3_1tor1_3_2);
|
||||
//
|
||||
// @Inject(method = "parse", at = @At("RETURN"), cancellable = true)
|
||||
// private static void fixAddress(String address, CallbackInfoReturnable<ServerAddress> cir) {
|
||||
// if (!cir.getReturnValue().equals(INVALID) && (viafabricplus_srvRange.contains(ProtocolHack.getTargetVersion()) || ProtocolHack.getTargetVersion().isEqualTo(BedrockProtocolVersion.bedrockLatest))) {
|
||||
// cir.setReturnValue(AllowedAddressResolver.DEFAULT.redirectResolver.lookupRedirect(cir.getReturnValue()).orElse(cir.getReturnValue()));
|
||||
// }
|
||||
// }
|
||||
}
|
@ -68,7 +68,7 @@ public class MixinConnectScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getHostName()Ljava/lang/String;", ordinal = 1))
|
||||
public String replaceAddress(InetSocketAddress instance) {
|
||||
if (ProtocolHack.isOrOlderSelectedOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isSelectedOrForced(instance, BedrockProtocolVersion.bedrockLatest))
|
||||
if (ProtocolHack.isOlderThanOrEqualToOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isEqualToOrForced(instance, BedrockProtocolVersion.bedrockLatest))
|
||||
return field_33737.getAddress();
|
||||
|
||||
return instance.getHostString();
|
||||
@ -76,7 +76,7 @@ public class MixinConnectScreen_1 {
|
||||
|
||||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/net/InetSocketAddress;getPort()I"))
|
||||
public int replacePort(InetSocketAddress instance) {
|
||||
if (ProtocolHack.isOrOlderSelectedOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isSelectedOrForced(instance, BedrockProtocolVersion.bedrockLatest))
|
||||
if (ProtocolHack.isOlderThanOrEqualToOrForced(instance, ProtocolVersion.v1_17) || ProtocolHack.isEqualToOrForced(instance, BedrockProtocolVersion.bedrockLatest))
|
||||
return field_33737.getPort();
|
||||
|
||||
return instance.getPort();
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.ServerAddressReplacement;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public class MixinMultiplayerScreen {
|
||||
|
||||
@Unique
|
||||
private ServerInfo viafabricplus_lastConnect;
|
||||
|
||||
@Inject(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD"))
|
||||
public void track(ServerInfo entry, CallbackInfo ci) {
|
||||
viafabricplus_lastConnect = entry;
|
||||
}
|
||||
|
||||
@Redirect(method = "connect(Lnet/minecraft/client/network/ServerInfo;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
public ServerAddress doOwnParse(String address) {
|
||||
return ServerAddressReplacement.parse(((IServerInfo) viafabricplus_lastConnect).viafabricplus_forcedVersion(), address);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.definition.ServerAddressReplacement;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import net.minecraft.client.network.MultiplayerServerListPinger;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MultiplayerServerListPinger.class)
|
||||
public class MixinMultiplayerServerListPinger {
|
||||
|
||||
@Unique
|
||||
private ServerInfo viafabricplus_lastConnect;
|
||||
|
||||
@Inject(method = "add", at = @At("HEAD"))
|
||||
public void track(ServerInfo entry, Runnable saver, CallbackInfo ci) {
|
||||
viafabricplus_lastConnect = entry;
|
||||
}
|
||||
|
||||
@Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerAddress;parse(Ljava/lang/String;)Lnet/minecraft/client/network/ServerAddress;"))
|
||||
public ServerAddress doOwnParse(String address) {
|
||||
return ServerAddressReplacement.parse(((IServerInfo) viafabricplus_lastConnect).viafabricplus_forcedVersion(), address);
|
||||
}
|
||||
}
|
@ -67,6 +67,7 @@ public class ProtocolHack {
|
||||
|
||||
public static ComparableProtocolVersion getTargetVersion() {
|
||||
if (MinecraftClient.getInstance() == null || MinecraftClient.getInstance().getNetworkHandler() == null) return getTargetVersion(null);
|
||||
|
||||
return getTargetVersion(MinecraftClient.getInstance().getNetworkHandler().getConnection().channel);
|
||||
}
|
||||
|
||||
@ -84,13 +85,13 @@ public class ProtocolHack {
|
||||
return rakNetPingSessions;
|
||||
}
|
||||
|
||||
public static boolean isSelectedOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
|
||||
public static boolean isEqualToOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
|
||||
if (forcedVersions.containsKey(socketAddress)) return forcedVersions.get(socketAddress).isEqualTo(version);
|
||||
|
||||
return ProtocolHack.getTargetVersion().isEqualTo(version);
|
||||
}
|
||||
|
||||
public static boolean isOrOlderSelectedOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
|
||||
public static boolean isOlderThanOrEqualToOrForced(final InetSocketAddress socketAddress, final ProtocolVersion version) {
|
||||
if (forcedVersions.containsKey(socketAddress)) return forcedVersions.get(socketAddress).isOlderThanOrEqualTo(version);
|
||||
|
||||
return ProtocolHack.getTargetVersion().isEqualTo(version);
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "${version}",
|
||||
|
||||
"name": "ViaFabricPlus",
|
||||
"description": "Clientside ViaVersion, ViaLegacy, ViaBedrock and ViaAprilFools implementation with clientside fixes for Fabric",
|
||||
"description": "Fabric mod to connect to EVERY minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay",
|
||||
"authors": [
|
||||
"FlorianMichael/EnZaXD"
|
||||
],
|
||||
|
@ -4,5 +4,6 @@ accessible field net/minecraft/client/network/AllowedAddressResolver redirectRes
|
||||
accessible field net/minecraft/item/Item ATTACK_DAMAGE_MODIFIER_ID Ljava/util/UUID;
|
||||
accessible field net/minecraft/client/gui/screen/ConnectScreen connection Lnet/minecraft/network/ClientConnection;
|
||||
accessible field net/minecraft/network/ClientConnection channel Lio/netty/channel/Channel;
|
||||
accessible field net/minecraft/client/network/ServerAddress INVALID Lnet/minecraft/client/network/ServerAddress;
|
||||
|
||||
accessible class net/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection
|
||||
|
@ -30,7 +30,6 @@
|
||||
"fixes.minecraft.MixinPlayerEntityRenderer",
|
||||
"fixes.minecraft.MixinPlayerPublicKey_PublicKeyData",
|
||||
"fixes.minecraft.MixinProfileKeysImpl",
|
||||
"fixes.minecraft.MixinServerAddress",
|
||||
"fixes.minecraft.MixinServerResourcePackProvider",
|
||||
"fixes.minecraft.MixinStringHelper",
|
||||
"fixes.minecraft.block.MixinAbstractBlock",
|
||||
@ -107,6 +106,8 @@
|
||||
"fixes.minecraft.screen.MixinGameModeSelectionScreen",
|
||||
"fixes.minecraft.screen.MixinGameModeSelectionScreen_GameModeSelection",
|
||||
"fixes.minecraft.screen.MixinJigsawBlockScreen",
|
||||
"fixes.minecraft.screen.MixinMultiplayerScreen",
|
||||
"fixes.minecraft.screen.MixinMultiplayerServerListPinger",
|
||||
"fixes.minecraft.screen.MixinStructureBlockScreen_1",
|
||||
"fixes.minecraft.screen.merchant.MixinMerchantScreen",
|
||||
"fixes.minecraft.screen.merchant.MixinMerchantScreenHandler",
|
||||
|
Loading…
Reference in New Issue
Block a user