本文整理汇总了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());
}
}
}
}
示例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());
}
}
}
}