Push next version of WMD
This commit is contained in:
parent
689485e337
commit
b8a065590c
10 changed files with 427 additions and 6 deletions
36
src/main/java/dev/zontreck/mcmods/Health.java
Normal file
36
src/main/java/dev/zontreck/mcmods/Health.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package dev.zontreck.mcmods;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class Health {
|
||||
|
||||
public float maximum;
|
||||
public float current;
|
||||
|
||||
public int asPercent()
|
||||
{
|
||||
return (int)Math.round(Math.abs((current * 100 / maximum)));
|
||||
}
|
||||
public Health lastHealthState;
|
||||
|
||||
|
||||
public static Health of(Player player){
|
||||
Health obj = new Health();
|
||||
obj.current = player.getHealth();
|
||||
obj.maximum = player.getMaxHealth();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public boolean shouldGiveAlert()
|
||||
{
|
||||
if(asPercent()<=50){
|
||||
return true;
|
||||
}else return false;
|
||||
}
|
||||
public boolean identical(Health other)
|
||||
{
|
||||
if(other.current == current && other.maximum == maximum)return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
Reference in a new issue