當前位置: 首頁>>代碼示例>>Java>>正文


Java Block.dropBlockAsItemWithChance方法代碼示例

本文整理匯總了Java中net.minecraft.block.Block.dropBlockAsItemWithChance方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.dropBlockAsItemWithChance方法的具體用法?Java Block.dropBlockAsItemWithChance怎麽用?Java Block.dropBlockAsItemWithChance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.block.Block的用法示例。


在下文中一共展示了Block.dropBlockAsItemWithChance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doExplosionB

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Does the second part of the explosion (sound, particles, drop spawn)
 */
public void doExplosionB(boolean spawnParticles)
{
    this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

    if (this.explosionSize >= 2.0F && this.isSmoking)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }
    else
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }

    if (this.isSmoking)
    {
        for (BlockPos blockpos : this.affectedBlockPositions)
        {
            Block block = this.worldObj.getBlockState(blockpos).getBlock();

            if (spawnParticles)
            {
                double d0 = (double)((float)blockpos.getX() + this.worldObj.rand.nextFloat());
                double d1 = (double)((float)blockpos.getY() + this.worldObj.rand.nextFloat());
                double d2 = (double)((float)blockpos.getZ() + this.worldObj.rand.nextFloat());
                double d3 = d0 - this.explosionX;
                double d4 = d1 - this.explosionY;
                double d5 = d2 - this.explosionZ;
                double d6 = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                d3 = d3 / d6;
                d4 = d4 / d6;
                d5 = d5 / d6;
                double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D);
                d7 = d7 * (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                d3 = d3 * d7;
                d4 = d4 * d7;
                d5 = d5 * d7;
                this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5, new int[0]);
                this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
            }

            if (block.getMaterial() != Material.air)
            {
                if (block.canDropFromExplosion(this))
                {
                    block.dropBlockAsItemWithChance(this.worldObj, blockpos, this.worldObj.getBlockState(blockpos), 1.0F / this.explosionSize, 0);
                }

                this.worldObj.setBlockState(blockpos, Blocks.air.getDefaultState(), 3);
                block.onBlockDestroyedByExplosion(this.worldObj, blockpos, this);
            }
        }
    }

    if (this.isFlaming)
    {
        for (BlockPos blockpos1 : this.affectedBlockPositions)
        {
            if (this.worldObj.getBlockState(blockpos1).getBlock().getMaterial() == Material.air && this.worldObj.getBlockState(blockpos1.down()).getBlock().isFullBlock() && this.explosionRNG.nextInt(3) == 0)
            {
                this.worldObj.setBlockState(blockpos1, Blocks.fire.getDefaultState());
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:68,代碼來源:Explosion.java

示例2: doExplosionB

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Does the second part of the explosion (sound, particles, drop spawn)
 */
public void doExplosionB(boolean spawnParticles)
{
    this.worldObj.playSound((EntityPlayer)null, this.explosionX, this.explosionY, this.explosionZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

    if (this.explosionSize >= 2.0F && this.isSmoking)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }
    else
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }

    if (this.isSmoking)
    {
        for (BlockPos blockpos : this.affectedBlockPositions)
        {
            IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
            Block block = iblockstate.getBlock();

            if (spawnParticles)
            {
                double d0 = (double)((float)blockpos.getX() + this.worldObj.rand.nextFloat());
                double d1 = (double)((float)blockpos.getY() + this.worldObj.rand.nextFloat());
                double d2 = (double)((float)blockpos.getZ() + this.worldObj.rand.nextFloat());
                double d3 = d0 - this.explosionX;
                double d4 = d1 - this.explosionY;
                double d5 = d2 - this.explosionZ;
                double d6 = (double)MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
                d3 = d3 / d6;
                d4 = d4 / d6;
                d5 = d5 / d6;
                double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D);
                d7 = d7 * (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                d3 = d3 * d7;
                d4 = d4 * d7;
                d5 = d5 * d7;
                this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (d0 + this.explosionX) / 2.0D, (d1 + this.explosionY) / 2.0D, (d2 + this.explosionZ) / 2.0D, d3, d4, d5, new int[0]);
                this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
            }

            if (iblockstate.getMaterial() != Material.AIR)
            {
                if (block.canDropFromExplosion(this))
                {
                    block.dropBlockAsItemWithChance(this.worldObj, blockpos, this.worldObj.getBlockState(blockpos), 1.0F / this.explosionSize, 0);
                }

                this.worldObj.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 3);
                block.onBlockDestroyedByExplosion(this.worldObj, blockpos, this);
            }
        }
    }

    if (this.isFlaming)
    {
        for (BlockPos blockpos1 : this.affectedBlockPositions)
        {
            if (this.worldObj.getBlockState(blockpos1).getMaterial() == Material.AIR && this.worldObj.getBlockState(blockpos1.down()).isFullBlock() && this.explosionRNG.nextInt(3) == 0)
            {
                this.worldObj.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:69,代碼來源:Explosion.java

示例3: doExplosionB

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Does the second part of the explosion (sound, particles, drop spawn)
 */
@Override
public void doExplosionB(boolean spawnParticles) {
	this.world.playSound((EntityPlayer) null, this.explosionX, this.explosionY, this.explosionZ,
			SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, this.getExplosivePlacedBy() instanceof EntityPlayer ? 4.0F : 1.0F,
			(1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F);

	if (this.explosionSize >= 2.0F && this.isSmoking)
		this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY,
				this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
	else
		this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.explosionX, this.explosionY,
				this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);

	if (this.isSmoking && TF2ConfigVars.destTerrain == 2)
		for (BlockPos blockpos : this.affectedBlockPositions) {
			IBlockState iblockstate = this.world.getBlockState(blockpos);
			Block block = iblockstate.getBlock();

			if (spawnParticles) {
				double d0 = blockpos.getX() + this.world.rand.nextFloat();
				double d1 = blockpos.getY() + this.world.rand.nextFloat();
				double d2 = blockpos.getZ() + this.world.rand.nextFloat();
				double d3 = d0 - this.explosionX;
				double d4 = d1 - this.explosionY;
				double d5 = d2 - this.explosionZ;
				double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
				d3 = d3 / d6;
				d4 = d4 / d6;
				d5 = d5 / d6;
				double d7 = 0.5D / (d6 / this.explosionSize + 0.1D);
				d7 = d7 * (this.world.rand.nextFloat() * this.world.rand.nextFloat() + 0.3F);
				d3 = d3 * d7;
				d4 = d4 * d7;
				d5 = d5 * d7;
				this.world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (d0 + this.explosionX) / 2.0D,
						(d1 + this.explosionY) / 2.0D, (d2 + this.explosionZ) / 2.0D, d3, d4, d5, new int[0]);
				this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
			}

			if (iblockstate.getMaterial() != Material.AIR) {
				if (block.canDropFromExplosion(this))
					block.dropBlockAsItemWithChance(this.world, blockpos, this.world.getBlockState(blockpos),
							1.0F / this.explosionSize, 0);

				block.onBlockExploded(this.world, blockpos, this);
			}
		}

	if (this.isFlaming)
		for (BlockPos blockpos1 : this.affectedBlockPositions)
			if (this.world.getBlockState(blockpos1).getMaterial() == Material.AIR
					&& this.world.getBlockState(blockpos1.down()).isFullBlock()
					&& this.explosionRNG.nextInt(3) == 0)
				this.world.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:59,代碼來源:TF2Explosion.java

示例4: doExplosionB

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Does the second part of the explosion (sound, particles, drop spawn)
 */
public void doExplosionB(boolean spawnParticles)
{
    this.worldObj.playSound((EntityPlayer)null, this.explosionX, this.explosionY, this.explosionZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

    if (this.explosionSize >= 2.0F && this.isSmoking)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }
    else
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }

    if (this.isSmoking)
    {
        for (BlockPos blockpos : this.affectedBlockPositions)
        {
            IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
            Block block = iblockstate.getBlock();

            if (spawnParticles)
            {
                double d0 = (double)((float)blockpos.getX() + this.worldObj.rand.nextFloat());
                double d1 = (double)((float)blockpos.getY() + this.worldObj.rand.nextFloat());
                double d2 = (double)((float)blockpos.getZ() + this.worldObj.rand.nextFloat());
                double d3 = d0 - this.explosionX;
                double d4 = d1 - this.explosionY;
                double d5 = d2 - this.explosionZ;
                double d6 = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                d3 = d3 / d6;
                d4 = d4 / d6;
                d5 = d5 / d6;
                double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D);
                d7 = d7 * (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                d3 = d3 * d7;
                d4 = d4 * d7;
                d5 = d5 * d7;
                this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (d0 + this.explosionX) / 2.0D, (d1 + this.explosionY) / 2.0D, (d2 + this.explosionZ) / 2.0D, d3, d4, d5, new int[0]);
                this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
            }

            if (iblockstate.getMaterial() != Material.AIR)
            {
                if (block.canDropFromExplosion(this))
                {
                    block.dropBlockAsItemWithChance(this.worldObj, blockpos, this.worldObj.getBlockState(blockpos), 1.0F / this.explosionSize, 0);
                }

                block.onBlockExploded(this.worldObj, blockpos, this);
            }
        }
    }

    if (this.isFlaming)
    {
        for (BlockPos blockpos1 : this.affectedBlockPositions)
        {
            if (this.worldObj.getBlockState(blockpos1).getMaterial() == Material.AIR && this.worldObj.getBlockState(blockpos1.down()).isFullBlock() && this.explosionRNG.nextInt(3) == 0)
            {
                this.worldObj.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:68,代碼來源:Explosion.java


注:本文中的net.minecraft.block.Block.dropBlockAsItemWithChance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。