Java Code Examples for net.minecraft.init.Blocks.tnt()

The following are Jave code examples for showing how to use tnt() of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: BlockFire.java   View Source Code Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: BlockFire.java   View Source Code Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 3
Project: BaseClient   File: BlockFire.java   View Source Code Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 4
Project: BaseClient   File: BlockFire.java   View Source Code Vote up 5 votes
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
    int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());

    if (random.nextInt(chance) < i)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
        {
            int j = age + random.nextInt(5) / 4;

            if (j > 15)
            {
                j = 15;
            }

            worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
        }
        else
        {
            worldIn.setBlockToAir(pos);
        }

        if (iblockstate.getBlock() == Blocks.tnt)
        {
            Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
        }
    }
}
 
Example 5
Project: minecraft-quiverbow   File: SmallRocket.java   View Source Code Vote up 4 votes
@Override
public void onImpact(MovingObjectPosition target)	// Server-side
{
	if (target.entityHit != null) 	// Hit a entity
   	{
		// Damage
		target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float)this.damage);
		target.entityHit.hurtResistantTime = 0; // No immunity frames
		
		// Knockback
           double f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
           if (f3 > 0.0F) 
           {
           	target.entityHit.addVelocity(
       			this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3, 
       			0.1D, 
       			this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3
           	);
           }
           
		// Effect
		if ( !(target.entityHit instanceof EntityEnderman) ) { target.entityHit.setFire(this.fireDuration); } 
		
		this.setDead();	
		
	}
	else 	// Hit a block
	{ 
		Block block = this.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
		
		// Glass breaking, once
		if (Helper.tryBlockBreak(this.worldObj, this, target, 1) && this.targetsHit < 1) { this.targetsHit += 1; }
		else { this.setDead(); }	// else, either we didn't break that block or we already hit one entity
           
		// Let's ignite TNT explicitly here.
		if (block == Blocks.tnt)
		{
			this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ); // setBlockToAir
              
			EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(this.worldObj, 
               		(double)((float)target.blockX + 0.5F), 
               		(double)((float)target.blockY + 0.5F), 
               		(double)((float)target.blockZ + 0.5F), 
               		this.shootingEntity);									

               this.worldObj.spawnEntityInWorld(entitytntprimed);			// This is TNT, so begone with that block and replace it with primed TNT
               
               this.worldObj.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
		}
		// else, block is not TNT
	} 
	
	if (!this.isInWater()) // Only explode if we're not in water
	{																			
		boolean griefing = true;	// Allowed by default
		
		if (this.shootingEntity instanceof EntityPlayer)
		{
			griefing = this.dmgTerrain;	// It's up to player settings to allow/forbid this
		}
		else
		{
			griefing = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");	// Are we allowed to break things?
		}
		
		this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionSize, griefing); 	
		// 4.0F is TNT, false is for "not flaming"
		// Editchevsky: Actually, false is double-used for "don't damage terrain"
	}
}