Search in sources :

Example 1 with RestrictSunGoal

use of net.minecraft.entity.ai.goal.RestrictSunGoal in project Vampirism by TeamLapen.

the class CurableConvertedCreature method registerGoalsC.

/**
 * call in {@link CreatureEntity#registerGoals()}
 */
default void registerGoalsC() {
    CreatureEntity entity = ((CreatureEntity) this);
    entity.goalSelector.addGoal(1, new AvoidEntityGoal<>(entity, CreatureEntity.class, 10, 1, 1.1, VampirismAPI.factionRegistry().getPredicate(getFaction(), false, true, false, false, VReference.HUNTER_FACTION)));
    entity.goalSelector.addGoal(4, new RestrictSunGoal(entity));
    entity.targetSelector.addGoal(1, new HurtByTargetGoal(entity));
    entity.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(entity, PlayerEntity.class, 5, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), true, false, true, false, null)));
    entity.targetSelector.addGoal(6, new NearestAttackableTargetGoal<>(entity, CreatureEntity.class, 5, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), false, false, false, false, null)));
}
Also used : RestrictSunGoal(net.minecraft.entity.ai.goal.RestrictSunGoal) HurtByTargetGoal(net.minecraft.entity.ai.goal.HurtByTargetGoal) CreatureEntity(net.minecraft.entity.CreatureEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with RestrictSunGoal

use of net.minecraft.entity.ai.goal.RestrictSunGoal in project Champions by TheIllusiveC4.

the class MoltenAffix method onSpawn.

@Override
public void onSpawn(IChampion champion) {
    LivingEntity livingEntity = champion.getLivingEntity();
    livingEntity.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 40, 0, true, false));
    if (livingEntity instanceof MobEntity) {
        MobEntity mobEntity = (MobEntity) livingEntity;
        mobEntity.setPathPriority(PathNodeType.WATER, -1.0F);
        mobEntity.setPathPriority(PathNodeType.LAVA, 8.0F);
        mobEntity.setPathPriority(PathNodeType.DANGER_FIRE, 0.0F);
        mobEntity.setPathPriority(PathNodeType.DAMAGE_FIRE, 0.0F);
        try {
            @SuppressWarnings("unchecked") Set<PrioritizedGoal> goals = (Set<PrioritizedGoal>) GOALS.get(mobEntity.goalSelector);
            Iterator<PrioritizedGoal> iter = goals.iterator();
            while (iter.hasNext()) {
                PrioritizedGoal goal = iter.next();
                Goal baseGoal = goal.getGoal();
                if (baseGoal instanceof FleeSunGoal || baseGoal instanceof RestrictSunGoal) {
                    iter.remove();
                }
            }
        } catch (Exception e) {
            Champions.LOGGER.error("Error accessing goals!");
        }
        if (mobEntity.getNavigator() instanceof GroundPathNavigator) {
            ((GroundPathNavigator) mobEntity.getNavigator()).setAvoidSun(false);
        }
    }
}
Also used : Set(java.util.Set) FleeSunGoal(net.minecraft.entity.ai.goal.FleeSunGoal) LivingEntity(net.minecraft.entity.LivingEntity) Goal(net.minecraft.entity.ai.goal.Goal) RestrictSunGoal(net.minecraft.entity.ai.goal.RestrictSunGoal) FleeSunGoal(net.minecraft.entity.ai.goal.FleeSunGoal) PrioritizedGoal(net.minecraft.entity.ai.goal.PrioritizedGoal) RestrictSunGoal(net.minecraft.entity.ai.goal.RestrictSunGoal) GroundPathNavigator(net.minecraft.pathfinding.GroundPathNavigator) PrioritizedGoal(net.minecraft.entity.ai.goal.PrioritizedGoal) EffectInstance(net.minecraft.potion.EffectInstance) MobEntity(net.minecraft.entity.MobEntity)

Aggregations

RestrictSunGoal (net.minecraft.entity.ai.goal.RestrictSunGoal)2 Set (java.util.Set)1 CreatureEntity (net.minecraft.entity.CreatureEntity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 FleeSunGoal (net.minecraft.entity.ai.goal.FleeSunGoal)1 Goal (net.minecraft.entity.ai.goal.Goal)1 HurtByTargetGoal (net.minecraft.entity.ai.goal.HurtByTargetGoal)1 PrioritizedGoal (net.minecraft.entity.ai.goal.PrioritizedGoal)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 GroundPathNavigator (net.minecraft.pathfinding.GroundPathNavigator)1 EffectInstance (net.minecraft.potion.EffectInstance)1