Search in sources :

Example 1 with BlastAntimatter

use of icbm.classic.content.blast.threaded.BlastAntimatter in project ICBM-Classic by BuiltBrokenModding.

the class ExplosiveInit method init.

// TODO use a datafixer to flatten missiles into (ex, homing, anti, cluster)
// https://github.com/RS485/LogisticsPipes/blob/dev-mc1122/common/logisticspipes/datafixer/DataFixerSolidBlockItems.java
// https://github.com/RS485/LogisticsPipes/blob/dev-mc1122/common/logisticspipes/datafixer/LPDataFixer.java#L17-L19
// the fuse suppliers all return 100 (default in ExBlockContentReg#getFuseTime) when an unknown enum value is given as a type
public static void init() {
    // =================== Tier 1
    ICBMExplosives.CONDENSED = newEx(0, "condensed", EnumTier.ONE, () -> new BlastTNT().setBlastSize(6));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.CONDENSED.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.CONDENSED);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.CONDENSED.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.CONVENTIONAL);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.CONDENSED.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.CONDENSED);
    ICBMExplosives.SHRAPNEL = newEx(1, "shrapnel", EnumTier.ONE, () -> new BlastShrapnel().setFlaming().setBlastSize(30));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.SHRAPNEL.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.SHRAPNEL);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.SHRAPNEL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.SHRAPNEL);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.SHRAPNEL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.SHRAPNEL);
    ICBMExplosives.INCENDIARY = newEx(2, "incendiary", EnumTier.ONE, () -> new BlastFire().setBlastSize(14));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseTickListener(ICBMExplosives.INCENDIARY.getRegistryName(), (world, x, y, z, tick) -> world.spawnParticle(EnumParticleTypes.LAVA, x, y + 0.5D, z, 0.0D, 0.0D, 0.0D));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.INCENDIARY.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.INCENDIARY);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.INCENDIARY.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.INCENDIARY);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.INCENDIARY.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.INCENDIARY);
    ICBMExplosives.DEBILITATION = newEx(3, "debilitation", EnumTier.ONE, () -> new BlastGasBase(20 * 30, false).setConfuse().setBlastSize(20));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.DEBILITATION.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.DEBILITATION);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.DEBILITATION.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.DEBILITATION);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.DEBILITATION.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.DEBILITATION);
    ICBMExplosives.CHEMICAL = newEx(4, "chemical", EnumTier.ONE, () -> new BlastGasBase(20 * 30, false).setPoison().setRGB(0.8f, 0.8f, 0).setBlastSize(20));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.CHEMICAL.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.CHEMICAL);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.CHEMICAL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.CHEMICAL);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.CHEMICAL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.CHEMICAL);
    ICBMExplosives.ANVIL = newEx(5, "anvil", EnumTier.ONE, () -> new BlastShrapnel().setAnvil().setBlastSize(25));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ANVIL.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ANVIL);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.ANVIL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.ANVIL);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ANVIL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ANVIL);
    ICBMExplosives.REPULSIVE = newEx(6, "repulsive", EnumTier.ONE, () -> new BlastTNT().setDestroyItems().setPushType(PushType.REPEL).setBlastSize(2));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.REPULSIVE.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.REPULSIVE);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.REPULSIVE.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.REPULSIVE);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.REPULSIVE.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.REPULSIVE);
    ICBMExplosives.ATTRACTIVE = newEx(7, "attractive", EnumTier.ONE, () -> new BlastTNT().setDestroyItems().setPushType(PushType.ATTRACT).setBlastSize(2));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ATTRACTIVE.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ATTRACTIVE);
    ICBMClassicAPI.EX_GRENADE_REGISTRY.setFuseSupplier(ICBMExplosives.ATTRACTIVE.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.GRENADES.ATTRACTIVE);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ATTRACTIVE.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ATTRACTIVE);
    // =================== Tier 2
    ICBMExplosives.FRAGMENTATION = newEx(8, "fragmentation", EnumTier.TWO, () -> new BlastShrapnel().setFlaming().setExplosive().setBlastSize(15));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.FRAGMENTATION.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.FRAGMENTATION);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.FRAGMENTATION.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.FRAGMENTATION);
    ICBMExplosives.CONTAGIOUS = newEx(9, "contagious", EnumTier.TWO, () -> new BlastGasBase(20 * 30, false).setContagious().setRGB(0.3f, 0.8f, 0).setBlastSize(20));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.CONTAGIOUS.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.CONTAGIOUS);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.CONTAGIOUS.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.CONTAGIOUS);
    ICBMExplosives.SONIC = newEx(10, "sonic", EnumTier.TWO, () -> new BlastSonic().setBlastSize(15));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.SONIC.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.SONIC);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.SONIC.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.SONIC);
    ICBMExplosives.BREACHING = newEx(11, "breaching", EnumTier.TWO, () -> new BlastBreach(7).setBlastSize(2.5));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.BREACHING.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.BREACHING);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.BREACHING.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.BREACHING);
    // 12 -> Regen
    ICBMExplosives.THERMOBARIC = newEx(13, "thermobaric", EnumTier.TWO, () -> new BlastNuclear().setEnergy(45).setBlastSize(30));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.THERMOBARIC.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.THERMOBARIC);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.THERMOBARIC.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.THERMOBARIC);
    // 14 -> S-Mine
    // =================== Tier 3
    ICBMExplosives.NUCLEAR = newEx(15, "nuclear", EnumTier.THREE, () -> new BlastNuclear().setNuclear().setEnergy(80).setBlastSize(50));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.NUCLEAR.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.NUCLEAR);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.NUCLEAR.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.NUCLEAR);
    ICBMExplosives.EMP = newEx(16, "emp", EnumTier.THREE, () -> new BlastEMP().setEffectBlocks().setEffectEntities().setBlastSize(50));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.EMP.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.EMP);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.EMP.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.EMP);
    ICBMExplosives.EXOTHERMIC = newEx(17, "exothermic", EnumTier.THREE, () -> new BlastExothermic().setBlastSize(30));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseTickListener(ICBMExplosives.EXOTHERMIC.getRegistryName(), (world, x, y, z, tick) -> world.spawnParticle(EnumParticleTypes.LAVA, x, y + 0.5D, z, 0.0D, 0.0D, 0.0D));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.EXOTHERMIC.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.EXOTHERMIC);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.EXOTHERMIC.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.EXOTHERMIC);
    ICBMExplosives.ENDOTHERMIC = newEx(18, "endothermic", EnumTier.THREE, () -> new BlastEndothermic().setBlastSize(30));
    // TODO add ice fuse animation
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ENDOTHERMIC.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ENDOTHERMIC);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ENDOTHERMIC.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ENDOTHERMIC);
    ICBMExplosives.ANTI_GRAVITATIONAL = newEx(19, "antigravitational", EnumTier.THREE, () -> new BlastAntiGravitational().setBlastSize(30));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ANTI_GRAVITATIONAL.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ANTI_GRAVITATIONAL);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ANTI_GRAVITATIONAL.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ANTI_GRAVITATIONAL);
    ICBMExplosives.ENDER = newEx(20, "ender", EnumTier.THREE, () -> new BlastEnderman().setBlastSize(30));
    ICBMClassicAPI.EX_MISSILE_REGISTRY.setInteractionListener(ICBMExplosives.ENDER.getRegistryName(), ExplosiveInit::enderMissileCoordSet);
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setActivationListener(ICBMExplosives.ENDER.getRegistryName(), ExplosiveInit::enderBlockCoordSet);
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ENDER.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ENDER);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ENDER.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ENDER);
    // TODO find Missile model
    ICBMExplosives.HYPERSONIC = newEx(21, "hypersonic", EnumTier.THREE, () -> new BlastSonic().setShockWave().setBlastSize(20));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.HYPERSONIC.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.HYPERSONIC);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.HYPERSONIC.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.HYPERSONIC);
    // =================== Tier 4
    ICBMExplosives.ANTIMATTER = newEx(22, "antimatter", EnumTier.FOUR, () -> new BlastAntimatter().setBlastSize(ConfigBlast.ANTIMATTER_SIZE));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.ANTIMATTER.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.ANTIMATTER);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.ANTIMATTER.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.ANTIMATTER);
    // TODO add config (disable by default) for alarm audio
    ICBMExplosives.REDMATTER = newEx(23, "redMatter", EnumTier.FOUR, () -> new BlastRedmatter().setBlastSize(ConfigBlast.REDMATTER.NORMAL_RADIUS));
    ICBMClassicAPI.EX_BLOCK_REGISTRY.setFuseSupplier(ICBMExplosives.REDMATTER.getRegistryName(), (world, x, y, z) -> ConfigBlast.FUSE_TIMES.EXPLOSIVES.REDMATTER);
    ICBMClassicAPI.EX_MINECART_REGISTRY.setFuseSupplier(ICBMExplosives.REDMATTER.getRegistryName(), (entity) -> ConfigBlast.FUSE_TIMES.BOMB_CARTS.REDMATTER);
    // =================== No content, only blast
    ICBMExplosives.MUTATION = newEx(24, "mutation", EnumTier.NONE, BlastMutation::new);
    ICBMExplosives.ROT = newEx(25, "rot", EnumTier.NONE, BlastRot::new);
    ((ExplosiveRegistry) ICBMClassicAPI.EXPLOSIVE_REGISTRY).lockForce();
// =================== Missiles
// /* 24 */MISSILE(new MissileModule());
// /* 25 */MISSILE_HOMING(new MissileHoming());
// /* 26 */MISSILE_ANTI(new MissileAnti());
// /* 27 */MISSILE_CLUSTER(new MissileCluster("cluster", EnumTier.TWO));
// /* 28 */MISSILE_CLUSTER_NUKE(new MissileNuclearCluster())
}
Also used : BlastEnderman(icbm.classic.content.blast.BlastEnderman) BlastGasBase(icbm.classic.content.blast.BlastGasBase) BlastExothermic(icbm.classic.content.blast.BlastExothermic) BlastBreach(icbm.classic.content.blast.BlastBreach) BlastEndothermic(icbm.classic.content.blast.BlastEndothermic) BlastEMP(icbm.classic.content.blast.BlastEMP) BlastFire(icbm.classic.content.blast.BlastFire) BlastSonic(icbm.classic.content.blast.BlastSonic) ExplosiveRegistry(icbm.classic.lib.explosive.reg.ExplosiveRegistry) BlastAntiGravitational(icbm.classic.content.blast.BlastAntiGravitational) BlastNuclear(icbm.classic.content.blast.threaded.BlastNuclear) BlastAntimatter(icbm.classic.content.blast.threaded.BlastAntimatter) BlastRedmatter(icbm.classic.content.blast.BlastRedmatter) BlastTNT(icbm.classic.content.blast.BlastTNT) BlastShrapnel(icbm.classic.content.blast.BlastShrapnel)

Example 2 with BlastAntimatter

use of icbm.classic.content.blast.threaded.BlastAntimatter in project ICBM-Classic by BuiltBrokenModding.

the class BlastRedmatter method attackEntity.

private void attackEntity(Entity entity, double distance) {
    // Handle eating logic
    if (// TODO make config driven, break section out into its own method
    distance < (ConfigBlast.REDMATTER.ENTITY_DESTROY_RADIUS * getScaleFactor())) {
        if (entity instanceof EntityExplosion) {
            final IBlast blast = ((EntityExplosion) entity).getBlast();
            if (// TODO move to capability
            blast instanceof BlastAntimatter) {
                if (ConfigBlast.REDMATTER.ENABLE_AUDIO) {
                    ICBMSounds.EXPLOSION.play(world, location.x(), location.y(), location.z(), 7.0F, CalculationHelpers.randFloatRange(world().rand, -0.6F, 0.9F), true);
                }
                if (this.world().rand.nextFloat() > 0.85 && !this.world().isRemote) {
                    // Destroy self
                    clearBlast();
                }
            } else if (// TODO move to capability, also why isAlive checks?
            blast instanceof BlastRedmatter && ((BlastRedmatter) blast).isAlive && this.isAlive) {
                // https://www.wolframalpha.com/input/?i=(4%2F3)pi+*+r%5E3+%3D+(4%2F3)pi+*+a%5E3+%2B+(4%2F3)pi+*+b%5E3
                // We are going to merge both blasts together
                final double selfRad = Math.pow(this.getBlastRadius(), 3);
                final double targetRad = Math.pow(((EntityExplosion) entity).getBlast().getBlastRadius(), 3);
                // TODO why cube?
                final float newRad = (float) Math.cbrt(selfRad + targetRad);
                // Average out timer
                this.callCount = (callCount + ((BlastRedmatter) blast).callCount) / 2;
                this.size = newRad;
                // TODO combine the vectors
                this.controller.setVelocity(0, 0, 0);
            // TODO fire an event when combined (non-cancelable to allow acting on combined result)
            }
            // Kill the blast
            blast.clearBlast();
        } else if (// TODO move to capability
        entity instanceof EntityMissile) {
            // TODO should trigger the explosive capability
            ((EntityMissile) entity).doExplosion();
        } else if (// TODO move to capability
        entity instanceof EntityExplosive) {
            // TODO should trigger the explosive capability
            ((EntityExplosive) entity).explode();
        } else if (entity instanceof EntityLiving || entity instanceof EntityPlayer) {
            entity.attackEntityFrom(new DamageSourceRedmatter(this), 2000);
        } else {
            // Kill entity in the center of the ball
            entity.setDead();
            if (entity instanceof EntityFlyingBlock) {
                if (this.size < 120) {
                    this.size += 0.05;
                }
            }
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) IBlast(icbm.classic.api.explosion.IBlast) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityExplosion(icbm.classic.content.entity.EntityExplosion) EntityExplosive(icbm.classic.content.entity.EntityExplosive) BlastAntimatter(icbm.classic.content.blast.threaded.BlastAntimatter) EntityMissile(icbm.classic.content.entity.missile.EntityMissile)

Example 3 with BlastAntimatter

use of icbm.classic.content.blast.threaded.BlastAntimatter 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

BlastAntimatter (icbm.classic.content.blast.threaded.BlastAntimatter)3 EntityExplosion (icbm.classic.content.entity.EntityExplosion)2 IMissile (icbm.classic.api.caps.IMissile)1 IBlast (icbm.classic.api.explosion.IBlast)1 BlastAntiGravitational (icbm.classic.content.blast.BlastAntiGravitational)1 BlastBreach (icbm.classic.content.blast.BlastBreach)1 BlastEMP (icbm.classic.content.blast.BlastEMP)1 BlastEnderman (icbm.classic.content.blast.BlastEnderman)1 BlastEndothermic (icbm.classic.content.blast.BlastEndothermic)1 BlastExothermic (icbm.classic.content.blast.BlastExothermic)1 BlastFire (icbm.classic.content.blast.BlastFire)1 BlastGasBase (icbm.classic.content.blast.BlastGasBase)1 BlastRedmatter (icbm.classic.content.blast.BlastRedmatter)1 BlastShrapnel (icbm.classic.content.blast.BlastShrapnel)1 BlastSonic (icbm.classic.content.blast.BlastSonic)1 BlastTNT (icbm.classic.content.blast.BlastTNT)1 BlastNuclear (icbm.classic.content.blast.threaded.BlastNuclear)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 EntityMissile (icbm.classic.content.entity.missile.EntityMissile)1