Search in sources :

Example 1 with CrystalBossBuddy

use of com.finderfeed.solarforge.misc_things.CrystalBossBuddy in project SolarCraftRepository by FINDERFEED.

the class EarthquakeEntity method tick.

@Override
public void tick() {
    if (!level.isClientSide) {
        this.setDirection(this.getDir());
        this.setLength(this.getLength());
        if (tickCount == ACTIVATION_TIME) {
            Vec3 dir = this.entityData.get(DIRECTION_VECTOR);
            Vec3 initPos = position();
            Vec3 endPos = initPos.add(dir.normalize().multiply(getLength() + 1, 0, getLength() + 1));
            Vec3 beetween = initPos.subtract(endPos).normalize();
            AABB box = new AABB(initPos.x + beetween.x, initPos.y, initPos.z + beetween.z, endPos.x + beetween.reverse().x, endPos.y + 6, endPos.z + beetween.reverse().z);
            for (LivingEntity e : level.getEntitiesOfClass(LivingEntity.class, box, (l) -> !(l instanceof CrystalBossBuddy))) {
                Vec3 vec = endPos.subtract(initPos).multiply(1, 0, 1);
                Vec3 ePos = e.position().subtract(initPos).multiply(1, 0, 1);
                double main = vec.length();
                double a = ePos.length();
                double b = vec.subtract(ePos).length();
                double p = (main + a + b) / 2;
                double S = Math.sqrt(p * (p - a) * (p - b) * (p - main));
                double H = 2 * S / main;
                if (H <= 2) {
                    e.hurt(DamageSource.MAGIC, damage);
                }
            }
        }
        if (tickCount >= DEATH_TIME - 20) {
            this.kill();
        }
    } else {
        if (tickCount == ACTIVATION_TIME - 2) {
            Vec3 dir = this.entityData.get(DIRECTION_VECTOR);
            Vec3 initPos = position();
            Vec3 endPos = initPos.add(dir.normalize().multiply(getLength(), 0, getLength()));
            Vec3 between = endPos.subtract(initPos);
            for (int i = 0; i < 5; i++) {
                for (double g = 0; g <= between.length(); g += 0.75) {
                    double percentile = (g + level.random.nextDouble() * 0.3) / between.length();
                    Vec3 pos = initPos.add(between.multiply(percentile, 0, percentile));
                    ClientHelpers.ParticleAnimationHelper.createParticle(ParticleTypesRegistry.SMALL_SOLAR_STRIKE_PARTICLE.get(), pos.x, pos.y, pos.z, 0, (0.1 + level.random.nextDouble() * 0.05) * (1 - i / 4f), 0, () -> 255, () -> 255, () -> 0, 0.5f * (i / 4f));
                }
            }
        }
    }
    super.tick();
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) Vec3(net.minecraft.world.phys.Vec3) CrystalBossBuddy(com.finderfeed.solarforge.misc_things.CrystalBossBuddy) AABB(net.minecraft.world.phys.AABB)

Example 2 with CrystalBossBuddy

use of com.finderfeed.solarforge.misc_things.CrystalBossBuddy in project SolarCraftRepository by FINDERFEED.

the class SunstrikeEntity method explode.

public void explode() {
    for (LivingEntity entity : this.level.getEntitiesOfClass(LivingEntity.class, new AABB(-2, -2, -2, 2, 2, 2).move(position()), (e) -> !(e instanceof CrystalBossBuddy))) {
        if (Helpers.isVulnerable(entity)) {
            entity.hurt(DamageSource.MAGIC, damage);
            entity.invulnerableTime = 0;
        }
    }
    level.playSound(null, this.getX(), this.getY(), this.getZ(), Sounds.SOLAR_EXPLOSION.get(), SoundSource.AMBIENT, level.random.nextFloat() * 0.5f + 0.5f, 1f);
    ExplosionParticlesPacket.send(level, this.position());
    this.discard();
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) CrystalBossBuddy(com.finderfeed.solarforge.misc_things.CrystalBossBuddy) AABB(net.minecraft.world.phys.AABB)

Example 3 with CrystalBossBuddy

use of com.finderfeed.solarforge.misc_things.CrystalBossBuddy in project SolarCraftRepository by FINDERFEED.

the class ExplosiveCrystal method tick.

@Override
public void tick() {
    super.tick();
    if (level.isClientSide) {
        if (isDeploying()) {
            for (int i = 0; i < 6; i++) {
                double[] xz = FinderfeedMathHelper.rotatePointDegrees(1.5 * (1 - (float) tickCount / DEPLOYING_TIME), 0, i * 60 + tickCount * 5);
                ClientHelpers.ParticleAnimationHelper.createParticle(ParticleTypesRegistry.SMALL_SOLAR_STRIKE_PARTICLE.get(), position().x + xz[0], position().y + 1.5, position().z + xz[1], 0, 0, 0, () -> 200 + level.random.nextInt(55), () -> 0, () -> 0, 0.3f);
            }
        }
    } else {
        int seconds = getRemainingActivationSeconds();
        if (!this.isDeadOrDying()) {
            if (seconds <= 0) {
                for (LivingEntity living : level.getEntitiesOfClass(LivingEntity.class, new AABB(-32, -32, -32, 32, 32, 32).move(position()), (l) -> !(l instanceof CrystalBossBuddy))) {
                    living.invulnerableTime = 0;
                    living.hurt(DamageSource.MAGIC, 60);
                }
                level.playSound(null, position().x, position().y + this.getBbHeight() / 2, position().z, SoundEvents.GENERIC_EXPLODE, SoundSource.HOSTILE, 1, 1);
                level.addParticle(ParticleTypes.EXPLOSION_EMITTER, position().x, position().y + this.getBbHeight() / 2, position().z, 0, 0, 0);
                ((ServerLevel) level).sendParticles(ParticleTypes.EXPLOSION_EMITTER, position().x, position().y + this.getBbHeight() / 2, position().z, 1, 0, 0, 0, 0);
                this.kill();
            } else {
                if (tickCount % 20 == 0 && !isDeploying()) {
                    if (!level.getEntitiesOfClass(Player.class, new AABB(-32, -32, -32, 32, 32, 32).move(position())).isEmpty()) {
                        setActivationSecondsRemaining(getRemainingActivationSeconds() - 1);
                    }
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) ServerLevel(net.minecraft.server.level.ServerLevel) CrystalBossBuddy(com.finderfeed.solarforge.misc_things.CrystalBossBuddy) AABB(net.minecraft.world.phys.AABB)

Example 4 with CrystalBossBuddy

use of com.finderfeed.solarforge.misc_things.CrystalBossBuddy in project SolarCraftRepository by FINDERFEED.

the class MineEntityCrystalBoss method blowUp.

public void blowUp() {
    level.getEntitiesOfClass(LivingEntity.class, new AABB(-1.5, -1.0, -1.5, 1.5, 2, 1.5).move(position()), (ent) -> {
        return !(ent instanceof CrystalBossBuddy);
    }).forEach((living) -> {
        living.setDeltaMovement(living.position().subtract(this.position()).normalize().add(0, 1, 0).multiply(1.5, 1.5, 1.5));
    });
    if (this.level.isClientSide) {
        createExplosionParticles();
    }
    if (!this.level.isClientSide) {
        level.playSound(null, this.getX(), this.getY(), this.getZ(), Sounds.SOLAR_EXPLOSION.get(), SoundSource.AMBIENT, level.random.nextFloat() * 0.5f + 0.5f, 1f);
        level.getEntitiesOfClass(LivingEntity.class, new AABB(-1.5, -1.0, -1.5, 1.5, 2, 1.5).move(position()), (ent) -> {
            return !(ent instanceof CrystalBossBuddy);
        }).forEach((living) -> {
            living.hurt(DamageSource.MAGIC, CrystalBossEntity.MINES_DAMAGE);
        });
    }
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) SoundSource(net.minecraft.sounds.SoundSource) LivingEntity(net.minecraft.world.entity.LivingEntity) AABB(net.minecraft.world.phys.AABB) EntityType(net.minecraft.world.entity.EntityType) AttributeSupplier(net.minecraft.world.entity.ai.attributes.AttributeSupplier) Helpers(com.finderfeed.solarforge.Helpers) EntityDataSerializers(net.minecraft.network.syncher.EntityDataSerializers) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) CrystalBossBuddy(com.finderfeed.solarforge.misc_things.CrystalBossBuddy) EntityDataAccessor(net.minecraft.network.syncher.EntityDataAccessor) Sounds(com.finderfeed.solarforge.registries.sounds.Sounds) SynchedEntityData(net.minecraft.network.syncher.SynchedEntityData) CompoundTag(net.minecraft.nbt.CompoundTag) Entity(net.minecraft.world.entity.Entity) DamageSource(net.minecraft.world.damagesource.DamageSource) Attributes(net.minecraft.world.entity.ai.attributes.Attributes) Packet(net.minecraft.network.protocol.Packet) PathfinderMob(net.minecraft.world.entity.PathfinderMob) Level(net.minecraft.world.level.Level) NetworkHooks(net.minecraftforge.network.NetworkHooks) CrystalBossBuddy(com.finderfeed.solarforge.misc_things.CrystalBossBuddy) AABB(net.minecraft.world.phys.AABB)

Aggregations

CrystalBossBuddy (com.finderfeed.solarforge.misc_things.CrystalBossBuddy)4 LivingEntity (net.minecraft.world.entity.LivingEntity)4 AABB (net.minecraft.world.phys.AABB)4 Helpers (com.finderfeed.solarforge.Helpers)1 Sounds (com.finderfeed.solarforge.registries.sounds.Sounds)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 Packet (net.minecraft.network.protocol.Packet)1 EntityDataAccessor (net.minecraft.network.syncher.EntityDataAccessor)1 EntityDataSerializers (net.minecraft.network.syncher.EntityDataSerializers)1 SynchedEntityData (net.minecraft.network.syncher.SynchedEntityData)1 ServerLevel (net.minecraft.server.level.ServerLevel)1 SoundSource (net.minecraft.sounds.SoundSource)1 DamageSource (net.minecraft.world.damagesource.DamageSource)1 MobEffectInstance (net.minecraft.world.effect.MobEffectInstance)1 Entity (net.minecraft.world.entity.Entity)1 EntityType (net.minecraft.world.entity.EntityType)1 PathfinderMob (net.minecraft.world.entity.PathfinderMob)1 AttributeSupplier (net.minecraft.world.entity.ai.attributes.AttributeSupplier)1 Attributes (net.minecraft.world.entity.ai.attributes.Attributes)1 Level (net.minecraft.world.level.Level)1