Search in sources :

Example 16 with Goal

use of net.minecraft.world.entity.ai.goal.Goal 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 17 with Goal

use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.

the class MobUtils method getGoalDescriptions.

protected Collection<String> getGoalDescriptions(GoalSelector selector) {
    List<String> descriptions = new ArrayList<>();
    Collection<WrappedGoal> available = selector.getAvailableGoals();
    for (WrappedGoal wrappedGoal : available) {
        Goal goal = wrappedGoal.getGoal();
        String description = goal.toString();
        String parentDescription = getGoalParentDescriptions(goal);
        if (parentDescription != null) {
            description += " " + parentDescription;
        }
        if (wrappedGoal.isRunning()) {
            description = ChatColor.AQUA + description;
        } else {
            description = ChatColor.GOLD + description;
        }
        descriptions.add(ChatColor.BLUE + Integer.toString(wrappedGoal.getPriority()) + ChatColor.DARK_GRAY + ": " + description);
    }
    return descriptions;
}
Also used : 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) ArrayList(java.util.ArrayList) WrappedGoal(net.minecraft.world.entity.ai.goal.WrappedGoal)

Example 18 with Goal

use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.

the class MagicGoal method getSubDescription.

protected String getSubDescription() {
    List<String> goalDescriptions = new ArrayList<>();
    for (Goal goal : goals) {
        String goalDescription = goal.toString();
        if (goal == currentGoal) {
            goalDescription = ChatColor.AQUA + goalDescription;
        } else {
            goalDescription = ChatColor.DARK_AQUA + goalDescription;
        }
        goalDescriptions.add(goalDescription);
    }
    return ChatColor.DARK_GRAY + " [" + StringUtils.join(goalDescriptions, " ") + ChatColor.DARK_GRAY + "]";
}
Also used : Goal(net.minecraft.world.entity.ai.goal.Goal) ArrayList(java.util.ArrayList)

Example 19 with Goal

use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.

the class MagicGoal method canContinueToUse.

@Override
public boolean canContinueToUse() {
    boolean interrupt = false;
    boolean continuing = false;
    for (Goal goal : goals) {
        if (goal == currentGoal) {
            boolean canContinue = goal.canContinueToUse();
            if (canContinue) {
                continuing = true;
            } else {
                interrupt = true;
            }
        } else {
            // A higher-priority goal can interrupt
            boolean canUse = goal.canUse();
            if (canUse && !continuing && (currentGoal == null || currentGoal.isInterruptable())) {
                interrupt = true;
            }
        }
        if (interrupt) {
            return false;
        }
    }
    return true;
}
Also used : Goal(net.minecraft.world.entity.ai.goal.Goal)

Example 20 with Goal

use of net.minecraft.world.entity.ai.goal.Goal in project MagicPlugin by elBukkit.

the class MagicGoal method getSubDescription.

protected String getSubDescription() {
    List<String> goalDescriptions = new ArrayList<>();
    for (Goal goal : goals) {
        String goalDescription = goal.toString();
        if (goal == currentGoal) {
            goalDescription = ChatColor.AQUA + goalDescription;
        } else {
            goalDescription = ChatColor.DARK_AQUA + goalDescription;
        }
        goalDescriptions.add(goalDescription);
    }
    return ChatColor.DARK_GRAY + " [" + StringUtils.join(goalDescriptions, " ") + ChatColor.DARK_GRAY + "]";
}
Also used : Goal(net.minecraft.world.entity.ai.goal.Goal) ArrayList(java.util.ArrayList)

Aggregations

Goal (net.minecraft.world.entity.ai.goal.Goal)28 AvoidEntityGoal (net.minecraft.world.entity.ai.goal.AvoidEntityGoal)20 BegGoal (net.minecraft.world.entity.ai.goal.BegGoal)20 BreakDoorGoal (net.minecraft.world.entity.ai.goal.BreakDoorGoal)20 BreathAirGoal (net.minecraft.world.entity.ai.goal.BreathAirGoal)20 BreedGoal (net.minecraft.world.entity.ai.goal.BreedGoal)20 EatBlockGoal (net.minecraft.world.entity.ai.goal.EatBlockGoal)20 FleeSunGoal (net.minecraft.world.entity.ai.goal.FleeSunGoal)20 FloatGoal (net.minecraft.world.entity.ai.goal.FloatGoal)20 FollowBoatGoal (net.minecraft.world.entity.ai.goal.FollowBoatGoal)20 FollowFlockLeaderGoal (net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal)20 FollowMobGoal (net.minecraft.world.entity.ai.goal.FollowMobGoal)20 FollowOwnerGoal (net.minecraft.world.entity.ai.goal.FollowOwnerGoal)20 FollowParentGoal (net.minecraft.world.entity.ai.goal.FollowParentGoal)20 GolemRandomStrollInVillageGoal (net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal)20 InteractGoal (net.minecraft.world.entity.ai.goal.InteractGoal)20 LandOnOwnersShoulderGoal (net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal)20 LeapAtTargetGoal (net.minecraft.world.entity.ai.goal.LeapAtTargetGoal)20 LookAtPlayerGoal (net.minecraft.world.entity.ai.goal.LookAtPlayerGoal)20 MeleeAttackGoal (net.minecraft.world.entity.ai.goal.MeleeAttackGoal)20