Move game options fix into correct package

This commit is contained in:
FlorianMichael 2024-05-25 21:47:03 +02:00
parent 473fe49b69
commit e01522c2fa
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 47 additions and 18 deletions

View File

@ -0,0 +1,46 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
* Copyright (C) 2023-2024 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.base.connect;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import net.minecraft.client.option.GameOptions;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(GameOptions.class)
public class MixinGameOptions {
@Shadow
public boolean useNativeTransport;
/**
* @author RK_01
* @reason Needed as an indicator if the client wants to ping a server or connect to a server
*/
@Overwrite
public boolean shouldUseNativeTransport() {
if (!this.useNativeTransport) {
ViaFabricPlus.global().getLogger().error("Native transport is disabled, but enabling it anyway since we use it as an indicator if the client wants to ping a server or connect to a server.");
}
return true;
}
}

View File

@ -20,21 +20,15 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.GameOptions;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(GameOptions.class) @Mixin(GameOptions.class)
public abstract class MixinGameOptions { public abstract class MixinGameOptions {
@Shadow
public boolean useNativeTransport;
@ModifyVariable(method = "setServerViewDistance", at = @At("HEAD"), ordinal = 0, argsOnly = true) @ModifyVariable(method = "setServerViewDistance", at = @At("HEAD"), ordinal = 0, argsOnly = true)
private int changeServerViewDistance(int viewDistance) { private int changeServerViewDistance(int viewDistance) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
@ -44,16 +38,4 @@ public abstract class MixinGameOptions {
} }
} }
/**
* @author RK_01
* @reason Needed as an indicator if the client wants to ping a server or connect to a server
*/
@Overwrite
public boolean shouldUseNativeTransport() {
if (!this.useNativeTransport) {
ViaFabricPlus.global().getLogger().error("Native transport is disabled, but enabling it anyway since we use it as an indicator if the client wants to ping a server or connect to a server.");
}
return true;
}
} }

View File

@ -10,6 +10,7 @@
"base.connect.MixinClientConnection_1", "base.connect.MixinClientConnection_1",
"base.connect.MixinClientLoginNetworkHandler", "base.connect.MixinClientLoginNetworkHandler",
"base.connect.MixinConnectScreen_1", "base.connect.MixinConnectScreen_1",
"base.connect.MixinGameOptions",
"base.integration.MixinAddServerScreen", "base.integration.MixinAddServerScreen",
"base.integration.MixinChunkTracker", "base.integration.MixinChunkTracker",
"base.integration.MixinClientConnection", "base.integration.MixinClientConnection",