From cce65ec76df4e17481070afc05cf32d8b1747e98 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Wed, 10 Aug 2022 14:09:23 +0200 Subject: [PATCH] Ignore expired player public keys during replay These would otherwise fail to be initialized and cause the game to disconnect itself on the first chat message from the corresponding player. --- .../mixin/Mixin_AllowExpiredPlayerKeys.java | 1 + .../resources/mixins.replay.replaymod.json | 3 +++ .../mixin/Mixin_AllowExpiredPlayerKeys.java | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java create mode 100644 versions/1.19/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java diff --git a/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java b/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java new file mode 100644 index 00000000..be37d3e2 --- /dev/null +++ b/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java @@ -0,0 +1 @@ +// 1.19+ only diff --git a/src/main/resources/mixins.replay.replaymod.json b/src/main/resources/mixins.replay.replaymod.json index 02e6fe65..bdd258a6 100644 --- a/src/main/resources/mixins.replay.replaymod.json +++ b/src/main/resources/mixins.replay.replaymod.json @@ -10,6 +10,9 @@ "world_border.Mixin_UseReplayTime_ForMovement", "world_border.Mixin_UseReplayTime_ForTexture", "Mixin_FixNPCSkinCaching", + //#if MC>=11900 + //$$ "Mixin_AllowExpiredPlayerKeys", + //#endif //#if MC>=11800 //$$ "Mixin_FixEntityNotTracking", //#endif diff --git a/versions/1.19/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java b/versions/1.19/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java new file mode 100644 index 00000000..f64cbc08 --- /dev/null +++ b/versions/1.19/src/main/java/com/replaymod/replay/mixin/Mixin_AllowExpiredPlayerKeys.java @@ -0,0 +1,18 @@ +package com.replaymod.replay.mixin; + +import com.replaymod.replay.ReplayModReplay; +import net.minecraft.network.encryption.PlayerPublicKey; +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; + +@Mixin(PlayerPublicKey.PublicKeyData.class) +public abstract class Mixin_AllowExpiredPlayerKeys { + @Inject(method = "isExpired", at = @At("HEAD"), cancellable = true) + private void neverExpireWhenInReplay(CallbackInfoReturnable ci) { + if (ReplayModReplay.instance.getReplayHandler() != null) { + ci.setReturnValue(false); + } + } +}