Skip to content

Commit

Permalink
- Add helper method AbilityHelper#isDefaultEnemy
Browse files Browse the repository at this point in the history
- Removed artifact durability config
  • Loading branch information
Thelnfamous1 committed Feb 14, 2024
1 parent 0a80816 commit 81ba906
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class DungeonsLibrariesConfig {
public static ForgeConfigSpec.ConfigValue<Boolean> ENABLE_DUAL_WIELDING;
public static ForgeConfigSpec.ConfigValue<Boolean> ENABLE_TWO_HANDED_WEAPON;
public static ForgeConfigSpec.ConfigValue<List<? extends String>> ENEMY_BLACKLIST;
public static ForgeConfigSpec.ConfigValue<Integer> ARTIFACT_DURABILITY;
public static ForgeConfigSpec.ConfigValue<Boolean> ENABLE_ELITE_MOBS;
public static ForgeConfigSpec.ConfigValue<Double> ELITE_MOBS_BASE_CHANCE;
public static ForgeConfigSpec.ConfigValue<List<? extends String>> ENEMY_WHITELIST;
Expand Down Expand Up @@ -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]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -91,7 +95,7 @@ public static <E extends LivingEntity> BrainAccessor<E> castToAccessor(Brain<E>
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())));
}
Expand Down

0 comments on commit 81ba906

Please sign in to comment.