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));
}
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));
}
}
}
Aggregations