diff --git a/build.gradle b/build.gradle index fcbbe05..392cefc 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "1.12.2-1.2.1" +version = "1.12.2-1.3.1" group= "net.profhugo.nodami" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "nodami" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 30d399d..29953ea 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e18cba7..2e6e589 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Sep 14 12:28:28 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip diff --git a/lib/snakeyaml-1.30-sources.jar b/lib/snakeyaml-1.30-sources.jar new file mode 100644 index 0000000..8de54b0 Binary files /dev/null and b/lib/snakeyaml-1.30-sources.jar differ diff --git a/lib/snakeyaml-1.30.jar b/lib/snakeyaml-1.30.jar new file mode 100644 index 0000000..6c9b2bc Binary files /dev/null and b/lib/snakeyaml-1.30.jar differ diff --git a/src/main/java/profhugo/nodami/NoDamI.java b/src/main/java/profhugo/nodami/NoDamI.java index 0977cb0..629c128 100644 --- a/src/main/java/profhugo/nodami/NoDamI.java +++ b/src/main/java/profhugo/nodami/NoDamI.java @@ -12,7 +12,7 @@ public class NoDamI { public static final String MODID = "nodami"; public static final String NAME = "No Damage Immunity"; - public static final String VERSION = "1.2.1"; + public static final String VERSION = "1.3.1"; @Mod.Instance(MODID) public static NoDamI instance; diff --git a/src/main/java/profhugo/nodami/config/NodamiConfig.java b/src/main/java/profhugo/nodami/config/NodamiConfig.java index 0478191..bcc17e9 100644 --- a/src/main/java/profhugo/nodami/config/NodamiConfig.java +++ b/src/main/java/profhugo/nodami/config/NodamiConfig.java @@ -1,6 +1,8 @@ package profhugo.nodami.config; import java.io.File; +import java.util.Arrays; +import java.util.HashSet; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Loader; @@ -13,7 +15,7 @@ public class NodamiConfig { public static boolean excludePlayers, excludeAllMobs, debugMode; public static float attackCancelThreshold, knockbackCancelThreshold; - public static String[] attackExcludedEntities, dmgReceiveExcludedEntities, damageSrcWhitelist; + public static HashSet attackExcludedEntities, dmgReceiveExcludedEntities, damageSrcWhitelist; public static void preInit() { File configFile = new File(Loader.instance().getConfigDir(), "nodami.cfg"); @@ -34,9 +36,9 @@ private static void syncConfig() { attackCancelThreshold = config.getFloat("attackCancelThreshold", "thresholds", 0.1f, -0.1f, 1, "How weak a player's attack can be before it gets nullified, from 0 (0%, cancels multiple attacks on the same tick) to 1 (100%, players cannot attack), or -0.1 (disables this feature)"); knockbackCancelThreshold = config.getFloat("knockbackCancelThreshold", "thresholds", 0.75f, -0.1f, 1, "How weak a player's attack can be before the knockback gets nullified, from 0 (0%, cancels multiple attacks on the same tick) to 1 (100%, no knockback), or -0.1 (disables this feature)"); - attackExcludedEntities = config.getStringList("attackExcludedEntities", "exclusions", new String[] {"minecraft:slime", "tconstruct:blueslime", "thaumcraft:thaumslime", "grimoireofgaia:*"}, "List of entities that need to give i-frames on attacking"); - dmgReceiveExcludedEntities = config.getStringList("damageReceiveExcludedEntities", "exclusions", new String[0], "List of entities that need to receive i-frames on receiving attacks or relies on iFrames"); - damageSrcWhitelist = config.getStringList("dmgSrcWhitelist", "exclusions", new String[] {"inFire", "lava", "cactus", "lightningBolt", "inWall", "hotFloor"}, "List of damage sources that need to give i-frames on doing damage (ex: lava)."); + attackExcludedEntities = new HashSet<>(Arrays.asList(config.getStringList("attackExcludedEntities", "exclusions", new String[] {"minecraft:slime", "tconstruct:blueslime", "thaumcraft:thaumslime"}, "List of entities that need to give i-frames on attacking"))); + dmgReceiveExcludedEntities = new HashSet<>(Arrays.asList(config.getStringList("damageReceiveExcludedEntities", "exclusions", new String[0], "List of entities that need to receive i-frames on receiving attacks or relies on iFrames"))); + damageSrcWhitelist = new HashSet<>(Arrays.asList(config.getStringList("dmgSrcWhitelist", "exclusions", new String[] {"inFire", "lava", "cactus", "lightningBolt", "inWall", "hotFloor"}, "List of damage sources that need to give i-frames on doing damage (ex: lava)."))); debugMode = config.getBoolean("debugMode", "misc", false, "If true, turns on feature which sends a message when a player receives damage, containing information such as the name of the source and the quantity. Use this to find the name of the source you need to whitelist, or the id of the mob you want to exclude."); diff --git a/src/main/java/profhugo/nodami/handlers/EntityHandler.java b/src/main/java/profhugo/nodami/handlers/EntityHandler.java index d1092e7..9d0983d 100644 --- a/src/main/java/profhugo/nodami/handlers/EntityHandler.java +++ b/src/main/java/profhugo/nodami/handlers/EntityHandler.java @@ -16,7 +16,7 @@ public class EntityHandler { - @SubscribeEvent(priority = EventPriority.LOWEST) + @SubscribeEvent(priority = EventPriority.LOW) public void onEntityHurt(LivingHurtEvent event) { if (!event.isCanceled()) { EntityLivingBase entity = event.getEntityLiving(); @@ -24,56 +24,47 @@ public void onEntityHurt(LivingHurtEvent event) { return; } DamageSource source = event.getSource(); + Entity trueSource = source.getTrueSource(); if (NodamiConfig.debugMode && entity instanceof EntityPlayer) { + String trueSourceName; + if (trueSource != null && EntityList.getKey(trueSource.getClass()) != null) { + trueSourceName = EntityList.getKey(trueSource.getClass()).toString(); + } else { + trueSourceName = "null"; + } String message = String.format("Type of damage received: %s\nAmount: %.3f\nTrue Source (mob id): %s\n", - source.getDamageType(), event.getAmount(), source.getTrueSource() == null ? "null" - : EntityList.getKey(source.getTrueSource().getClass()).toString()); + source.getDamageType(), event.getAmount(), trueSourceName); ((EntityPlayer) entity).sendMessage(new TextComponentString(message)); } + if (NodamiConfig.excludePlayers && entity instanceof EntityPlayer) { return; } + if (NodamiConfig.excludeAllMobs && !(entity instanceof EntityPlayer)) { return; } - for (String id : NodamiConfig.dmgReceiveExcludedEntities) { - ResourceLocation loc = EntityList.getKey(entity.getClass()); - if (loc == null) - break; - int starIndex = id.indexOf('*'); - if (starIndex != -1) { - if (loc.toString().indexOf(id.substring(0, starIndex)) != -1) { - return; - } - } else if (loc.toString().equals(id)) { - return; - } + + ResourceLocation loc = EntityList.getKey(entity.getClass()); + if (loc != null && NodamiConfig.dmgReceiveExcludedEntities.contains(loc.toString())) { + return; } + // May have more DoTs missing in this list // Not anymore (/s) - for (String dmgType : NodamiConfig.damageSrcWhitelist) { - if (source.getDamageType().equals(dmgType)) { - return; - } + if (NodamiConfig.damageSrcWhitelist.contains(source.getDamageType())) { + return; } // Mobs that do damage on collusion but have no attack timer - for (String id : NodamiConfig.attackExcludedEntities) { - if (source.getTrueSource() == null) - break; - ResourceLocation loc = EntityList.getKey(source.getTrueSource().getClass()); - if (loc == null) - break; - int starIndex = id.indexOf('*'); - if (starIndex != -1) { - if (loc.toString().indexOf(id.substring(0, starIndex)) != -1) { - return; - } - } else if (loc.toString().equals(id)) { + if (trueSource != null) { + loc = EntityList.getKey(trueSource.getClass()); + if (loc != null && NodamiConfig.attackExcludedEntities.contains(loc.toString())) { return; } - } + + entity.hurtResistantTime = NodamiConfig.iFrameInterval; } }