本文整理汇总了Java中net.minecraft.entity.Entity.onStruckByLightning方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.onStruckByLightning方法的具体用法?Java Entity.onStruckByLightning怎么用?Java Entity.onStruckByLightning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.Entity
的用法示例。
在下文中一共展示了Entity.onStruckByLightning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.lightningState == 2)
{
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 2.0F, 0.5F + this.rand.nextFloat() * 0.2F);
}
--this.lightningState;
if (this.lightningState < 0)
{
if (this.boltLivingTime == 0)
{
this.setDead();
}
else if (this.lightningState < -this.rand.nextInt(10))
{
--this.boltLivingTime;
this.lightningState = 1;
this.boltVertex = this.rand.nextLong();
BlockPos blockpos = new BlockPos(this);
if (!this.worldObj.isRemote && this.worldObj.getGameRules().getBoolean("doFireTick") && this.worldObj.isAreaLoaded(blockpos, 10) && this.worldObj.getBlockState(blockpos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this.worldObj, blockpos))
{
this.worldObj.setBlockState(blockpos, Blocks.fire.getDefaultState());
}
}
}
if (this.lightningState >= 0)
{
if (this.worldObj.isRemote)
{
this.worldObj.setLastLightningBolt(2);
}
else
{
double d0 = 3.0D;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
entity.onStruckByLightning(this);
}
}
}
}
示例2: onUpdate
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.lightningState == 2)
{
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.rand.nextFloat() * 0.2F);
}
--this.lightningState;
if (this.lightningState < 0)
{
if (this.boltLivingTime == 0)
{
this.setDead();
}
else if (this.lightningState < -this.rand.nextInt(10))
{
--this.boltLivingTime;
this.lightningState = 1;
if (!this.effectOnly && !this.world.isRemote)
{
this.boltVertex = this.rand.nextLong();
BlockPos blockpos = new BlockPos(this);
if (this.world.getGameRules().getBoolean("doFireTick") && this.world.isAreaLoaded(blockpos, 10) && this.world.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(this.world, blockpos))
{
this.world.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
}
}
}
}
if (this.lightningState >= 0)
{
if (this.world.isRemote)
{
this.world.setLastLightningBolt(2);
}
else if (!this.effectOnly)
{
double d0 = 3.0D;
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(this.posX - 3.0D, this.posY - 3.0D, this.posZ - 3.0D, this.posX + 3.0D, this.posY + 6.0D + 3.0D, this.posZ + 3.0D));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
entity.onStruckByLightning(this);
}
}
}
}
示例3: onUpdate
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.lightningState == 2)
{
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.rand.nextFloat() * 0.2F);
}
--this.lightningState;
if (this.lightningState < 0)
{
if (this.boltLivingTime == 0)
{
this.setDead();
}
else if (this.lightningState < -this.rand.nextInt(10))
{
--this.boltLivingTime;
this.lightningState = 1;
if (!this.effectOnly && !this.worldObj.isRemote)
{
this.boltVertex = this.rand.nextLong();
BlockPos blockpos = new BlockPos(this);
if (this.worldObj.getGameRules().getBoolean("doFireTick") && this.worldObj.isAreaLoaded(blockpos, 10) && this.worldObj.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(this.worldObj, blockpos))
{
this.worldObj.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
}
}
}
}
if (this.lightningState >= 0)
{
if (this.worldObj.isRemote)
{
this.worldObj.setLastLightningBolt(2);
}
else if (!this.effectOnly)
{
double d0 = 3.0D;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(this.posX - 3.0D, this.posY - 3.0D, this.posZ - 3.0D, this.posX + 3.0D, this.posY + 6.0D + 3.0D, this.posZ + 3.0D));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this))
entity.onStruckByLightning(this);
}
}
}
}