當前位置: 首頁>>代碼示例>>Java>>正文


Java Entity.onStruckByLightning方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:55,代碼來源:EntityLightningBolt.java

示例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);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:59,代碼來源:EntityLightningBolt.java

示例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);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:60,代碼來源:EntityLightningBolt.java


注:本文中的net.minecraft.entity.Entity.onStruckByLightning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。