Search in sources :

Example 1 with MantleEffectBootes

use of hellfirepvp.astralsorcery.common.constellation.mantle.effect.MantleEffectBootes in project AstralSorcery by HellFirePvP.

the class EntityFlare method tick.

@Override
public void tick() {
    super.tick();
    this.entityAge++;
    if (this.getEntityWorld().isRemote()) {
        this.tickClient();
    } else {
        if (this.isAmbient() && this.entityAge > 600 && rand.nextInt(600) == 0) {
            DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
        }
        if (this.isAlive()) {
            if (EntityConfig.CONFIG.flareAttackBats.get() && rand.nextInt(30) == 0) {
                BatEntity closest = EntityUtils.getClosestEntity(this.getEntityWorld(), BatEntity.class, this.getBoundingBox().grow(10), Vector3.atEntityCenter(this));
                if (closest != null) {
                    this.doLightningAttack(closest, 100F);
                }
            }
            if (EntityConfig.CONFIG.flareAttackPhantoms.get() && rand.nextInt(30) == 0) {
                PhantomEntity closest = EntityUtils.getClosestEntity(this.getEntityWorld(), PhantomEntity.class, this.getBoundingBox().grow(10), Vector3.atEntityCenter(this));
                if (closest != null) {
                    this.doLightningAttack(closest, 100F);
                }
            }
            if (this.isAmbient()) {
                boolean atTarget = this.currentMoveTarget == null || this.currentMoveTarget.distance(this) < 5.0;
                if (atTarget) {
                    this.currentMoveTarget = null;
                }
                if (this.currentMoveTarget == null && rand.nextInt(150) == 0) {
                    BlockPos newTarget = this.getPosition().add(rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1), rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1), rand.nextInt(RANDOM_WANDER_RANGE) * (rand.nextBoolean() ? 1 : -1));
                    if (newTarget.getY() > 1 && newTarget.getY() < 254 && new Vector3(newTarget).distance(this) >= 5.0) {
                        MiscUtils.executeWithChunk(this.getEntityWorld(), newTarget, () -> {
                            this.currentMoveTarget = new Vector3(newTarget);
                        });
                    }
                }
            } else if (this.getAttackTarget() != null) {
                if (!this.getAttackTarget().isAlive() || (this.getFollowingTarget() != null && this.getFollowingTarget().getDistance(this) > 30.0F)) {
                    this.setAttackTarget(null);
                } else {
                    Vector3 newTarget = Vector3.atEntityCenter(this.getAttackTarget()).addY(1.5F);
                    if (newTarget.getY() > 1 && newTarget.getY() < 254 && newTarget.distance(this) >= 3.0) {
                        this.currentMoveTarget = newTarget;
                    } else {
                        this.currentMoveTarget = null;
                    }
                }
            } else if (this.followingEntityId != -1) {
                LivingEntity following = this.getFollowingTarget();
                if (following == null) {
                    DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                } else {
                    MantleEffectBootes effect = ItemMantle.getEffect(following, ConstellationsAS.bootes);
                    if (effect == null) {
                        DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                        return;
                    }
                    if (this.getAttackTarget() != null && !this.getAttackTarget().isAlive()) {
                        this.setAttackTarget(null);
                    }
                    if (this.getAttackTarget() == null) {
                        Vector3 newTarget = Vector3.atEntityCenter(following).addY(2.5F);
                        if (newTarget.distance(this) >= 2.0) {
                            this.currentMoveTarget = newTarget;
                        } else {
                            this.currentMoveTarget = null;
                        }
                    }
                }
            } else {
                DamageUtil.attackEntityFrom(this, CommonProxy.DAMAGE_SOURCE_STELLAR, 1F);
                return;
            }
            LivingEntity target = this.getAttackTarget();
            if (target != null && target.isAlive() && target.getDistance(this) < 10 && rand.nextInt(40) == 0) {
                DamageUtil.shotgunAttack(target, e -> this.doLightningAttack(e, 2F + rand.nextFloat() * 2F));
            }
            this.doMovement();
        }
    }
}
Also used : MantleEffectBootes(hellfirepvp.astralsorcery.common.constellation.mantle.effect.MantleEffectBootes) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) BatEntity(net.minecraft.entity.passive.BatEntity) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Aggregations

MantleEffectBootes (hellfirepvp.astralsorcery.common.constellation.mantle.effect.MantleEffectBootes)1 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)1 PhantomEntity (net.minecraft.entity.monster.PhantomEntity)1 BatEntity (net.minecraft.entity.passive.BatEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1