]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Minor tweak to "Ping" packet
authorStephen Seo <seo.disparate@gmail.com>
Fri, 25 Oct 2024 06:31:23 +0000 (15:31 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 25 Oct 2024 06:31:23 +0000 (15:31 +0900)
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
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattlePing.java

index f15d880eab023807d87ad1e33442d80660ed2593..f0f0a943e4cde47f8ef2c03fc5c1be8eef72cfed 100644 (file)
@@ -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.
index 1901bd0caf35a5b04c13865712fb1236395d895e..46e1bf87425c8a8f3746e9c6e927ee6cbf005d8d 100644 (file)
@@ -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;