Search in sources :

Example 1 with GoalConfiguration

use of com.elmakers.mine.bukkit.mob.GoalConfiguration in project MagicPlugin by elBukkit.

the class EntityData method applyBrain.

private void applyBrain(Entity entity) {
    if (brain == null)
        return;
    // See if there are any custom goals
    MobUtils mobUtils = CompatibilityLib.getMobUtils();
    Collection<GoalConfiguration> goals = GoalConfiguration.fromList(brain, "goals", controller.getLogger(), "mob " + getKey());
    // Remove any existing goals first
    boolean removeDefaultGoals = brain.getBoolean("remove_default_goals", goals != null && !goals.isEmpty());
    if (removeDefaultGoals) {
        if (!mobUtils.removeGoals(entity)) {
            // This indicates we don't have support for goals, so just stop here.
            return;
        }
    }
    List<String> removeGoals = ConfigurationUtils.getStringList(brain, "remove_goals");
    if (removeGoals != null) {
        for (String goalKey : removeGoals) {
            GoalType goalType;
            try {
                goalType = GoalType.valueOf(goalKey.toUpperCase());
            } catch (Exception ex) {
                controller.getLogger().info("Invalid goal type in remove_goals of mob " + getKey() + ": " + goalKey);
                continue;
            }
            mobUtils.removeGoal(entity, goalType);
        }
    }
    // Apply custom goals
    applyGoals(entity, goals);
    // Now look for target goals
    Collection<GoalConfiguration> targets = GoalConfiguration.fromList(brain, "targets", controller.getLogger(), "mob " + getKey());
    // Remove any existing goals first
    boolean removeDefaultTargets = brain.getBoolean("remove_default_targets", targets != null && !targets.isEmpty());
    if (removeDefaultTargets) {
        if (!mobUtils.removeTargetGoals(entity)) {
            // This indicates we don't have support for goals, so just stop here.
            return;
        }
    }
    List<String> removeTargets = ConfigurationUtils.getStringList(brain, "remove_targets");
    if (removeTargets != null) {
        for (String goalKey : removeTargets) {
            GoalType goalType;
            try {
                goalType = GoalType.valueOf(goalKey.toUpperCase());
            } catch (Exception ex) {
                controller.getLogger().info("Invalid goal type in remove_targets of mob " + getKey() + ": " + goalKey);
                continue;
            }
            mobUtils.removeTargetGoal(entity, goalType);
        }
    }
    // Apply custom goals
    applyTargetGoals(entity, targets);
}
Also used : GoalConfiguration(com.elmakers.mine.bukkit.mob.GoalConfiguration) GoalType(com.elmakers.mine.bukkit.mob.GoalType) MobUtils(com.elmakers.mine.bukkit.utility.platform.MobUtils)

Example 2 with GoalConfiguration

use of com.elmakers.mine.bukkit.mob.GoalConfiguration in project MagicPlugin by elBukkit.

the class MobUtils method getGoals.

private List<Goal> getGoals(Entity entity, Mob mob, ConfigurationSection config, String logContext) {
    List<Goal> goals = new ArrayList<>();
    List<GoalConfiguration> goalConfigurations = GoalConfiguration.fromList(config, "goals", platform.getLogger(), logContext);
    if (goalConfigurations != null) {
        Collections.sort(goalConfigurations);
        for (GoalConfiguration goalConfig : goalConfigurations) {
            try {
                Goal goal = getGoal(goalConfig.getGoalType(), entity, mob, goalConfig.getConfiguration());
                if (goal != null) {
                    goals.add(goal);
                }
            } catch (Exception ex) {
                platform.getLogger().log(Level.WARNING, "Error creating goal: " + goalConfig.getGoalType() + " on mob " + entity.getType(), ex);
            }
        }
    }
    if (goals.isEmpty()) {
        goals.add(new IdleGoal());
    }
    return goals;
}
Also used : GoalConfiguration(com.elmakers.mine.bukkit.mob.GoalConfiguration) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.IdleGoal) StrollThroughVillageGoal(net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal) OcelotAttackGoal(net.minecraft.world.entity.ai.goal.OcelotAttackGoal) AvoidEntityGoal(net.minecraft.world.entity.ai.goal.AvoidEntityGoal) MagicFindOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicFindOwnerGoal) MagicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicOwnerHurtTargetGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicFollowOwnerGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) LandOnOwnersShoulderGoal(net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal) BreathAirGoal(net.minecraft.world.entity.ai.goal.BreathAirGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicFollowMobGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal) OwnerHurtTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal) WrappedGoal(net.minecraft.world.entity.ai.goal.WrappedGoal) FollowOwnerGoal(net.minecraft.world.entity.ai.goal.FollowOwnerGoal) RandomSwimmingGoal(net.minecraft.world.entity.ai.goal.RandomSwimmingGoal) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicPanicGoal) GolemRandomStrollInVillageGoal(net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal) WaterAvoidingRandomFlyingGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal) OpenDoorGoal(net.minecraft.world.entity.ai.goal.OpenDoorGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicOwnerHurtByTargetGoal) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal) TryFindWaterGoal(net.minecraft.world.entity.ai.goal.TryFindWaterGoal) MoveTowardsRestrictionGoal(net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal) MoveTowardsTargetGoal(net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal) DefendVillageTargetGoal(net.minecraft.world.entity.ai.goal.target.DefendVillageTargetGoal) EatBlockGoal(net.minecraft.world.entity.ai.goal.EatBlockGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) OfferFlowerGoal(net.minecraft.world.entity.ai.goal.OfferFlowerGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) RequirementsGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.RequirementsGoal) MeleeAttackGoal(net.minecraft.world.entity.ai.goal.MeleeAttackGoal) FollowBoatGoal(net.minecraft.world.entity.ai.goal.FollowBoatGoal) RestrictSunGoal(net.minecraft.world.entity.ai.goal.RestrictSunGoal) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) TargetGoal(net.minecraft.world.entity.ai.goal.target.TargetGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) MoveThroughVillageGoal(net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal) LeapAtTargetGoal(net.minecraft.world.entity.ai.goal.LeapAtTargetGoal) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) BreakDoorGoal(net.minecraft.world.entity.ai.goal.BreakDoorGoal) SwellGoal(net.minecraft.world.entity.ai.goal.SwellGoal) Goal(net.minecraft.world.entity.ai.goal.Goal) RunAroundLikeCrazyGoal(net.minecraft.world.entity.ai.goal.RunAroundLikeCrazyGoal) MagicCheckOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.MagicCheckOwnerGoal) ZombieAttackGoal(net.minecraft.world.entity.ai.goal.ZombieAttackGoal) TriggerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.TriggerGoal) FleeSunGoal(net.minecraft.world.entity.ai.goal.FleeSunGoal) FollowFlockLeaderGoal(net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal) MoveBackToVillageGoal(net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) BegGoal(net.minecraft.world.entity.ai.goal.BegGoal) InteractGoal(net.minecraft.world.entity.ai.goal.InteractGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_0.goal.IdleGoal) ArrayList(java.util.ArrayList)

Example 3 with GoalConfiguration

use of com.elmakers.mine.bukkit.mob.GoalConfiguration in project MagicPlugin by elBukkit.

the class MobUtils method getGoals.

private List<Goal> getGoals(Entity entity, Mob mob, ConfigurationSection config, String logContext) {
    List<Goal> goals = new ArrayList<>();
    List<GoalConfiguration> goalConfigurations = GoalConfiguration.fromList(config, "goals", platform.getLogger(), logContext);
    if (goalConfigurations != null) {
        Collections.sort(goalConfigurations);
        for (GoalConfiguration goalConfig : goalConfigurations) {
            try {
                Goal goal = getGoal(goalConfig.getGoalType(), entity, mob, goalConfig.getConfiguration());
                if (goal != null) {
                    goals.add(goal);
                }
            } catch (Exception ex) {
                platform.getLogger().log(Level.WARNING, "Error creating goal: " + goalConfig.getGoalType() + " on mob " + entity.getType(), ex);
            }
        }
    }
    if (goals.isEmpty()) {
        goals.add(new IdleGoal());
    }
    return goals;
}
Also used : GoalConfiguration(com.elmakers.mine.bukkit.mob.GoalConfiguration) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicPanicGoal) StrollThroughVillageGoal(net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal) OcelotAttackGoal(net.minecraft.world.entity.ai.goal.OcelotAttackGoal) AvoidEntityGoal(net.minecraft.world.entity.ai.goal.AvoidEntityGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) LandOnOwnersShoulderGoal(net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal) BreathAirGoal(net.minecraft.world.entity.ai.goal.BreathAirGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicOwnerHurtByTargetGoal) OwnerHurtTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal) WrappedGoal(net.minecraft.world.entity.ai.goal.WrappedGoal) FollowOwnerGoal(net.minecraft.world.entity.ai.goal.FollowOwnerGoal) RandomSwimmingGoal(net.minecraft.world.entity.ai.goal.RandomSwimmingGoal) GolemRandomStrollInVillageGoal(net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal) WaterAvoidingRandomFlyingGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal) OpenDoorGoal(net.minecraft.world.entity.ai.goal.OpenDoorGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicOwnerHurtTargetGoal) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal) TryFindWaterGoal(net.minecraft.world.entity.ai.goal.TryFindWaterGoal) MagicFindOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicFindOwnerGoal) MoveTowardsRestrictionGoal(net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.IdleGoal) MoveTowardsTargetGoal(net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal) DefendVillageTargetGoal(net.minecraft.world.entity.ai.goal.target.DefendVillageTargetGoal) EatBlockGoal(net.minecraft.world.entity.ai.goal.EatBlockGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) OfferFlowerGoal(net.minecraft.world.entity.ai.goal.OfferFlowerGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) MagicCheckOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicCheckOwnerGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicFollowOwnerGoal) RequirementsGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.RequirementsGoal) MeleeAttackGoal(net.minecraft.world.entity.ai.goal.MeleeAttackGoal) FollowBoatGoal(net.minecraft.world.entity.ai.goal.FollowBoatGoal) RestrictSunGoal(net.minecraft.world.entity.ai.goal.RestrictSunGoal) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) TargetGoal(net.minecraft.world.entity.ai.goal.target.TargetGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) MoveThroughVillageGoal(net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal) LeapAtTargetGoal(net.minecraft.world.entity.ai.goal.LeapAtTargetGoal) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) MagicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicGoal) BreakDoorGoal(net.minecraft.world.entity.ai.goal.BreakDoorGoal) SwellGoal(net.minecraft.world.entity.ai.goal.SwellGoal) Goal(net.minecraft.world.entity.ai.goal.Goal) RunAroundLikeCrazyGoal(net.minecraft.world.entity.ai.goal.RunAroundLikeCrazyGoal) ZombieAttackGoal(net.minecraft.world.entity.ai.goal.ZombieAttackGoal) FleeSunGoal(net.minecraft.world.entity.ai.goal.FleeSunGoal) TriggerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.TriggerGoal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.MagicFollowMobGoal) FollowFlockLeaderGoal(net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal) MoveBackToVillageGoal(net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal) SpinGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.SpinGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) BegGoal(net.minecraft.world.entity.ai.goal.BegGoal) InteractGoal(net.minecraft.world.entity.ai.goal.InteractGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_1.goal.IdleGoal) ArrayList(java.util.ArrayList)

Example 4 with GoalConfiguration

use of com.elmakers.mine.bukkit.mob.GoalConfiguration in project MagicPlugin by elBukkit.

the class MobUtils method getGoals.

private List<Goal> getGoals(Entity entity, Mob mob, ConfigurationSection config, String logContext) {
    List<Goal> goals = new ArrayList<>();
    List<GoalConfiguration> goalConfigurations = GoalConfiguration.fromList(config, "goals", platform.getLogger(), logContext);
    if (goalConfigurations != null) {
        Collections.sort(goalConfigurations);
        for (GoalConfiguration goalConfig : goalConfigurations) {
            try {
                Goal goal = getGoal(goalConfig.getGoalType(), entity, mob, goalConfig.getConfiguration());
                if (goal != null) {
                    goals.add(goal);
                }
            } catch (Exception ex) {
                platform.getLogger().log(Level.WARNING, "Error creating goal: " + goalConfig.getGoalType() + " on mob " + entity.getType(), ex);
            }
        }
    }
    if (goals.isEmpty()) {
        goals.add(new IdleGoal());
    }
    return goals;
}
Also used : GoalConfiguration(com.elmakers.mine.bukkit.mob.GoalConfiguration) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicOwnerHurtByTargetGoal) StrollThroughVillageGoal(net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal) OcelotAttackGoal(net.minecraft.world.entity.ai.goal.OcelotAttackGoal) AvoidEntityGoal(net.minecraft.world.entity.ai.goal.AvoidEntityGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) LandOnOwnersShoulderGoal(net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal) BreathAirGoal(net.minecraft.world.entity.ai.goal.BreathAirGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal) OwnerHurtTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal) WrappedGoal(net.minecraft.world.entity.ai.goal.WrappedGoal) FollowOwnerGoal(net.minecraft.world.entity.ai.goal.FollowOwnerGoal) RandomSwimmingGoal(net.minecraft.world.entity.ai.goal.RandomSwimmingGoal) GolemRandomStrollInVillageGoal(net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal) WaterAvoidingRandomFlyingGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal) OpenDoorGoal(net.minecraft.world.entity.ai.goal.OpenDoorGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) TriggerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.TriggerGoal) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.IdleGoal) TryFindWaterGoal(net.minecraft.world.entity.ai.goal.TryFindWaterGoal) MoveTowardsRestrictionGoal(net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicPanicGoal) MoveTowardsTargetGoal(net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal) DefendVillageTargetGoal(net.minecraft.world.entity.ai.goal.target.DefendVillageTargetGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicOwnerHurtTargetGoal) EatBlockGoal(net.minecraft.world.entity.ai.goal.EatBlockGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) OfferFlowerGoal(net.minecraft.world.entity.ai.goal.OfferFlowerGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicFollowMobGoal) MeleeAttackGoal(net.minecraft.world.entity.ai.goal.MeleeAttackGoal) FollowBoatGoal(net.minecraft.world.entity.ai.goal.FollowBoatGoal) RestrictSunGoal(net.minecraft.world.entity.ai.goal.RestrictSunGoal) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) TargetGoal(net.minecraft.world.entity.ai.goal.target.TargetGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) MoveThroughVillageGoal(net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal) MagicGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicGoal) LeapAtTargetGoal(net.minecraft.world.entity.ai.goal.LeapAtTargetGoal) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) RequirementsGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.RequirementsGoal) MagicFindOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicFindOwnerGoal) BreakDoorGoal(net.minecraft.world.entity.ai.goal.BreakDoorGoal) SwellGoal(net.minecraft.world.entity.ai.goal.SwellGoal) Goal(net.minecraft.world.entity.ai.goal.Goal) RunAroundLikeCrazyGoal(net.minecraft.world.entity.ai.goal.RunAroundLikeCrazyGoal) ZombieAttackGoal(net.minecraft.world.entity.ai.goal.ZombieAttackGoal) FleeSunGoal(net.minecraft.world.entity.ai.goal.FleeSunGoal) MagicCheckOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicCheckOwnerGoal) FollowFlockLeaderGoal(net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal) MoveBackToVillageGoal(net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) BegGoal(net.minecraft.world.entity.ai.goal.BegGoal) InteractGoal(net.minecraft.world.entity.ai.goal.InteractGoal) SpinGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.SpinGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.MagicFollowOwnerGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_18_2.goal.IdleGoal) ArrayList(java.util.ArrayList)

Example 5 with GoalConfiguration

use of com.elmakers.mine.bukkit.mob.GoalConfiguration in project MagicPlugin by elBukkit.

the class MobUtils method getGoals.

private List<Goal> getGoals(Entity entity, Mob mob, ConfigurationSection config, String logContext) {
    List<Goal> goals = new ArrayList<>();
    List<GoalConfiguration> goalConfigurations = GoalConfiguration.fromList(config, "goals", platform.getLogger(), logContext);
    if (goalConfigurations != null) {
        Collections.sort(goalConfigurations);
        for (GoalConfiguration goalConfig : goalConfigurations) {
            try {
                Goal goal = getGoal(goalConfig.getGoalType(), entity, mob, goalConfig.getConfiguration());
                if (goal != null) {
                    goals.add(goal);
                }
            } catch (Exception ex) {
                platform.getLogger().log(Level.WARNING, "Error creating goal: " + goalConfig.getGoalType() + " on mob " + entity.getType(), ex);
            }
        }
    }
    if (goals.isEmpty()) {
        goals.add(new IdleGoal());
    }
    return goals;
}
Also used : GoalConfiguration(com.elmakers.mine.bukkit.mob.GoalConfiguration) StrollThroughVillageGoal(net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal) OcelotAttackGoal(net.minecraft.world.entity.ai.goal.OcelotAttackGoal) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtByTargetGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal) AvoidEntityGoal(net.minecraft.world.entity.ai.goal.AvoidEntityGoal) TriggerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.TriggerGoal) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicPanicGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) LandOnOwnersShoulderGoal(net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal) BreathAirGoal(net.minecraft.world.entity.ai.goal.BreathAirGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal) OwnerHurtTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal) WrappedGoal(net.minecraft.world.entity.ai.goal.WrappedGoal) MagicCheckOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicCheckOwnerGoal) FollowOwnerGoal(net.minecraft.world.entity.ai.goal.FollowOwnerGoal) RandomSwimmingGoal(net.minecraft.world.entity.ai.goal.RandomSwimmingGoal) GolemRandomStrollInVillageGoal(net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal) WaterAvoidingRandomFlyingGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal) RequirementsGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.RequirementsGoal) OpenDoorGoal(net.minecraft.world.entity.ai.goal.OpenDoorGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal) TryFindWaterGoal(net.minecraft.world.entity.ai.goal.TryFindWaterGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtTargetGoal) MoveTowardsRestrictionGoal(net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal) MagicFindOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFindOwnerGoal) MoveTowardsTargetGoal(net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal) DefendVillageTargetGoal(net.minecraft.world.entity.ai.goal.target.DefendVillageTargetGoal) EatBlockGoal(net.minecraft.world.entity.ai.goal.EatBlockGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) OfferFlowerGoal(net.minecraft.world.entity.ai.goal.OfferFlowerGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) MeleeAttackGoal(net.minecraft.world.entity.ai.goal.MeleeAttackGoal) FollowBoatGoal(net.minecraft.world.entity.ai.goal.FollowBoatGoal) RestrictSunGoal(net.minecraft.world.entity.ai.goal.RestrictSunGoal) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) TargetGoal(net.minecraft.world.entity.ai.goal.target.TargetGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) MoveThroughVillageGoal(net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal) LeapAtTargetGoal(net.minecraft.world.entity.ai.goal.LeapAtTargetGoal) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) BreakDoorGoal(net.minecraft.world.entity.ai.goal.BreakDoorGoal) SwellGoal(net.minecraft.world.entity.ai.goal.SwellGoal) Goal(net.minecraft.world.entity.ai.goal.Goal) RunAroundLikeCrazyGoal(net.minecraft.world.entity.ai.goal.RunAroundLikeCrazyGoal) ZombieAttackGoal(net.minecraft.world.entity.ai.goal.ZombieAttackGoal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowMobGoal) FleeSunGoal(net.minecraft.world.entity.ai.goal.FleeSunGoal) MagicGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowOwnerGoal) FollowFlockLeaderGoal(net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal) MoveBackToVillageGoal(net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) BegGoal(net.minecraft.world.entity.ai.goal.BegGoal) InteractGoal(net.minecraft.world.entity.ai.goal.InteractGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal) ArrayList(java.util.ArrayList)

Aggregations

GoalConfiguration (com.elmakers.mine.bukkit.mob.GoalConfiguration)5 ArrayList (java.util.ArrayList)4 AvoidEntityGoal (net.minecraft.world.entity.ai.goal.AvoidEntityGoal)4 BegGoal (net.minecraft.world.entity.ai.goal.BegGoal)4 BreakDoorGoal (net.minecraft.world.entity.ai.goal.BreakDoorGoal)4 BreathAirGoal (net.minecraft.world.entity.ai.goal.BreathAirGoal)4 BreedGoal (net.minecraft.world.entity.ai.goal.BreedGoal)4 EatBlockGoal (net.minecraft.world.entity.ai.goal.EatBlockGoal)4 FleeSunGoal (net.minecraft.world.entity.ai.goal.FleeSunGoal)4 FloatGoal (net.minecraft.world.entity.ai.goal.FloatGoal)4 FollowBoatGoal (net.minecraft.world.entity.ai.goal.FollowBoatGoal)4 FollowFlockLeaderGoal (net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal)4 FollowMobGoal (net.minecraft.world.entity.ai.goal.FollowMobGoal)4 FollowOwnerGoal (net.minecraft.world.entity.ai.goal.FollowOwnerGoal)4 FollowParentGoal (net.minecraft.world.entity.ai.goal.FollowParentGoal)4 Goal (net.minecraft.world.entity.ai.goal.Goal)4 GolemRandomStrollInVillageGoal (net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal)4 InteractGoal (net.minecraft.world.entity.ai.goal.InteractGoal)4 LandOnOwnersShoulderGoal (net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal)4 LeapAtTargetGoal (net.minecraft.world.entity.ai.goal.LeapAtTargetGoal)4