当前位置: 首页>>代码示例>>Java>>正文


Java Block.onBlockDestroyedByExplosion方法代码示例

本文整理汇总了Java中net.minecraft.block.Block.onBlockDestroyedByExplosion方法的典型用法代码示例。如果您正苦于以下问题:Java Block.onBlockDestroyedByExplosion方法的具体用法?Java Block.onBlockDestroyedByExplosion怎么用?Java Block.onBlockDestroyedByExplosion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.block.Block的用法示例。


在下文中一共展示了Block.onBlockDestroyedByExplosion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的net.minecraft.block.Block.onBlockDestroyedByExplosion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。