当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.shouldHeal方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.shouldHeal方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.shouldHeal方法的具体用法?Java EntityPlayer.shouldHeal怎么用?Java EntityPlayer.shouldHeal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.shouldHeal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:53,代码来源:FoodStats.java

示例2: onUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.world.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    boolean flag = player.world.getGameRules().getBoolean("naturalRegeneration");

    if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 10)
        {
            float f = Math.min(this.foodSaturationLevel, 6.0F);
            player.heal(f / 6.0F);
            this.addExhaustion(f);
            this.foodTimer = 0;
        }
    }
    else if (flag && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(6.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:67,代码来源:FoodStats.java

示例3: onUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    boolean flag = player.worldObj.getGameRules().getBoolean("naturalRegeneration");

    if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 10)
        {
            float f = Math.min(this.foodSaturationLevel, 4.0F);
            player.heal(f / 4.0F);
            this.addExhaustion(f);
            this.foodTimer = 0;
        }
    }
    else if (flag && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(4.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:67,代码来源:FoodStats.java


注:本文中的net.minecraft.entity.player.EntityPlayer.shouldHeal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。