Search in sources :

Example 1 with FleeSunGoal

use of net.minecraft.entity.ai.goal.FleeSunGoal 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

Set (java.util.Set)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 PrioritizedGoal (net.minecraft.entity.ai.goal.PrioritizedGoal)1 RestrictSunGoal (net.minecraft.entity.ai.goal.RestrictSunGoal)1 GroundPathNavigator (net.minecraft.pathfinding.GroundPathNavigator)1 EffectInstance (net.minecraft.potion.EffectInstance)1