# Upcoming changes
+# Version 1.21.2
+
+Refactored checking-if-in-battle code from `O(n)` to `O(1)` complexity.
+(In other words, utilizes the HashMap's constant time lookup of a key instead of
+checking every key's id if the entity's id is the same. This speeds up the
+lookup from linear to constant time.)
+
# Version 1.21.1
Refactored checking-if-in-battle code to be more efficient.
//apply plugin: 'eclipse'
//apply plugin: 'maven-publish'
-version = "1.21.1"
+version = "1.21.2"
group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft"
return result;
}
- public boolean isInBattle(int entityID) {
- return entityToBattleMap.keySet().parallelStream().anyMatch(pair -> pair.id == entityID);
+ public boolean isInBattle(Entity entity) {
+ return entityToBattleMap.keySet().contains(new EntityIDDimPair(entity));
}
}
\ No newline at end of file
CommonProxy proxy = TurnBasedMinecraftMod.proxy;
if (event.getEntity().level.isClientSide || proxy.getBattleManager() == null) {
return;
- } else if (proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().msgId) && proxy.getBattleManager().isInBattle(event.getEntity().getId())) {
+ } else if (proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().msgId) && proxy.getBattleManager().isInBattle(event.getEntity())) {
event.setCanceled(true);
}
}
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.1";
+ public static final String VERSION = "1.21.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/";
# 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.1" #mandatory
+version="1.21.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>
"modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.",
- "version": "1.21.1",
+ "version": "1.21.2",
"mcversion": "1.18.2",
"url": "",
"updateUrl": "",