Advertisement
jayhillx

[X Life] HealthTextUtils

Mar 19th, 2022
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.02 KB | None | 0 0
  1. private static String value;
  2.  
  3.     private static String hearts(float health) {
  4.         char h = 10084;
  5.  
  6.         if (health >= 0.1F && health <= 2.0F) {
  7.             return value = "" + h;
  8.         } else if (health >= 2.1F && health <= 4.0F) {
  9.             return value = "" + h+h;
  10.         } else if (health >= 3.1F && health <= 6.0F) {
  11.             return value = "" + h+h+h;
  12.         } else if (health >= 6.1F && health <= 8.0F) {
  13.             return value = "" + h+h+h+h;
  14.         } else if (health >= 8.1F && health <= 10.0F) {
  15.             return value = "" + h+h+h+h+h;
  16.         } else if (health >= 10.1F && health <= 12.0F) {
  17.             return value = "" + h+h+h+h+h+h;
  18.         } else if (health >= 12.1F && health <= 14.0F) {
  19.             return value = "" + h+h+h+h+h+h+h;
  20.         } else if (health >= 14.1F && health <= 16.0F) {
  21.             return value = "" + h+h+h+h+h+h+h+h;
  22.         } else if (health >= 16.1F && health <= 18.0F) {
  23.             return value = "" + h+h+h+h+h+h+h+h+h;
  24.         } else if (health >= 18.1F && health <= 20.0F) {
  25.             return value = "" + h+h+h+h+h+h+h+h+h+h;
  26.         } else if (health == 0.0F) {
  27.             return "";
  28.         }
  29.         return value;
  30.     }
  31.  
  32.     public static String setDynamicHearts(float maxHealth, float lostHealth) {
  33.  
  34.         if (maxHealth == 2.0F) {
  35.             return GRAY + "(" + RED + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  36.         } else if (maxHealth == 4.0F) {
  37.             return GRAY + "(" + BLUE + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  38.         } else if (maxHealth == 6.0F) {
  39.             return GRAY + "(" + DARK_GREEN + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  40.         } else if (maxHealth == 8.0F) {
  41.             return GRAY + "(" + GOLD + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  42.         } else if (maxHealth == 10.0F) {
  43.             return GRAY + "(" + LIGHT_PURPLE + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  44.         } else if (maxHealth == 12.0F) {
  45.             return GRAY + "(" + DARK_PURPLE + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  46.         } else if (maxHealth == 14.0F) {
  47.             return GRAY + "(" + YELLOW + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  48.         } else if (maxHealth == 16.0F) {
  49.             return GRAY + "(" + DARK_AQUA + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  50.         } else if (maxHealth == 18.0F) {
  51.             return GRAY + "(" + GREEN + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  52.         } else if (maxHealth == 20.0F) {
  53.             return GRAY + "(" + BLACK + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  54.         } else {
  55.             return GRAY + "(" + RED + "" + hearts(maxHealth) + DARK_GRAY + "" + hearts(lostHealth - 1) + GRAY + ")";
  56.         }
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement