Search in sources :

Example 6 with IdleGoal

use of com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal 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 7 with IdleGoal

use of com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal in project MagicPlugin by elBukkit.

the class MobUtils method getGoal.

private Goal getGoal(GoalType goalType, Entity entity, Mob mob, ConfigurationSection config) {
    final String classType = config.getString("entity_class", "player");
    final double speed = config.getDouble("speed", 1);
    final double sprintSpeed = config.getDouble("sprint_speed", 1);
    final float distance = (float) config.getDouble("distance", 16);
    final boolean doors = config.getBoolean("doors", true);
    final boolean interruptable = config.getBoolean("interruptable", true);
    final boolean see = config.getBoolean("see", true);
    final boolean reach = config.getBoolean("reach", false);
    final float startDistance = (float) config.getDouble("start_distance", 5);
    final float stopDistance = (float) config.getDouble("stop_distance", 1);
    final float radius = (float) config.getDouble("radius", 16);
    final PathfinderMob pathfinder = mob instanceof PathfinderMob ? (PathfinderMob) mob : null;
    int interval = config.getInt("interval", 1000);
    // Interval is specified in ms, but needed in ticks
    interval = interval / 50;
    MageController controller = platform.getController();
    Mage mage;
    List<Goal> goals;
    switch(goalType) {
        case AVOID_ENTITY:
            if (pathfinder == null)
                return null;
            return new AvoidEntityGoal<>(pathfinder, getMobClass(classType), distance, sprintSpeed, sprintSpeed);
        case BEG:
            if (mob instanceof Wolf) {
                return new BegGoal((Wolf) mob, distance);
            }
            return null;
        case BREAK_DOOR:
            return new BreakDoorGoal(mob, difficulty -> true);
        case BREATHE_AIR:
            if (pathfinder == null)
                return null;
            return new BreathAirGoal(pathfinder);
        case BREED:
            if (mob instanceof Animal) {
                return new BreedGoal((Animal) mob, speed);
            }
            return null;
        case EAT_BLOCK:
            return new EatBlockGoal(mob);
        case FLEE_SUN:
            if (pathfinder == null)
                return null;
            return new FleeSunGoal(pathfinder, speed);
        case FLOAT:
            return new FloatGoal(mob);
        case FOLLOW_BOAT:
            if (pathfinder == null)
                return null;
            return new FollowBoatGoal(pathfinder);
        case FOLLOW_FLOCK_LEADER:
            if (mob instanceof AbstractSchoolingFish) {
                return new FollowFlockLeaderGoal((AbstractSchoolingFish) mob);
            }
            return null;
        case FOLLOW_MOB:
            return new FollowMobGoal(mob, speed, distance, radius);
        case FOLLOW_OWNER:
            if (mob instanceof TamableAnimal) {
                return new FollowOwnerGoal((TamableAnimal) mob, speed, startDistance, stopDistance, config.getBoolean("fly", false));
            }
        // Intentional fall-through
        case MAGIC_FOLLOW_OWNER:
            return new MagicFollowOwnerGoal(platform, mob, speed, startDistance, stopDistance, interval, config);
        case FOLLOW_PARENT:
            if (mob instanceof Animal) {
                return new FollowParentGoal((Animal) mob, speed);
            }
            return null;
        case GOLEM_RANDOM_STROLL_IN_VILLAGE:
            if (pathfinder == null)
                return null;
            return new GolemRandomStrollInVillageGoal(pathfinder, speed);
        case INTERACT:
            return new InteractGoal(mob, getMobClass(classType), distance, (float) config.getDouble("probability", 1));
        case LAND_ON_OWNERS_SHOULDER:
            if (mob instanceof ShoulderRidingEntity) {
                return new LandOnOwnersShoulderGoal((ShoulderRidingEntity) mob);
            }
            return null;
        case LEAP_AT_TARGET:
            return new LeapAtTargetGoal(mob, (float) config.getDouble("y_offset", 0.4));
        case LOOK_AT_PLAYER:
            return new LookAtPlayerGoal(mob, getMobClass(classType), distance, (float) config.getDouble("probability", 1), config.getBoolean("horizontal"));
        case MELEE_ATTACK:
            if (pathfinder == null)
                return null;
            return new MeleeAttackGoal(pathfinder, speed, config.getBoolean("follow", true));
        case MOVE_BACK_TO_VILLAGE:
            if (pathfinder == null)
                return null;
            return new MoveBackToVillageGoal(pathfinder, speed, config.getBoolean("check", true));
        case MOVE_THROUGH_VILLAGE:
            if (pathfinder == null)
                return null;
            return new MoveThroughVillageGoal(pathfinder, speed, config.getBoolean("night", true), (int) distance, (BooleanSupplier) () -> doors);
        case MOVE_TOWARDS_RESTRICTION:
            if (pathfinder == null)
                return null;
            return new MoveTowardsRestrictionGoal(pathfinder, speed);
        case MOVE_TOWARDS_TARGET:
            if (pathfinder == null)
                return null;
            return new MoveTowardsTargetGoal(pathfinder, speed, distance);
        case OCELOT_ATTACK:
            return new OcelotAttackGoal(mob);
        case OFFER_FLOWER:
            if (mob instanceof IronGolem) {
                return new OfferFlowerGoal((IronGolem) mob);
            }
            return null;
        case OPEN_DOOR:
            return new OpenDoorGoal(mob, config.getBoolean("close", false));
        case PANIC_FIRE:
            if (pathfinder == null)
                return null;
            return new PanicGoal(pathfinder, speed);
        case PANIC:
        case MAGIC_PANIC:
            if (pathfinder == null)
                return null;
            return new MagicPanicGoal(pathfinder, speed, config.getInt("panic", 3000), config.getInt("calm", 5000), interruptable);
        case RANDOM_LOOK_AROUND:
            return new RandomLookAroundGoal(mob);
        case RANDOM_STROLL:
            if (pathfinder == null)
                return null;
            return new RandomStrollGoal(pathfinder, speed, interval);
        case RANDOM_SWIMMING:
            if (pathfinder == null)
                return null;
            return new RandomSwimmingGoal(pathfinder, speed, interval);
        case RESTRICT_SUN:
            if (pathfinder == null)
                return null;
            return new RestrictSunGoal(pathfinder);
        case RUN_AROUND_LIKE_CRAZY:
            if (mob instanceof Horse) {
                return new RunAroundLikeCrazyGoal((Horse) mob, speed);
            }
            return null;
        case STROLL_THROUGH_VILLAGE:
            if (pathfinder == null)
                return null;
            return new StrollThroughVillageGoal(pathfinder, interval);
        case SWELL:
            if (mob instanceof Creeper) {
                return new SwellGoal((Creeper) mob);
            }
            return null;
        case TEMPT:
            if (pathfinder == null)
                return null;
            String itemKey = config.getString("item", "EMERALD");
            try {
                Material material = Material.valueOf(itemKey.toUpperCase());
                org.bukkit.inventory.ItemStack itemStack = new org.bukkit.inventory.ItemStack(material);
                ItemUtils itemUtils = platform.getItemUtils();
                itemStack = itemUtils.makeReal(itemStack);
                ItemStack nms = (ItemStack) itemUtils.getHandle(itemStack);
                if (nms == null) {
                    platform.getLogger().warning("Invalid item from material in temp goal: " + itemKey);
                    return null;
                }
                boolean scare = config.getBoolean("scare", false);
                return new TemptGoal(pathfinder, speed, Ingredient.of(nms), scare);
            } catch (Exception ex) {
                platform.getLogger().warning("Invalid material in temp goal: " + itemKey);
                return null;
            }
        case TRY_FIND_WATER:
            if (pathfinder == null)
                return null;
            return new TryFindWaterGoal(pathfinder);
        case WATER_AVOIDING_RANDOM_FLYING:
            if (pathfinder == null)
                return null;
            return new WaterAvoidingRandomFlyingGoal(pathfinder, speed);
        case WATER_AVOIDING_RANDOM_STROLL:
            if (pathfinder == null)
                return null;
            return new WaterAvoidingRandomStrollGoal(pathfinder, speed);
        case ZOMBIE_ATTACK:
            if (mob instanceof Zombie) {
                return new ZombieAttackGoal((Zombie) mob, speed, config.getBoolean("follow", true));
            }
            return null;
        // Target
        case DEFEND_VILLAGE_TARGET:
            if (mob instanceof IronGolem) {
                return new DefendVillageTargetGoal((IronGolem) mob);
            }
            return null;
        case HURT_BY_TARGET:
            if (pathfinder == null)
                return null;
            return new HurtByTargetGoal(pathfinder);
        case NEAREST_ATTACKABLE_TARGET:
            return new NearestAttackableTargetGoal<>(mob, getMobClass(classType), see, reach);
        case OWNER_HURT_BY_TARGET:
            if (mob instanceof TamableAnimal) {
                return new OwnerHurtByTargetGoal((TamableAnimal) mob);
            }
        // Intentional fall-through
        case MAGIC_OWNER_HURT_BY_TARGET:
            return new MagicOwnerHurtByTargetGoal(platform, mob, entity, see, reach);
        case OWNER_HURT_TARGET:
            if (mob instanceof TamableAnimal) {
                return new OwnerHurtTargetGoal((TamableAnimal) mob);
            }
        // Intentional fall-through
        case MAGIC_OWNER_HURT_TARGET:
            return new MagicOwnerHurtTargetGoal(platform, mob, entity, see, reach);
        // Magic add-ons
        case FOLLOW_ENTITY:
        case MAGIC_FOLLOW_MOB:
            Class<? extends LivingEntity> mobClass = getMobClass(classType);
            if (mobClass == null) {
                platform.getLogger().warning("Unsupported entity_class in magic_follow_mob goal: " + classType);
                return null;
            }
            return new MagicFollowMobGoal(mob, speed, radius, distance, interval, mobClass);
        case REQUIREMENT:
        case REQUIREMENTS:
            if (pathfinder == null)
                return null;
            mage = controller.getMage(entity);
            Collection<Requirement> requirements = controller.getRequirements(config);
            goals = getGoals(entity, mob, config, "magic requirement goal");
            return new RequirementsGoal(mage, goals, interruptable, requirements);
        case GROUP:
            goals = getGoals(entity, mob, config, "magic group goal");
            return new MagicGoal(goals, interruptable);
        case TRIGGER:
            mage = controller.getMage(entity);
            goals = getGoals(entity, mob, config, "magic trigger goal");
            return new TriggerGoal(mage, goals, interruptable, config.getString("trigger", "goal"), interval);
        case FIND_OWNER:
            return new MagicFindOwnerGoal(platform, mob, radius, getMobClass(classType));
        case CHECK_OWNER:
            return new MagicCheckOwnerGoal(platform, mob);
        case IDLE:
            return new IdleGoal();
        default:
            platform.getLogger().warning("Unsupported goal type: " + goalType);
            return null;
    }
}
Also used : TryFindWaterGoal(net.minecraft.world.entity.ai.goal.TryFindWaterGoal) TriggerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.TriggerGoal) IdleGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) MagicGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicGoal) MageController(com.elmakers.mine.bukkit.api.magic.MageController) AvoidEntityGoal(net.minecraft.world.entity.ai.goal.AvoidEntityGoal) FollowBoatGoal(net.minecraft.world.entity.ai.goal.FollowBoatGoal) 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) BegGoal(net.minecraft.world.entity.ai.goal.BegGoal) MeleeAttackGoal(net.minecraft.world.entity.ai.goal.MeleeAttackGoal) RestrictSunGoal(net.minecraft.world.entity.ai.goal.RestrictSunGoal) Horse(net.minecraft.world.entity.animal.horse.Horse) ZombieHorse(net.minecraft.world.entity.animal.horse.ZombieHorse) AbstractChestedHorse(net.minecraft.world.entity.animal.horse.AbstractChestedHorse) AbstractHorse(net.minecraft.world.entity.animal.horse.AbstractHorse) ZombieAttackGoal(net.minecraft.world.entity.ai.goal.ZombieAttackGoal) InteractGoal(net.minecraft.world.entity.ai.goal.InteractGoal) BreathAirGoal(net.minecraft.world.entity.ai.goal.BreathAirGoal) MoveBackToVillageGoal(net.minecraft.world.entity.ai.goal.MoveBackToVillageGoal) Zombie(net.minecraft.world.entity.monster.Zombie) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtByTargetGoal) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtByTargetGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtTargetGoal) MagicCheckOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicCheckOwnerGoal) Requirement(com.elmakers.mine.bukkit.api.requirements.Requirement) Mage(com.elmakers.mine.bukkit.api.magic.Mage) Animal(net.minecraft.world.entity.animal.Animal) TamableAnimal(net.minecraft.world.entity.TamableAnimal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowMobGoal) LandOnOwnersShoulderGoal(net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) LeapAtTargetGoal(net.minecraft.world.entity.ai.goal.LeapAtTargetGoal) MoveThroughVillageGoal(net.minecraft.world.entity.ai.goal.MoveThroughVillageGoal) ItemStack(net.minecraft.world.item.ItemStack) FollowOwnerGoal(net.minecraft.world.entity.ai.goal.FollowOwnerGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowOwnerGoal) MoveTowardsTargetGoal(net.minecraft.world.entity.ai.goal.MoveTowardsTargetGoal) DefendVillageTargetGoal(net.minecraft.world.entity.ai.goal.target.DefendVillageTargetGoal) MagicFollowOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowOwnerGoal) RunAroundLikeCrazyGoal(net.minecraft.world.entity.ai.goal.RunAroundLikeCrazyGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) MoveTowardsRestrictionGoal(net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal) StrollThroughVillageGoal(net.minecraft.world.entity.ai.goal.StrollThroughVillageGoal) SwellGoal(net.minecraft.world.entity.ai.goal.SwellGoal) TamableAnimal(net.minecraft.world.entity.TamableAnimal) Creeper(net.minecraft.world.entity.monster.Creeper) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) FollowFlockLeaderGoal(net.minecraft.world.entity.ai.goal.FollowFlockLeaderGoal) OwnerHurtTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal) MagicOwnerHurtTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtTargetGoal) IronGolem(net.minecraft.world.entity.animal.IronGolem) FleeSunGoal(net.minecraft.world.entity.ai.goal.FleeSunGoal) ShoulderRidingEntity(net.minecraft.world.entity.animal.ShoulderRidingEntity) EatBlockGoal(net.minecraft.world.entity.ai.goal.EatBlockGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) Wolf(net.minecraft.world.entity.animal.Wolf) OpenDoorGoal(net.minecraft.world.entity.ai.goal.OpenDoorGoal) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) BreakDoorGoal(net.minecraft.world.entity.ai.goal.BreakDoorGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) MagicOwnerHurtByTargetGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicOwnerHurtByTargetGoal) OwnerHurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.OwnerHurtByTargetGoal) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) GolemRandomStrollInVillageGoal(net.minecraft.world.entity.ai.goal.GolemRandomStrollInVillageGoal) Material(org.bukkit.Material) WaterAvoidingRandomFlyingGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicPanicGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal) MagicPanicGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicPanicGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) MagicFindOwnerGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFindOwnerGoal) RequirementsGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.RequirementsGoal) OcelotAttackGoal(net.minecraft.world.entity.ai.goal.OcelotAttackGoal) AbstractSchoolingFish(net.minecraft.world.entity.animal.AbstractSchoolingFish) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) MagicFollowMobGoal(com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.MagicFollowMobGoal) RandomSwimmingGoal(net.minecraft.world.entity.ai.goal.RandomSwimmingGoal) PathfinderMob(net.minecraft.world.entity.PathfinderMob) ItemUtils(com.elmakers.mine.bukkit.utility.platform.ItemUtils) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) OfferFlowerGoal(net.minecraft.world.entity.ai.goal.OfferFlowerGoal)

Example 8 with IdleGoal

use of com.elmakers.mine.bukkit.utility.platform.v1_17_1.goal.IdleGoal 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

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