use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doPostExplode.
@Override
protected void doPostExplode() {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.explosionX - this.explosionSize, this.explosionY - this.explosionSize, this.explosionZ - this.explosionSize, this.explosionX + this.explosionSize, this.explosionY + this.explosionSize, this.explosionZ + this.explosionSize);
List<?> list = this.world().getEntitiesWithinAABB(EntityExplosion.class, bounds);
for (Object obj : list) {
if (obj instanceof EntityExplosion) {
EntityExplosion explosion = (EntityExplosion) obj;
if (explosion.getBlast() == this) {
explosion.setDead();
}
}
}
}
use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class Blast method doDamageEntities.
/**
* @return true if the method ran successfully, false if it was interrupted
*/
protected boolean doDamageEntities(float radius, float power, boolean destroyItem) {
// Step 2: Damage all entities
radius *= 2.0F;
Location minCoord = location.add(-radius - 1);
Location maxCoord = location.add(radius + 1);
List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(minCoord.xi(), minCoord.yi(), minCoord.zi(), maxCoord.xi(), maxCoord.yi(), maxCoord.zi()));
Vec3d var31 = new Vec3d(location.x(), location.y(), location.z());
if (!ConfigBlast.ANTIMATTER_BLOCK_AND_ENT_DAMAGE_ON_REDMATTER && this instanceof BlastAntimatter) {
allEntities.sort((e1, e2) -> {
if (e2 instanceof EntityExplosion && ((EntityExplosion) e2).getBlast() instanceof BlastRedmatter) {
// put red matter at the front
return 1;
} else {
return -1;
}
});
if (// remove red matter blast and stop doing anything else
onDamageEntity(allEntities.get(0))) {
return false;
}
}
for (int i = 0; i < allEntities.size(); ++i) {
Entity entity = allEntities.get(i);
if (this.onDamageEntity(entity)) {
continue;
}
if (entity instanceof IMissile) {
((IMissile) entity).destroyMissile(true);
continue;
}
if (entity instanceof EntityItem && !destroyItem) {
continue;
}
double distance = entity.getDistance(location.x(), location.y(), location.z()) / radius;
if (distance <= 1.0D) {
double xDifference = entity.posX - location.x();
double yDifference = entity.posY - location.y();
double zDifference = entity.posZ - location.z();
double var35 = MathHelper.sqrt(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
xDifference /= var35;
yDifference /= var35;
zDifference /= var35;
double var34 = world().getBlockDensity(var31, entity.getEntityBoundingBox());
double var36 = (1.0D - distance) * var34;
int damage = 0;
damage = (int) ((var36 * var36 + var36) / 2.0D * 8.0D * power + 1.0D);
entity.attackEntityFrom(DamageSource.causeExplosionDamage(this), damage);
entity.motionX += xDifference * var36;
entity.motionY += yDifference * var36;
entity.motionZ += zDifference * var36;
}
}
return true;
}
Aggregations