Search in sources :

Example 1 with ExExothermic

use of icbm.classic.content.explosive.ex.ExExothermic in project ICBM-Classic by BuiltBrokenModding.

the class BlastExothermic method doPostExplode.

@Override
public void doPostExplode() {
    super.doPostExplode();
    if (!this.world().isRemote) {
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "powerdown", 4.0F, 0.8F);
        if (this.canFocusBeam(this.world(), position) && this.thread.isComplete) {
            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) {
                    /*
                         * Check to see if the block is an air block and there is a block below it
                         * to support the fire.
                         */
                    Block blockID = this.world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                    if (blockID.getMaterial() == Material.water || blockID == Blocks.ice) {
                        this.world().setBlockToAir(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                    }
                    if (blockID.blockMaterial == Material.rock && this.world().rand.nextFloat() > 0.8) {
                        this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.flowing_lava, 0, 2);
                    }
                    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 (this.world().rand.nextFloat() > 0.99) {
                            this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.flowing_lava, 0, 2);
                        } else {
                            this.world().setBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), Blocks.fire, 0, 2);
                            blockID = this.world().getBlock(targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi());
                            if (((ExExothermic) Explosives.EXOTHERMIC.handler).createNetherrack && (blockID == Blocks.stone || blockID == Blocks.grass || blockID == Blocks.dirt) && this.world().rand.nextFloat() > 0.75) {
                                this.world().setBlock(targetPosition.xi(), targetPosition.yi() - 1, targetPosition.zi(), Blocks.netherrack, 0, 2);
                            }
                        }
                    }
                }
            }
            this.world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "explosionfire", 6.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
        }
        if (!world().getGameRules().getGameRuleBooleanValue("doDaylightCycle")) {
            this.world().setWorldTime(18000);
        }
    }
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) Block(net.minecraft.block.Block) ExExothermic(icbm.classic.content.explosive.ex.ExExothermic)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 ExExothermic (icbm.classic.content.explosive.ex.ExExothermic)1 Block (net.minecraft.block.Block)1