Search in sources :

Example 6 with EntityExplosion

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();
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) EntityExplosion(icbm.classic.content.entity.EntityExplosion)

Example 7 with EntityExplosion

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;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) IMissile(icbm.classic.api.caps.IMissile) EntityExplosion(icbm.classic.content.entity.EntityExplosion) BlastAntimatter(icbm.classic.content.blast.threaded.BlastAntimatter) Vec3d(net.minecraft.util.math.Vec3d) EntityItem(net.minecraft.entity.item.EntityItem) Location(icbm.classic.lib.transform.vector.Location)

Aggregations

EntityExplosion (icbm.classic.content.entity.EntityExplosion)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 BlastAntimatter (icbm.classic.content.blast.threaded.BlastAntimatter)2 EntityExplosive (icbm.classic.content.entity.EntityExplosive)2 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)2 Entity (net.minecraft.entity.Entity)2 EntityLiving (net.minecraft.entity.EntityLiving)2 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)2 EulerAngle (com.builtbroken.mc.imp.transform.rotation.EulerAngle)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 IMissile (icbm.classic.api.caps.IMissile)1 IBlast (icbm.classic.api.explosion.IBlast)1 EntityMissile (icbm.classic.content.entity.EntityMissile)1 EntityMissile (icbm.classic.content.entity.missile.EntityMissile)1 BlastEMP (icbm.classic.content.explosive.blast.BlastEMP)1 BlastRedmatter (icbm.classic.content.explosive.blast.BlastRedmatter)1 Location (icbm.classic.lib.transform.vector.Location)1 List (java.util.List)1 Random (java.util.Random)1