Handles the food game logic.
(EntityPlayer player)
| 39 | * Handles the food game logic. |
| 40 | */ |
| 41 | public void onUpdate(EntityPlayer player) |
| 42 | { |
| 43 | EnumDifficulty enumdifficulty = player.worldObj.getDifficulty(); |
| 44 | this.prevFoodLevel = this.foodLevel; |
| 45 | |
| 46 | if (this.foodExhaustionLevel > 4.0F) |
| 47 | { |
| 48 | this.foodExhaustionLevel -= 4.0F; |
| 49 | |
| 50 | if (this.foodSaturationLevel > 0.0F) |
| 51 | { |
| 52 | this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); |
| 53 | } |
| 54 | else if (enumdifficulty != EnumDifficulty.PEACEFUL) |
| 55 | { |
| 56 | this.foodLevel = Math.max(this.foodLevel - 1, 0); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (player.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal()) |
| 61 | { |
| 62 | ++this.foodTimer; |
| 63 | |
| 64 | if (this.foodTimer >= 80) |
| 65 | { |
| 66 | player.heal(1.0F); |
| 67 | this.addExhaustion(3.0F); |
| 68 | this.foodTimer = 0; |
| 69 | } |
| 70 | } |
| 71 | else if (this.foodLevel <= 0) |
| 72 | { |
| 73 | ++this.foodTimer; |
| 74 | |
| 75 | if (this.foodTimer >= 80) |
| 76 | { |
| 77 | if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) |
| 78 | { |
| 79 | player.attackEntityFrom(DamageSource.starve, 1.0F); |
| 80 | } |
| 81 | |
| 82 | this.foodTimer = 0; |
| 83 | } |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | this.foodTimer = 0; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Reads the food data for the player. |
nothing calls this directly
no test coverage detected