forked from jzitnik/twodcraft
Added Burning state so player will be burning even after he is out of lava. Also added texture for fire that is added on top of steve texture
54 lines
1.1 KiB
Java
54 lines
1.1 KiB
Java
package cz.jzitnik.game.entities;
|
|
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
|
|
import java.io.Serializable;
|
|
|
|
@Getter
|
|
@Setter
|
|
public class Player implements Serializable {
|
|
private int health = 10;
|
|
private int hunger = 10;
|
|
private int fallDistance = 0;
|
|
private Block playerBlock1;
|
|
private Block playerBlock2;
|
|
private boolean burning = false;
|
|
private int burningTimeout;
|
|
private boolean burningState = false;
|
|
|
|
public synchronized void heal() {
|
|
if (hunger > 3 && health < 10) {
|
|
health = Math.min(health + 1, 10);
|
|
}
|
|
}
|
|
|
|
public synchronized void drainHunger() {
|
|
if (hunger > 0) {
|
|
hunger--;
|
|
}
|
|
}
|
|
|
|
public void addFalling() {
|
|
fallDistance++;
|
|
}
|
|
|
|
public void fell() {
|
|
int damage = Math.max(fallDistance - 3, 0);
|
|
dealDamage(damage);
|
|
fallDistance = 0;
|
|
}
|
|
|
|
public synchronized void dealDamage(int amount) {
|
|
health = Math.max(0, health - amount);
|
|
|
|
if (health == 0) {
|
|
// TODO: Implement dead
|
|
}
|
|
}
|
|
|
|
public synchronized void dealDamage() {
|
|
dealDamage(1);
|
|
}
|
|
}
|