Skip to content

Commit

Permalink
Implement difficulties for starvation damage (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuZhen86 authored and mastercoms committed Feb 4, 2018
1 parent a1d441e commit 8707480
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/main/java/net/glowstone/entity/GlowPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,35 @@ public void pulse() {
}
}

if (foodLevel == 0 && getHealth() > 1 && ticksLived % 80 == 0) {
damage(1, DamageCause.STARVATION);
// Process food level and starvation based on difficulty.
switch (world.getDifficulty()) {
case PEACEFUL: {
if (foodLevel < 20 && ticksLived % 20 == 0) {
foodLevel++;
}
break;
}
case EASY: {
if (foodLevel == 0 && getHealth() > 10 && ticksLived % 80 == 0) {
damage(1, DamageCause.STARVATION);
}
break;
}
case NORMAL: {
if (foodLevel == 0 && getHealth() > 1 && ticksLived % 80 == 0) {
damage(1, DamageCause.STARVATION);
}
break;
}
case HARD: {
if (foodLevel == 0 && ticksLived % 80 == 0) {
damage(1, DamageCause.STARVATION);
}
break;
}
default: {
// Do nothing when there are other game difficulties.
}
}

// stream world
Expand Down

0 comments on commit 8707480

Please sign in to comment.