Advertisement
jayhillx

HeartColors.class 2.0

Oct 21st, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. import com.meepshadow.xlifehealth.XLifeHealth;
  2. import net.minecraft.client.MainWindow;
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.util.ResourceLocation;
  5. import net.minecraftforge.client.event.RenderGameOverlayEvent;
  6. import net.minecraftforge.eventbus.api.SubscribeEvent;
  7. import net.minecraftforge.fml.client.gui.GuiUtils;
  8.  
  9. import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.HEALTH;
  10.  
  11. public class HeartColors extends GuiUtils {
  12.  
  13. public static final ResourceLocation BLUE_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/blue_hearts.png");
  14. public static final ResourceLocation GREEN_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/green_hearts.png");
  15. public static final ResourceLocation ORANGE_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/orange_hearts.png");
  16. public static final ResourceLocation PINK_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/pink_hearts.png");
  17. public static final ResourceLocation PURPLE_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/purple_hearts.png");
  18. public static final ResourceLocation YELLOW_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/yellow_hearts.png");
  19. public static final ResourceLocation CYAN_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/cyan_hearts.png");
  20. public static final ResourceLocation MAGENTA_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/magenta_hearts.png");
  21. public static final ResourceLocation BLACK_HEARTS = new ResourceLocation(XLifeHealth.MOD_ID, "textures/gui/black_hearts.png");
  22. private final int tex_width = 7, tex_height = 7;
  23.  
  24. @SubscribeEvent
  25. public void setHeartColors(RenderGameOverlayEvent.Pre event) {
  26. if (event.getType() == HEALTH)
  27. setBlueHearts(event);
  28. setGreenHearts(event);
  29. setOrangeHearts(event);
  30. setPinkHearts(event);
  31. setPurpleHearts(event);
  32. setYellowHearts(event);
  33. setCyanHearts(event);
  34. setMagentaHearts(event);
  35. setBlackHearts(event);
  36. }
  37.  
  38. public void setBlueHearts(RenderGameOverlayEvent event) {
  39. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  40. Minecraft mc = Minecraft.getInstance();
  41. mc.getTextureManager().bindTexture(BLUE_HEARTS);
  42. bind(BLUE_HEARTS);
  43. }
  44. }
  45. public void setGreenHearts(RenderGameOverlayEvent event) {
  46. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  47. Minecraft mc = Minecraft.getInstance();
  48. mc.getTextureManager().bindTexture(GREEN_HEARTS);
  49. bind(GREEN_HEARTS);
  50. }
  51. }
  52. public void setOrangeHearts(RenderGameOverlayEvent event) {
  53. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  54. Minecraft mc = Minecraft.getInstance();
  55. mc.getTextureManager().bindTexture(ORANGE_HEARTS);
  56. bind(ORANGE_HEARTS);
  57. }
  58. }
  59. public void setPinkHearts(RenderGameOverlayEvent event) {
  60. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  61. Minecraft mc = Minecraft.getInstance();
  62. mc.getTextureManager().bindTexture(PINK_HEARTS);
  63. bind(PINK_HEARTS);
  64. }
  65. }
  66. public void setPurpleHearts(RenderGameOverlayEvent event) {
  67. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  68. Minecraft mc = Minecraft.getInstance();
  69. mc.getTextureManager().bindTexture(PURPLE_HEARTS);
  70. bind(PURPLE_HEARTS);
  71. }
  72. }
  73. public void setYellowHearts(RenderGameOverlayEvent event) {
  74. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  75. Minecraft mc = Minecraft.getInstance();
  76. mc.getTextureManager().bindTexture(YELLOW_HEARTS);
  77. bind(YELLOW_HEARTS);
  78. }
  79. }
  80. public void setCyanHearts(RenderGameOverlayEvent event) {
  81. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  82. Minecraft mc = Minecraft.getInstance();
  83. mc.getTextureManager().bindTexture(CYAN_HEARTS);
  84. bind(CYAN_HEARTS);
  85. }
  86. }
  87. public void setMagentaHearts(RenderGameOverlayEvent event) {
  88. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  89. Minecraft mc = Minecraft.getInstance();
  90. mc.getTextureManager().bindTexture(MAGENTA_HEARTS);
  91. bind(MAGENTA_HEARTS);
  92. }
  93. }
  94. public void setBlackHearts(RenderGameOverlayEvent event) {
  95. if (event.getType() == RenderGameOverlayEvent.ElementType.HEALTH) {
  96. Minecraft mc = Minecraft.getInstance();
  97. mc.getTextureManager().bindTexture(BLACK_HEARTS);
  98. bind(BLACK_HEARTS);
  99. }
  100. }
  101.  
  102. private void bind(ResourceLocation res) {
  103. Minecraft mc = Minecraft.getInstance();
  104. mc.getTextureManager().bindTexture(res);
  105. }
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement