From fde09d116dccbf9a2848809851daab49c576e884 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 25 Oct 2024 15:46:56 +0900 Subject: [PATCH] Change "Ping" packet behavior Changed "Ping" packet to not create client-local Battle instance when received, but rather only act if client-local Battle instance exists. This change was also made on the neoforge branches. --- .../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 c9f057b..89d88d1 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java @@ -46,13 +46,12 @@ public class PacketBattlePing { @Override public void accept(PacketBattlePing pkt, CustomPayloadEvent.Context 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.decisionSeconds); + TurnBasedMinecraftMod.proxy.pauseMCMusic(); } - TurnBasedMinecraftMod.proxy.setBattleGuiAsGui(); - TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged(); - TurnBasedMinecraftMod.proxy.setBattleGuiTime(pkt.decisionSeconds); - TurnBasedMinecraftMod.proxy.pauseMCMusic(); }); ctx.setPacketHandled(true); }