Search in sources :

Example 1 with TropicalFishEntity

use of net.minecraft.entity.passive.fish.TropicalFishEntity in project upgrade-aquatic by team-abnormals.

the class LionfishEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.35D, 30) {

        @Override
        public boolean shouldExecute() {
            if (this.creature.isBeingRidden()) {
                return false;
            } else {
                if (!this.mustUpdate) {
                    if (this.creature.getIdleTime() >= 100) {
                        return false;
                    }
                    if (((LionfishEntity) this.creature).isHungry()) {
                        if (this.creature.getRNG().nextInt(60) != 0) {
                            return false;
                        }
                    } else {
                        if (this.creature.getRNG().nextInt(30) != 0) {
                            return false;
                        }
                    }
                }
                Vector3d vec3d = this.getPosition();
                if (vec3d == null) {
                    return false;
                } else {
                    this.x = vec3d.x;
                    this.y = vec3d.y;
                    this.z = vec3d.z;
                    this.mustUpdate = false;
                    return true;
                }
            }
        }
    });
    this.goalSelector.addGoal(4, new LionfishEntity.LionfishAttackGoal(this, 12D, true));
    this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<TropicalFishEntity>(this, TropicalFishEntity.class, true) {

        @Override
        public boolean shouldExecute() {
            return ((LionfishEntity) this.goalOwner).isHungry() && super.shouldExecute();
        }
    });
    this.targetSelector.addGoal(2, new HurtByTargetGoal(this));
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) TropicalFishEntity(net.minecraft.entity.passive.fish.TropicalFishEntity) HurtByTargetGoal(net.minecraft.entity.ai.goal.HurtByTargetGoal) RandomSwimmingGoal(net.minecraft.entity.ai.goal.RandomSwimmingGoal)

Example 2 with TropicalFishEntity

use of net.minecraft.entity.passive.fish.TropicalFishEntity in project upgrade-aquatic by team-abnormals.

the class EntityEvents method onEntitySpawned.

@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onEntitySpawned(EntityJoinWorldEvent event) {
    if (event.getWorld().isRemote)
        return;
    Entity entity = event.getEntity();
    if (entity instanceof DrownedEntity) {
        ((CreatureEntity) entity).goalSelector.addGoal(3, new AvoidEntityGoal<>((CreatureEntity) entity, TurtleEntity.class, 6.0F, 1.0D, 1.2D));
    }
    if (entity instanceof AbstractFishEntity) {
        ((AbstractFishEntity) entity).goalSelector.addGoal(2, new AvoidEntityGoal<>((CreatureEntity) entity, PikeEntity.class, 8.0F, 1.6D, 1.4D, UAEntityPredicates.IS_HIDING_IN_PICKERELWEED::test));
        if (entity instanceof TropicalFishEntity) {
            ((AbstractFishEntity) entity).goalSelector.addGoal(2, new AvoidEntityGoal<>((CreatureEntity) entity, LionfishEntity.class, 8.0F, 1.6D, 1.4D, EntityPredicates.IS_ALIVE::test));
        }
    }
    if (entity instanceof WaterMobEntity && !(entity instanceof IMob)) {
        if (!(entity instanceof DolphinEntity)) {
            ((MobEntity) entity).goalSelector.addGoal(1, new AvoidEntityGoal<>((CreatureEntity) entity, ThrasherEntity.class, 20.0F, 1.4D, 1.6D, EntityPredicates.IS_ALIVE::test));
        }
        if (entity instanceof DolphinEntity) {
            ((MobEntity) entity).targetSelector.addGoal(0, (new HurtByTargetGoal((DolphinEntity) entity, ThrasherEntity.class)).setCallsForHelp());
            ((MobEntity) entity).goalSelector.addGoal(1, new MeleeAttackGoal((DolphinEntity) entity, 1.2D, true));
        }
    }
}
Also used : PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity) DolphinEntity(net.minecraft.entity.passive.DolphinEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) SquidEntity(net.minecraft.entity.passive.SquidEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) LionfishEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.LionfishEntity) DrownedEntity(net.minecraft.entity.monster.DrownedEntity) CreatureEntity(net.minecraft.entity.CreatureEntity) TurtleEntity(net.minecraft.entity.passive.TurtleEntity) TropicalFishEntity(net.minecraft.entity.passive.fish.TropicalFishEntity) MobEntity(net.minecraft.entity.MobEntity) Entity(net.minecraft.entity.Entity) TurtleEntity(net.minecraft.entity.passive.TurtleEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) HurtByTargetGoal(net.minecraft.entity.ai.goal.HurtByTargetGoal) DolphinEntity(net.minecraft.entity.passive.DolphinEntity) CreatureEntity(net.minecraft.entity.CreatureEntity) PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity) LionfishEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.LionfishEntity) UAEntityPredicates(com.minecraftabnormals.upgrade_aquatic.api.util.UAEntityPredicates) EntityPredicates(net.minecraft.util.EntityPredicates) UAEntityPredicates(com.minecraftabnormals.upgrade_aquatic.api.util.UAEntityPredicates) IMob(net.minecraft.entity.monster.IMob) MeleeAttackGoal(net.minecraft.entity.ai.goal.MeleeAttackGoal) TropicalFishEntity(net.minecraft.entity.passive.fish.TropicalFishEntity) DrownedEntity(net.minecraft.entity.monster.DrownedEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

HurtByTargetGoal (net.minecraft.entity.ai.goal.HurtByTargetGoal)2 TropicalFishEntity (net.minecraft.entity.passive.fish.TropicalFishEntity)2 UAEntityPredicates (com.minecraftabnormals.upgrade_aquatic.api.util.UAEntityPredicates)1 LionfishEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.LionfishEntity)1 PikeEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)1 ThrasherEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity)1 CreatureEntity (net.minecraft.entity.CreatureEntity)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 MeleeAttackGoal (net.minecraft.entity.ai.goal.MeleeAttackGoal)1 RandomSwimmingGoal (net.minecraft.entity.ai.goal.RandomSwimmingGoal)1 DrownedEntity (net.minecraft.entity.monster.DrownedEntity)1 IMob (net.minecraft.entity.monster.IMob)1 PhantomEntity (net.minecraft.entity.monster.PhantomEntity)1 DolphinEntity (net.minecraft.entity.passive.DolphinEntity)1 SquidEntity (net.minecraft.entity.passive.SquidEntity)1 TurtleEntity (net.minecraft.entity.passive.TurtleEntity)1 WaterMobEntity (net.minecraft.entity.passive.WaterMobEntity)1 AbstractFishEntity (net.minecraft.entity.passive.fish.AbstractFishEntity)1