From 570c68c675ce15747a833dcb305c9db2799aff95 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 25 Oct 2024 15:23:44 +0900 Subject: [PATCH] Minor refactoring Do not create Battle instance client-side from received "Ping" packet. --- .../common/networking/PacketBattlePing.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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;