本文整理汇总了Java中net.minecraft.init.Blocks.tnt方法的典型用法代码示例。如果您正苦于以下问题:Java Blocks.tnt方法的具体用法?Java Blocks.tnt怎么用?Java Blocks.tnt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.init.Blocks
的用法示例。
在下文中一共展示了Blocks.tnt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: catchOnFire
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
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)));
}
}
}
示例2: onImpact
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
@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"
}
}