From 367c407ec9afa3fad8fcbea6bcffa59b1e61d311 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 25 Oct 2024 15:31:23 +0900 Subject: [PATCH] Minor tweak to "Ping" packet This commit changes the "Ping" packet to not create a client-side Battle instance if it does not exist when the packet is received. --- Changelog.md | 5 +++++ .../common/networking/PacketBattlePing.java | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index f15d880..f0f0a94 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Upcoming changes +# Version NeoForge-1.26.3-MC-1.21.1 + +Tweak to "Ping" packet to not create client-local Battle instance if it does +not exist. + # Version Forge-1.26.2 Show battling Entities next to their attack button in the BattleGUI. diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java index 1901bd0..46e1bf8 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java @@ -31,13 +31,12 @@ public record PacketBattlePing(int battleID, int remainingSeconds) implements Cu @Override public void handle(final @NotNull PacketBattlePing pkt, IPayloadContext ctx) { ctx.enqueueWork(() -> { - if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) { - TurnBasedMinecraftMod.proxy.createLocalBattle(pkt.battleID); + if (TurnBasedMinecraftMod.proxy.getLocalBattle() != null) { + TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); + TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); + TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds); + TurnBasedMinecraftMod.proxy.pauseMCMusic(); } - TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); - TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); - TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.remainingSeconds); - TurnBasedMinecraftMod.proxy.pauseMCMusic(); }).exceptionally(e -> { ctx.disconnect(Component.literal("Exception handling PacketBattlePing! " + e.getMessage())); return null;