Search in sources :

Example 1 with CustomPotionEffect

use of icbm.classic.content.potion.CustomPotionEffect in project ICBM-Classic by BuiltBrokenModding.

the class BlastChemical method doExplode.

@Override
public void doExplode() {
    float radius = this.getRadius();
    if (this.world().isRemote) {
        for (int i = 0; i < 200; i++) {
            Pos diDian = new Pos(Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4);
            diDian = diDian.multiply(Math.min(radius, callCount) / 10);
            if (diDian.magnitude() <= radius) {
                diDian = diDian.add(this.position);
                ICBMClassic.proxy.spawnParticle("smoke", this.world(), diDian, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, this.red, this.green, this.blue, 7.0F, 8);
            }
        }
    }
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
    List<EntityLivingBase> allEntities = world().getEntitiesWithinAABB(EntityLivingBase.class, bounds);
    for (EntityLivingBase entity : allEntities) {
        if (this.isContagious) {
            ICBMClassic.contagios_potion.poisonEntity(position.toPos(), entity);
        }
        if (this.isPoisonous) {
            ICBMClassic.poisonous_potion.poisonEntity(position.toPos(), entity);
        }
        if (this.isConfuse) {
            entity.addPotionEffect(new CustomPotionEffect(Potion.confusion.id, 18 * 20, 0));
            entity.addPotionEffect(new CustomPotionEffect(Potion.digSlowdown.id, 20 * 60, 0));
            entity.addPotionEffect(new CustomPotionEffect(Potion.moveSlowdown.id, 20 * 60, 2));
        }
    }
    if (this.isMutate) {
        new BlastMutation(world(), this.exploder, position.x(), position.y(), position.z(), this.getRadius()).explode();
    }
    if (this.playShortSoundFX) {
        world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "gasleak", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
    }
    if (this.callCount > this.duration) {
        this.controller.endExplosion();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityLivingBase(net.minecraft.entity.EntityLivingBase) CustomPotionEffect(icbm.classic.content.potion.CustomPotionEffect)

Example 2 with CustomPotionEffect

use of icbm.classic.content.potion.CustomPotionEffect in project ICBM-Classic by BuiltBrokenModding.

the class BlastEndothermic method doPostExplode.

@Override
public void doPostExplode() {
    super.doPostExplode();
    if (!this.world().isRemote) {
        if (this.canFocusBeam(this.world(), position) && this.thread.isComplete) {
            /*
                 * Freeze all nearby entities.
                 */
            List<EntityLiving> livingEntities = world().getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(position.x() - getRadius(), position.y() - getRadius(), position.z() - getRadius(), position.x() + getRadius(), position.y() + getRadius(), position.z() + getRadius()));
            if (livingEntities != null && !livingEntities.isEmpty()) {
                Iterator<EntityLiving> it = livingEntities.iterator();
                while (it.hasNext()) {
                    EntityLiving entity = it.next();
                    if (entity != null && entity.isEntityAlive()) {
                        entity.addPotionEffect(new CustomPotionEffect(PoisonFrostBite.INSTANCE.getId(), 60 * 20, 1, null));
                        entity.addPotionEffect(new PotionEffect(Potion.confusion.id, 10 * 20, 2));
                        entity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 120 * 20, 2));
                        entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 120 * 20, 4));
                    }
                }
            }
            for (Pos targetPosition : this.thread.results) {
                double distanceFromCenter = position.distance(targetPosition);
                if (distanceFromCenter > this.getRadius()) {
                    continue;
                }
                /*
                     * Reduce the chance of setting blocks on fire based on distance from center.
                     */
                double chance = this.getRadius() - (Math.random() * distanceFromCenter);
                if (chance > distanceFromCenter * 0.55) {
                    /*
                         * Place down ice blocks.
                         */
                    Block blockID = this.world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                    if (blockID.blockMaterial == Material.water) {
                        this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.ice, 0, 3);
                    } else if (blockID == Blocks.fire || blockID == Blocks.flowing_lava || blockID == Blocks.lava) {
                        this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.snow, 0, 3);
                    } else {
                        Block blockBellow = world().getBlock(targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi());
                        if ((blockID.isReplaceable(world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi())) && blockBellow.getMaterial().isSolid() && blockBellow.isSideSolid(world(), targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi(), ForgeDirection.UP)) {
                            if (MathUtility.rand.nextBoolean()) {
                                this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.ice, 0, 3);
                            } else {
                                this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.snow, 0, 3);
                            }
                        }
                    }
                }
            }
            this.world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "redmatter", 6.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
        }
        if (!world().getGameRules().getGameRuleBooleanValue("doDaylightCycle")) {
            this.world().setWorldTime(1200);
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) CustomPotionEffect(icbm.classic.content.potion.CustomPotionEffect) PotionEffect(net.minecraft.potion.PotionEffect) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Block(net.minecraft.block.Block) CustomPotionEffect(icbm.classic.content.potion.CustomPotionEffect)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)2 CustomPotionEffect (icbm.classic.content.potion.CustomPotionEffect)2 Block (net.minecraft.block.Block)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 PotionEffect (net.minecraft.potion.PotionEffect)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1