]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Change "Ping" packet behavior
authorStephen Seo <seo.disparate@gmail.com>
Fri, 25 Oct 2024 06:46:56 +0000 (15:46 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 25 Oct 2024 06:46:56 +0000 (15:46 +0900)
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.

src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java

index c9f057b2dabbb458e4e9573a92b81174e9ce4e78..89d88d17bd86e193c8477b00f7600b800d066cf8 100644 (file)
@@ -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);
         }