Search in sources :

Example 1 with EntityLightBeam

use of icbm.classic.content.entity.EntityLightBeam in project ICBM-Classic by BuiltBrokenModding.

the class BlastBeam method doExplode.

@Override
protected boolean doExplode(int callCount) {
    if (!hasDoneSetup) {
        hasDoneSetup = true;
        // Play audio
        ICBMSounds.BEAM_CHARGING.play(world, location.x(), location.y(), location.z(), 4.0F, 0.8F, true);
        // Basic explosion
        // TODO remove basic in favor of thread
        this.world().createExplosion(this.exploder, location.x(), location.y(), location.z(), 4F, true);
        // Create beam
        this.lightBeam = new EntityLightBeam(this.world()).setPosition(location).setColor(this.red, this.green, this.blue);
        this.lightBeam.beamSize = 1;
        this.lightBeam.beamGlowSize = 2;
        this.lightBeam.setTargetBeamProgress(0.1f);
        this.world().spawnEntity(this.lightBeam);
    }
    // Start first thread if not already started
    if (!hasStartedFirstThread) {
        hasStartedFirstThread = true;
        this.lightBeam.setTargetBeamProgress(0.2f);
        WorkerThreadManager.INSTANCE.addWork(getFirstThread());
    }
    // When first thread is completed start floating blocks and ticking down to start second thread
    if (hasCompletedFirstThread && !hasStartedSecondThread) {
        // Spawn flying blocks
        if (!hasGeneratedFlyingBlocks) {
            hasGeneratedFlyingBlocks = true;
            this.lightBeam.setTargetBeamProgress(0.5f);
            // Edit blocks and queue spawning
            for (BlockPos blockPos : blocksToRemove) {
                // TODO filter what can turn into a flying block
                final IBlockState state = world.getBlockState(blockPos);
                // Remove block
                if (world.setBlockToAir(blockPos)) {
                    // Create an spawn
                    final EntityFlyingBlock entity = new EntityFlyingBlock(this.world(), blockPos, state);
                    entity.gravity = -0.01f;
                    if (world.spawnEntity(entity)) {
                        flyingBlocks.add(entity);
                    }
                }
            }
            blocksToRemove.clear();
        }
        // Delay second thread start
        if (secondThreadTimer-- <= 0) {
            this.lightBeam.setTargetBeamProgress(0.8f);
            hasStartedSecondThread = true;
            WorkerThreadManager.INSTANCE.addWork(getSecondThread());
        }
    }
    if (hasCompetedSecondThread) {
        this.lightBeam.setTargetBeamProgress(1f);
        if (!hasEnabledGravityForFlyingBlocks) {
            hasEnabledGravityForFlyingBlocks = true;
            flyingBlocks.forEach(entity -> entity.gravity = 0.5f);
        }
        if (!hasPlacedBlocks) {
            hasPlacedBlocks = true;
            mutateBlocks(blocksToRemove);
            blocksToRemove.clear();
        }
    }
    return hasPlacedBlocks;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) EntityLightBeam(icbm.classic.content.entity.EntityLightBeam) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with EntityLightBeam

use of icbm.classic.content.entity.EntityLightBeam in project ICBM-Classic by BuiltBrokenModding.

the class BlastBeam method doPreExplode.

/** Called before an explosion happens */
@Override
public void doPreExplode() {
    if (!this.world().isRemote) {
        this.world().createExplosion(this.exploder, position.x(), position.y(), position.z(), 4F, true);
        this.lightBeam = new EntityLightBeam(this.world(), position, 20 * 20, this.red, this.green, this.blue);
        this.world().spawnEntityInWorld(this.lightBeam);
        this.thread = new ThreadSky(this.position, (int) this.getRadius(), 50, this.exploder);
        this.thread.start();
    }
}
Also used : ThreadSky(icbm.classic.content.explosive.thread.ThreadSky) EntityLightBeam(icbm.classic.content.entity.EntityLightBeam)

Example 3 with EntityLightBeam

use of icbm.classic.content.entity.EntityLightBeam in project ICBM-Classic by BuiltBrokenModding.

the class RenderLightBeam method doRender.

@Override
public void doRender(Entity par1Entity, double x, double y, double z, float f, float f1) {
    if (this.renderManager == null) {
        this.setRenderManager(RenderManager.instance);
    }
    EntityLightBeam entity = ((EntityLightBeam) par1Entity);
    Tessellator tessellator = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(770, 1);
    // Previously
    double[] ad = new double[80];
    // both
    // were 8
    double[] ad1 = new double[80];
    double d3 = 0.0D;
    double d4 = 0.0D;
    for (int j = 7; j >= 0; j--) {
        ad[j] = d3;
        ad1[j] = d4;
    }
    for (int i = 0; i < 4; i++) {
        for (int ii = 0; ii < 3; ii++) {
            int l = 7;
            int i1 = 0;
            if (ii > 0) {
                l = 7 - ii;
            }
            if (ii > 0) {
                i1 = l - 2;
            }
            double d5 = ad[l] - d3;
            double d6 = ad1[l] - d4;
            for (int iii = l; iii >= i1; iii--) {
                double d7 = d5;
                double d8 = d6;
                // Weird but cool effects
                tessellator.startDrawing(5);
                float f2 = 0.5F;
                // Set color
                tessellator.setColorRGBA_F(entity.red, entity.green, entity.blue, 10F);
                double d9 = 0.10000000000000001D + i * 0.20000000000000001D;
                if (ii == 0) {
                    d9 *= iii * 0.10000000000000001D + 1.0D;
                }
                double d10 = 0.10000000000000001D + i * 0.20000000000000001D;
                if (ii == 0) {
                    d10 *= (iii - 1) * 0.10000000000000001D + 1.0D;
                }
                for (int iiii = 0; iiii < 5; iiii++) {
                    double d11 = (x + 0.5D) - d9;
                    double d12 = (z + 0.5D) - d9;
                    if (iiii == 1 || iiii == 2) {
                        d11 += d9 * 2D;
                    }
                    if (iiii == 2 || iiii == 3) {
                        d12 += d9 * 2D;
                    }
                    double d13 = (x + 0.5D) - d10;
                    double d14 = (z + 0.5D) - d10;
                    if (iiii == 1 || iiii == 2) {
                        d13 += d10 * 2D;
                    }
                    if (iiii == 2 || iiii == 3) {
                        d14 += d10 * 2D;
                    }
                    tessellator.addVertex(d13 + d5, y + iii * 16, d14 + d6);
                    tessellator.addVertex(d11 + d7, y + (iii + 1) * 16, d12 + d8);
                }
                tessellator.draw();
            }
        }
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) EntityLightBeam(icbm.classic.content.entity.EntityLightBeam)

Aggregations

EntityLightBeam (icbm.classic.content.entity.EntityLightBeam)3 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 ThreadSky (icbm.classic.content.explosive.thread.ThreadSky)1 IBlockState (net.minecraft.block.state.IBlockState)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 BlockPos (net.minecraft.util.math.BlockPos)1