Search in sources :

Example 1 with RandomSwimmingGoal

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

use of net.minecraft.entity.ai.goal.RandomSwimmingGoal in project upgrade-aquatic by team-abnormals.

the class PikeEntity method registerGoals.

@Override
protected void registerGoals() {
    super.registerGoals();
    if (this.getPikeType() != PikeType.SPECTRAL) {
        this.goalSelector.addGoal(2, new AvoidEntityGoal<PikeEntity>(this, PikeEntity.class, 8.0F, 1.6D, 1.4D, UAEntityPredicates.IS_SPECTRAL::test) {

            @Override
            public boolean shouldExecute() {
                return super.shouldExecute() && this.entity != null && ((PikeEntity) this.entity).getPikeType() != PikeType.SPECTRAL;
            }
        });
    }
    this.goalSelector.addGoal(3, new PikeTemptGoal(this));
    this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.1D, 40) {

        @Override
        public boolean shouldExecute() {
            return ((PikeEntity) creature).isHidingInPickerelweed() ? super.shouldExecute() && creature.getRNG().nextInt(6) == 0 : super.shouldExecute();
        }
    });
    this.goalSelector.addGoal(4, new HideInPickerelweedGoal(this));
    this.goalSelector.addGoal(4, new PikeSwimToItemsGoal(this));
    this.goalSelector.addGoal(4, new PikeAttackGoal(this, 12D, true));
    this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<AbstractFishEntity>(this, AbstractFishEntity.class, true) {

        @Override
        public boolean shouldExecute() {
            return ((PikeEntity) this.goalOwner).getAttackCooldown() <= 0 && super.shouldExecute();
        }
    });
    this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<TurtleEntity>(this, TurtleEntity.class, 10, true, false, UAEntityPredicates.IS_CHILD::test) {

        @Override
        public boolean shouldExecute() {
            return ((PikeEntity) this.goalOwner).getAttackCooldown() <= 0 && super.shouldExecute();
        }
    });
    this.targetSelector.addGoal(2, new HurtByTargetGoal(this));
}
Also used : TurtleEntity(net.minecraft.entity.passive.TurtleEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) HurtByTargetGoal(net.minecraft.entity.ai.goal.HurtByTargetGoal) UAEntityPredicates(com.minecraftabnormals.upgrade_aquatic.api.util.UAEntityPredicates) RandomSwimmingGoal(net.minecraft.entity.ai.goal.RandomSwimmingGoal)

Aggregations

HurtByTargetGoal (net.minecraft.entity.ai.goal.HurtByTargetGoal)2 RandomSwimmingGoal (net.minecraft.entity.ai.goal.RandomSwimmingGoal)2 UAEntityPredicates (com.minecraftabnormals.upgrade_aquatic.api.util.UAEntityPredicates)1 TurtleEntity (net.minecraft.entity.passive.TurtleEntity)1 AbstractFishEntity (net.minecraft.entity.passive.fish.AbstractFishEntity)1 TropicalFishEntity (net.minecraft.entity.passive.fish.TropicalFishEntity)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1