diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientCommonNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientCommonNetworkHandler.java new file mode 100644 index 00000000..7cf34ff8 --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinClientCommonNetworkHandler.java @@ -0,0 +1,52 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2024 FlorianMichael/EnZaXD 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 . + */ + +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import de.florianmichael.viafabricplus.settings.impl.DebugSettings; +import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.DisconnectionInfo; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.nio.file.Path; +import java.util.Optional; + +@Mixin(ClientCommonNetworkHandler.class) +public abstract class MixinClientCommonNetworkHandler { + + @Inject(method = "savePacketErrorReport", at = @At("HEAD"), cancellable = true) + private void dontCreatePacketErrorCrashReports(CallbackInfoReturnable> cir) { + if (DebugSettings.global().dontCreatePacketErrorCrashReports.isEnabled()) { + cir.setReturnValue(Optional.empty()); + } + } + + @WrapWithCondition(method = "onPacketException", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;disconnect(Lnet/minecraft/network/DisconnectionInfo;)V")) + private boolean dontDisconnectOnPacketException(ClientConnection instance, DisconnectionInfo disconnectionInfo) { + return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_20_3); + } + +} diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java index b19f9ccb..bb1a7600 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java @@ -33,7 +33,6 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.VersionType; import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; -import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5; import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback; import de.florianmichael.viafabricplus.fixes.viaversion.ViaFabricPlusProtocol; import de.florianmichael.viafabricplus.injection.access.IClientConnection; @@ -342,7 +341,6 @@ public class ProtocolTranslator { ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new ); - Protocol1_20_3To1_20_5.strictErrorHandling = false; ProtocolVersion.register(AUTO_DETECT_PROTOCOL); ViaFabricPlusProtocol.INSTANCE.initialize(); }); diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java index a47640c1..a08f812b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java @@ -35,6 +35,9 @@ public class DebugSettings extends SettingGroup { public final BooleanSetting printNetworkingErrorsToLogs = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.print_networking_errors_to_logs"), true); public final BooleanSetting ignoreFabricSyncErrors = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.ignore_fabric_sync_errors"), false); + // 1.20.5 -> 1.20.4 + public final VersionedBooleanSetting dontCreatePacketErrorCrashReports = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.dont_create_packet_error_crash_reports"), VersionRange.andOlder(ProtocolVersion.v1_20_3)); + // 1.19 -> 1.18.2 public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.disable_sequencing"), VersionRange.andOlder(ProtocolVersion.v1_18_2)); diff --git a/src/main/resources/assets/viafabricplus/lang/en_us.json b/src/main/resources/assets/viafabricplus/lang/en_us.json index 8ee630f0..03459597 100644 --- a/src/main/resources/assets/viafabricplus/lang/en_us.json +++ b/src/main/resources/assets/viafabricplus/lang/en_us.json @@ -63,6 +63,7 @@ "debug_settings.viafabricplus.prevent_entity_cramming": "Prevent entity cramming", "debug_settings.viafabricplus.always_tick_client_player": "Always tick client player", "debug_settings.viafabricplus.print_networking_errors_to_logs": "Print networking errors to logs", + "debug_settings.viafabricplus.dont_create_packet_error_crash_reports": "Don't create packet error crash reports", "debug_settings.viafabricplus.ignore_fabric_sync_errors": "Ignore Fabric sync errors", "debug_settings.viafabricplus.legacy_tab_completions": "Legacy tab completions", diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 6b76a6e1..e2ba6600 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -42,6 +42,7 @@ "fixes.minecraft.MixinCamera", "fixes.minecraft.MixinChatInputSuggestor", "fixes.minecraft.MixinClientCommandSource", + "fixes.minecraft.MixinClientCommonNetworkHandler", "fixes.minecraft.MixinClientWorld", "fixes.minecraft.MixinFlowableFluid", "fixes.minecraft.MixinFontStorage",