Search in sources :

Example 1 with ThreadLargeExplosion

use of icbm.classic.content.explosive.thread.ThreadLargeExplosion in project ICBM-Classic by BuiltBrokenModding.

the class BlastRot method doPreExplode.

@Override
public void doPreExplode() {
    if (!this.world().isRemote) {
        this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.nengLiang, this.exploder);
        this.thread.start();
    }
}
Also used : ThreadLargeExplosion(icbm.classic.content.explosive.thread.ThreadLargeExplosion)

Example 2 with ThreadLargeExplosion

use of icbm.classic.content.explosive.thread.ThreadLargeExplosion in project ICBM-Classic by BuiltBrokenModding.

the class BlastSonic method doPreExplode.

@Override
public void doPreExplode() {
    if (!this.world().isRemote) {
        if (this.hasShockWave) {
            for (int x = (int) (-this.getRadius() * 2); x < this.getRadius() * 2; ++x) {
                for (int y = (int) (-this.getRadius() * 2); y < this.getRadius() * 2; ++y) {
                    for (int z = (int) (-this.getRadius() * 2); z < this.getRadius() * 2; ++z) {
                        Location targetPosition = position.add(new Pos(x, y, z));
                        Block blockID = world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                        if (blockID != Blocks.air) {
                            Material material = blockID.getMaterial();
                            if (blockID != Blocks.bedrock && !(material.isLiquid()) && (blockID.getExplosionResistance(this.exploder, world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi(), position.xi(), position.yi(), position.zi()) > this.nengLiang || material == Material.glass)) {
                                targetPosition.setBlock(world(), Blocks.air);
                            }
                        }
                    }
                }
            }
        }
        this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.nengLiang, this.exploder, new IThreadCallBack() {

            @Override
            public float getResistance(World world, IPos3D explosionPosition, IPos3D targetPosition, Entity source, Block block) {
                float resistance = 0;
                if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
                    resistance = 1f;
                } else {
                    resistance = block.getExplosionResistance(source, world, (int) targetPosition.x(), (int) targetPosition.y(), (int) targetPosition.z(), explosionPosition.x(), explosionPosition.y(), explosionPosition.z());
                }
                return resistance;
            }
        });
        this.thread.start();
    }
    if (this.hasShockWave) {
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "hypersonic", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
    } else {
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "sonicwave", 4.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IThreadCallBack(icbm.classic.content.explosive.thread.ThreadLargeExplosion.IThreadCallBack) Material(net.minecraft.block.material.Material) World(net.minecraft.world.World) ThreadLargeExplosion(icbm.classic.content.explosive.thread.ThreadLargeExplosion) IPos3D(com.builtbroken.jlib.data.vector.IPos3D) BlockLiquid(net.minecraft.block.BlockLiquid) Pos(com.builtbroken.mc.imp.transform.vector.Pos) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 3 with ThreadLargeExplosion

use of icbm.classic.content.explosive.thread.ThreadLargeExplosion in project ICBM-Classic by BuiltBrokenModding.

the class BlastNuclear method doPreExplode.

@Override
public void doPreExplode() {
    if (!this.world().isRemote) {
        this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.energy, this.exploder);
        this.thread.start();
    } else if (this.spawnMoreParticles && ICBMClassic.proxy.isGaoQing()) {
        // Spawn nuclear cloud.
        for (int y = 0; y < 26; y++) {
            int r = 4;
            if (y < 8) {
                r = Math.max(Math.min((8 - y) * 2, 10), 4);
            } else if (y > 15) {
                r = Math.max(Math.min((y - 15) * 2, 15), 5);
            }
            for (int x = -r; x < r; x++) {
                for (int z = -r; z < r; z++) {
                    double distance = MathHelper.sqrt_double(x * x + z * z);
                    if (r > distance && r - 3 < distance) {
                        Location spawnPosition = position.add(new Pos(x * 2, (y - 2) * 2, z * 2));
                        float xDiff = (float) (spawnPosition.x() - position.x());
                        float zDiff = (float) (spawnPosition.z() - position.z());
                        ICBMClassic.proxy.spawnParticle("smoke", world(), spawnPosition, xDiff * 0.3 * world().rand.nextFloat(), -world().rand.nextFloat(), zDiff * 0.3 * world().rand.nextFloat(), (float) (distance / this.getRadius()) * world().rand.nextFloat(), 0, 0, 8F, 1.2F);
                    }
                }
            }
        }
    }
    this.doDamageEntities(this.getRadius(), this.energy * 1000);
    this.world().playSoundEffect(this.position.x(), this.position.y(), this.position.z(), ICBMClassic.PREFIX + "explosion", 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
Also used : ThreadLargeExplosion(icbm.classic.content.explosive.thread.ThreadLargeExplosion) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Location(com.builtbroken.mc.imp.transform.vector.Location)

Aggregations

ThreadLargeExplosion (icbm.classic.content.explosive.thread.ThreadLargeExplosion)3 Location (com.builtbroken.mc.imp.transform.vector.Location)2 Pos (com.builtbroken.mc.imp.transform.vector.Pos)2 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)1 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 IThreadCallBack (icbm.classic.content.explosive.thread.ThreadLargeExplosion.IThreadCallBack)1 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 Material (net.minecraft.block.material.Material)1 Entity (net.minecraft.entity.Entity)1 World (net.minecraft.world.World)1 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)1