|
| 1 | +package com.ryorama.terrariamod.client.ui; |
| 2 | + |
| 3 | +import com.ryorama.terrariamod.TerrariaMod; |
| 4 | +import com.ryorama.terrariamod.stats.StatsT; |
| 5 | +import net.minecraft.client.Minecraft; |
| 6 | +import net.minecraft.client.player.LocalPlayer; |
| 7 | +import net.minecraft.resources.ResourceLocation; |
| 8 | +import net.minecraft.stats.Stats; |
| 9 | + |
| 10 | +public class TerrariaUI { |
| 11 | + public static ResourceLocation health_icon = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/heart.png"); |
| 12 | + public static ResourceLocation shield = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/shield.png"); |
| 13 | + public static ResourceLocation mana = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/mana.png"); |
| 14 | + |
| 15 | + //Buffs |
| 16 | + public static ResourceLocation iron_skin = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/ironskin.png"); |
| 17 | + public static ResourceLocation happy = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/happy.png"); |
| 18 | + public static ResourceLocation cozy_fire = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/cozy_fire.png"); |
| 19 | + public static ResourceLocation regeneration = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/regeneration.png"); |
| 20 | + |
| 21 | + //DeBuffs |
| 22 | + public static ResourceLocation potion_sickness = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/potion_sickness.png"); |
| 23 | + public static ResourceLocation poisoned = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/poisoned.png"); |
| 24 | + |
| 25 | + public static ResourceLocation bleeding = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/bleeding.png"); |
| 26 | + public static ResourceLocation water_candle = new ResourceLocation(TerrariaMod.MOD_ID, "textures/ui/buffs/water_candle.png"); |
| 27 | + |
| 28 | + public static LocalPlayer player; |
| 29 | + |
| 30 | + public static void renderTerrariaHealth() { |
| 31 | + if (!TerrariaMod.CONFIG.useVanillaHud) { |
| 32 | + float scaledWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth(); |
| 33 | + |
| 34 | + if (Minecraft.getInstance().player != null) { |
| 35 | + player = Minecraft.getInstance().player; |
| 36 | + } |
| 37 | + |
| 38 | + if (player != null) { |
| 39 | + for (int h = 0; h < player.getHealth() + 20; h++) { |
| 40 | + if (h % 20 == 0) { |
| 41 | + if (h < 200) { |
| 42 | + UIRenderer.renderOverlay(health_icon, 50, 8, 8, scaledWidth - 125 + h / 2, 10, -90); |
| 43 | + } else if (h > 200) { |
| 44 | + UIRenderer.renderOverlay(health_icon, 50, 8, 8, scaledWidth - 125 + h / 2 - 110, 20, -90); |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + public static void renderTerrariaDefense() { |
| 53 | + float scaledWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth(); |
| 54 | + |
| 55 | + if (Minecraft.getInstance().player != null) { |
| 56 | + player = Minecraft.getInstance().player; |
| 57 | + } |
| 58 | + |
| 59 | + if (player != null) { |
| 60 | + UIRenderer.renderOverlay(shield, 50, 16, 16, scaledWidth - 100 / 2 - 70, 220, -90); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + public static void renderTerrariaMana() { |
| 65 | + if (!TerrariaMod.CONFIG.useVanillaHud) { |
| 66 | + float scaledWidth = Minecraft.getInstance().getWindow().getGuiScaledWidth(); |
| 67 | + |
| 68 | + if (Minecraft.getInstance().player != null) { |
| 69 | + player = Minecraft.getInstance().player; |
| 70 | + } |
| 71 | + |
| 72 | + if (player != null) { |
| 73 | + for (int i = 0; i <= player.getStats().getValue(Stats.CUSTOM.get(StatsT.MANA)) - 20; i++) { |
| 74 | + if (i % 20 == 0) { |
| 75 | + UIRenderer.renderOverlay(mana, 50, 10, 10, scaledWidth - 18, 10 + i / 2, -90); |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + public static void renderTerrariaEffects() { |
| 83 | + if (TerrariaMod.CONFIG.showTerrariaBuffs) { |
| 84 | + if (Minecraft.getInstance().player != null) { |
| 85 | + player = Minecraft.getInstance().player; |
| 86 | + } |
| 87 | + |
| 88 | + int i3 = 17; |
| 89 | + int j3 = 27; |
| 90 | + int effectCounter = 0; |
| 91 | + |
| 92 | + if (player != null) { |
| 93 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.POTION_SICKNESS)) > 0) { |
| 94 | + UIRenderer.renderOverlay(potion_sickness, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 95 | + effectCounter++; |
| 96 | + } |
| 97 | + |
| 98 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.POISONED)) > 0) { |
| 99 | + UIRenderer.renderOverlay(poisoned, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 100 | + effectCounter++; |
| 101 | + } |
| 102 | + |
| 103 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.IRON_SKIN)) > 0) { |
| 104 | + UIRenderer.renderOverlay(iron_skin, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 105 | + effectCounter++; |
| 106 | + } |
| 107 | + |
| 108 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.HAPPY)) > 0) { |
| 109 | + UIRenderer.renderOverlay(happy, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 110 | + effectCounter++; |
| 111 | + } |
| 112 | + |
| 113 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.COZY_FIRE)) > 0) { |
| 114 | + UIRenderer.renderOverlay(cozy_fire, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 115 | + effectCounter++; |
| 116 | + } |
| 117 | + |
| 118 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.REGENERATION)) > 0) { |
| 119 | + UIRenderer.renderOverlay(regeneration, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 120 | + effectCounter++; |
| 121 | + } |
| 122 | + |
| 123 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.BLEEDING)) > 0) { |
| 124 | + UIRenderer.renderOverlay(bleeding, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 125 | + effectCounter++; |
| 126 | + } |
| 127 | + if (player.getStats().getValue(Stats.CUSTOM.get(StatsT.WATER_CANDLE)) > 0) { |
| 128 | + UIRenderer.renderOverlay(water_candle, 50, 16, 16, i3 + effectCounter * 20f, j3, -90); |
| 129 | + effectCounter++; |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | +} |
0 commit comments