diff --git a/Changelog.md b/Changelog.md index 959fb2d..ace7f4a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Upcoming changes +# Version 1.21.1 + +Refactored checking-if-in-battle code to be more efficient. + # Version 1.21.0 Updated mod to use forge-1.19.2-43.1.1 diff --git a/build.gradle b/build.gradle index 4f3bc81..05f0321 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle' //apply plugin: 'eclipse' //apply plugin: 'maven-publish' -version = "1.21.0" +version = "1.21.1" group = "com.burnedkirby.TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft" diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.java index ab8778f..688d841 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/BattleManager.java @@ -352,12 +352,6 @@ public class BattleManager } public boolean isInBattle(int entityID) { - for (Battle battle : battleMap.values()) { - if (battle.hasCombatant(entityID)) { - return true; - } - } - - return false; + return entityToBattleMap.keySet().parallelStream().anyMatch(pair -> pair.id == entityID); } } \ No newline at end of file diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/HurtEventHandler.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/HurtEventHandler.java index 551ff7c..5a39f94 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/HurtEventHandler.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/HurtEventHandler.java @@ -9,8 +9,7 @@ public class HurtEventHandler { CommonProxy proxy = TurnBasedMinecraftMod.proxy; if (event.getEntity().level.isClientSide || proxy.getBattleManager() == null) { return; - } else if (proxy.getBattleManager().isInBattle(event.getEntity().getId()) - && proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().msgId)) { + } else if (proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().msgId) && proxy.getBattleManager().isInBattle(event.getEntity().getId())) { event.setCanceled(true); } } diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index 6df888c..53cf919 100644 --- a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -39,7 +39,7 @@ import org.apache.logging.log4j.Logger; 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.21.0"; + public static final String VERSION = "1.21.1"; 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/"; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a625005..b172066 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -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.21.0" #mandatory +version="1.21.1" #mandatory # A display name for the mod displayName="TurnBasedMinecraftMod" #mandatory # A URL to query for updates for this mod. See the JSON update specification diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 94b3ced..bafbd81 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "com_burnedkirby_turnbasedminecraft", "name": "Turn Based Minecraft", "description": "Changes battles to be turn-based.", - "version": "1.21.0", + "version": "1.21.1", "mcversion": "1.18.2", "url": "", "updateUrl": "",