From 81ba90669827f8822c1298d0e6b888dfc5d83d29 Mon Sep 17 00:00:00 2001 From: Thelnfamous1 Date: Tue, 13 Feb 2024 22:10:14 -0600 Subject: [PATCH] - Add helper method AbilityHelper#isDefaultEnemy - Removed artifact durability config --- .../capabilities/minionmaster/FollowerLeaderHelper.java | 6 +++--- .../config/DungeonsLibrariesConfig.java | 7 ------- .../infamous/dungeons_libraries/utils/AbilityHelper.java | 8 ++++++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerLeaderHelper.java b/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerLeaderHelper.java index 211c145..004a23e 100644 --- a/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerLeaderHelper.java +++ b/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerLeaderHelper.java @@ -2,15 +2,15 @@ import com.infamous.dungeons_libraries.DungeonsLibraries; import com.infamous.dungeons_libraries.capabilities.ModCapabilities; +import com.infamous.dungeons_libraries.capabilities.minionmaster.goals.FollowerFollowLeaderGoal; import com.infamous.dungeons_libraries.capabilities.minionmaster.goals.LeaderHurtByTargetGoal; import com.infamous.dungeons_libraries.capabilities.minionmaster.goals.LeaderHurtTargetGoal; -import com.infamous.dungeons_libraries.capabilities.minionmaster.goals.FollowerFollowLeaderGoal; import com.infamous.dungeons_libraries.mixin.MobInvoker; import com.infamous.dungeons_libraries.summon.SummonHelper; +import com.infamous.dungeons_libraries.utils.AbilityHelper; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.goal.WrappedGoal; import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; @@ -110,7 +110,7 @@ public static void addFollowerGoals(Mob mobEntity) { mobEntity.targetSelector.addGoal(1, new LeaderHurtByTargetGoal(mobEntity)); mobEntity.targetSelector.addGoal(2, new LeaderHurtTargetGoal(mobEntity)); mobEntity.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(mobEntity, LivingEntity.class, 5, false, false, - (entityIterator) -> entityIterator.getClassification(false).equals(MobCategory.MONSTER) && canPetAttackEntity(mobEntity, entityIterator))); + (entityIterator) -> AbilityHelper.isDefaultEnemy(entityIterator) && canPetAttackEntity(mobEntity, entityIterator))); minionCap.getLeader().getCapability(ModCapabilities.LEADER_CAPABILITY).ifPresent(leader -> { leader.addFollower(mobEntity); diff --git a/src/main/java/com/infamous/dungeons_libraries/config/DungeonsLibrariesConfig.java b/src/main/java/com/infamous/dungeons_libraries/config/DungeonsLibrariesConfig.java index d605097..03905bd 100644 --- a/src/main/java/com/infamous/dungeons_libraries/config/DungeonsLibrariesConfig.java +++ b/src/main/java/com/infamous/dungeons_libraries/config/DungeonsLibrariesConfig.java @@ -12,7 +12,6 @@ public class DungeonsLibrariesConfig { public static ForgeConfigSpec.ConfigValue ENABLE_DUAL_WIELDING; public static ForgeConfigSpec.ConfigValue ENABLE_TWO_HANDED_WEAPON; public static ForgeConfigSpec.ConfigValue> ENEMY_BLACKLIST; - public static ForgeConfigSpec.ConfigValue ARTIFACT_DURABILITY; public static ForgeConfigSpec.ConfigValue ENABLE_ELITE_MOBS; public static ForgeConfigSpec.ConfigValue ELITE_MOBS_BASE_CHANCE; public static ForgeConfigSpec.ConfigValue> ENEMY_WHITELIST; @@ -61,12 +60,6 @@ public Common(ForgeConfigSpec.Builder builder) { .define("enableKeepSoulsOnDeath", false); builder.pop(); - builder.comment("Artifact Configuration").push("artifact_configuration"); - ARTIFACT_DURABILITY = builder - .comment("Set the durability for artifacts. [0-1024, default: 64") - .defineInRange("artifactDurability", 64, 0, 1024); - builder.pop(); - builder.comment("Elite Mob Configuration").push("elite_mob_configuration"); ENABLE_ELITE_MOBS = builder .comment("Enables elite mobs, enabled by default. [true / false]") diff --git a/src/main/java/com/infamous/dungeons_libraries/utils/AbilityHelper.java b/src/main/java/com/infamous/dungeons_libraries/utils/AbilityHelper.java index b8af7c2..d75891e 100644 --- a/src/main/java/com/infamous/dungeons_libraries/utils/AbilityHelper.java +++ b/src/main/java/com/infamous/dungeons_libraries/utils/AbilityHelper.java @@ -61,7 +61,11 @@ public static boolean isAlly(LivingEntity origin, LivingEntity target) { || origin.isAlliedTo(target) || isBothPlayerAndNoPvP(origin, target) || isEntityBlacklisted(origin, target) - || (origin.getClassification(false).equals(MobCategory.MONSTER) && target.getClassification(false).equals(MobCategory.MONSTER) && !matchesAITargets(origin, target)); + || (isDefaultEnemy(origin) && isDefaultEnemy(target) && !matchesAITargets(origin, target)); + } + + public static boolean isDefaultEnemy(LivingEntity origin) { + return origin.getClassification(false).equals(MobCategory.MONSTER); } private static boolean matchesAITargets(LivingEntity origin, LivingEntity target) { @@ -91,7 +95,7 @@ public static BrainAccessor castToAccessor(Brain private static boolean isEntityBlacklisted(LivingEntity origin, LivingEntity target) { if (target.getType().equals(ARMOR_STAND)) return true; return origin instanceof Player - && !target.getClassification(false).equals(MobCategory.MONSTER) + && !isDefaultEnemy(target) && (!DungeonsLibrariesConfig.ENEMY_WHITELIST.get().contains(ForgeRegistries.ENTITY_TYPES.getKey(target.getType()).toString()) || (DungeonsLibrariesConfig.ENEMY_BLACKLIST.get().contains(ForgeRegistries.ENTITY_TYPES.getKey(target.getType()).toString()))); }