日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > java >内容正文

java

JAVA刷TNT_Java Blocks.tnt方法代码示例

發(fā)布時(shí)間:2024/10/8 java 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JAVA刷TNT_Java Blocks.tnt方法代码示例 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

import net.minecraft.init.Blocks; //導(dǎo)入方法依賴的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"

}

}

總結(jié)

以上是生活随笔為你收集整理的JAVA刷TNT_Java Blocks.tnt方法代码示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。