]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Fix potential client freeze bug 1.17.2
authorStephen Seo <seo.disparate@gmail.com>
Sun, 23 May 2021 06:38:04 +0000 (15:38 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sun, 23 May 2021 06:38:04 +0000 (15:38 +0900)
Changelog.md
build.gradle
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java
src/main/resources/META-INF/mods.toml
src/main/resources/mcmod.info

index 3d170412ecf01c70769d617357b66966d53625ed..5b1b23de5a86aa2cd189f31980491cb568d801fb 100644 (file)
@@ -1,5 +1,9 @@
 # Upcoming changes
 
+# Version 1.17.2
+
+(try to) Fix potential freeze bug when an entity leaves battle.
+
 # Version 1.17.1
 
 Add experimental support for Pam's Harvestcraft foods.
index 00c8933493e474ae8aab11ff72defd82e146c9a1..9f1ee806faf37ed8b4a35f82d5c2c12f4f9f10f9 100644 (file)
@@ -14,7 +14,7 @@ apply plugin: 'eclipse'
 //apply plugin: 'maven-publish'\r
 apply plugin: 'com.github.johnrengelman.shadow'\r
 \r
-version = "1.17.1"\r
+version = "1.17.2"\r
 group = "com.burnedkirby.TurnBasedMinecraft"\r
 archivesBaseName = "TurnBasedMinecraft"\r
 \r
index 14b8c1aa4fc236eb6624fd9ced6e7ed1c632eced..f11d253a6e8f76daeba3a49f5fbe2d48a1516e7b 100644 (file)
@@ -116,53 +116,40 @@ public class ClientProxy extends CommonProxy
     @Override
     public void typeEnteredBattle(String type)
     {
-        if(localBattle == null)
-        {
+        if(localBattle == null) {
             return;
-        }
-        if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type))
-        {
+        } if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
             ++battleMusicCount;
-        }
-        else if(getConfig().isSillyMusicType(type))
-        {
+        } else if(getConfig().isSillyMusicType(type)) {
             ++sillyMusicCount;
-        }
-        else
-        {
+        } else {
             ++battleMusicCount;
         }
-        checkBattleTypes();
+        checkBattleTypes(false);
     }
 
     @Override
     public void typeLeftBattle(String type)
     {
-        if(localBattle == null)
+        if(localBattle == null || localBattle.getSideA().isEmpty() || localBattle.getSideB().isEmpty())
         {
+            battleMusicCount = 0;
+            sillyMusicCount = 0;
             return;
-        }
-        if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type))
-        {
+        } else if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
             --battleMusicCount;
-        }
-        else if(getConfig().isSillyMusicType(type))
-        {
+        } else if(getConfig().isSillyMusicType(type)) {
             --sillyMusicCount;
-        }
-        else
-        {
+        } else {
             --battleMusicCount;
         }
-        checkBattleTypes();
+        checkBattleTypes(true);
     }
 
     @Override
     public void displayString(String message)
     {
         StringTextComponent prefix = new StringTextComponent("TBM: ");
-        // func_240718_a_ is set color
-        // func_240713_a_ is set bold
         prefix.withStyle(prefix.getStyle().withColor(Color.fromRgb(0xFF00FF00)).withBold(true));
         StringTextComponent text = new StringTextComponent(message);
         prefix.getSiblings().add(text);
@@ -178,9 +165,14 @@ public class ClientProxy extends CommonProxy
         Minecraft.getInstance().player.sendMessage(text, UUID.randomUUID());
     }
 
-    private void checkBattleTypes()
+    private void checkBattleTypes(boolean entityLeft)
     {
-        float percentage = 0.0f;
+        // check that battle is still valid
+        if(localBattle == null && entityLeft && (localBattle.getSideA().isEmpty() || localBattle.getSideB().isEmpty())) {
+            return;
+        }
+
+    float percentage = 0.0f;
         if(sillyMusicCount == 0 && battleMusicCount == 0)
         {
             percentage = 0.0f;
index 8d187c028fa397d49ead51cdbfe38a7fe538b51a..1bacc908bf640ca4104bcb14dd19ea0387299158 100644 (file)
@@ -1290,8 +1290,8 @@ public class Battle
                             {
                                 fleeingCategory = "player";
                             }
-                            sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getId(), 0, 1, fleeingCategory);
                             removeCombatant(next);
+                            sendMessageToAllPlayers(PacketBattleMessage.MessageType.FLEE, next.entity.getId(), 0, 1, fleeingCategory);
                         }
                         else
                         {
index ecf63d1ed9276fc23228bf2140f9da2e80496cb4..2deee8f254606db40ac482dcd8686fe2aaaafd52 100644 (file)
@@ -35,7 +35,7 @@ public class TurnBasedMinecraftMod
 {
     public static final String MODID = "com_burnedkirby_turnbasedminecraft";
     public static final String NAME = "Turn Based Minecraft Mod";
-    public static final String VERSION = "1.17.1";
+    public static final String VERSION = "1.17.2";
     public static final String CONFIG_FILENAME = "TBM_Config.toml";
     public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
     public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
index 16d644e353c7005a9484616742a2b13f2e1195d7..99b8c7816fdbbed62a9f235a0c3f59a33b9c1c22 100644 (file)
@@ -15,7 +15,7 @@ license="MIT"
 # The modid of the mod
 modId="com_burnedkirby_turnbasedminecraft" #mandatory
 # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
-version="1.17.1" #mandatory
+version="1.17.2" #mandatory
  # A display name for the mod
 displayName="TurnBasedMinecraftMod" #mandatory
 # A URL to query for updates for this mod. See the JSON update specification <here>
index 297c8dd1ad75e7b669a303ac647e649c049b4695..b61db108df121d8a0a45987d6cb003f957459652 100644 (file)
@@ -3,7 +3,7 @@
   "modid": "com_burnedkirby_turnbasedminecraft",
   "name": "Turn Based Minecraft",
   "description": "Changes battles to be turn-based.",
-  "version": "1.17.1",
+  "version": "1.17.2",
   "mcversion": "1.16.3",
   "url": "",
   "updateUrl": "",