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