move the damn elements

This commit is contained in:
Ranzu committed 2026-11-02 21:02:28 +01:00
1 parent 5bec959166
commit ad926cf86f
3 files changed
+58 -14

No files matched your search

@@ -27,6 +27,7 @@ import vazkii.botania.api.internal.ShaderCallback;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.MathHelper;
public final class BossBarHandler {
@@ -64,15 +65,19 @@ public final class BossBarHandler {
int fw = (int) ((double) fgRect.width * (currentBoss.getHealth() / currentBoss.getMaxHealth()));
int tx = c - mc.fontRenderer.getStringWidth(name) / 2;
GL11.glColor4f(1F, 1F, 1F, 1F);
currentBoss.bossBarRenderCallback(res, x, y);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(currentBoss.getBossBarTexture());
drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true);
drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false);
mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C);
GL11.glEnable(GL11.GL_BLEND);
if(!Botania.dashboardLoaded || DashboardHud.beginBossBar(res)) {
GL11.glColor4f(1F, 1F, 1F, 1F);
currentBoss.bossBarRenderCallback(res, x, y);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(currentBoss.getBossBarTexture());
drawBar(x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true);
drawBar(xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false);
mc.fontRenderer.drawStringWithShadow(name, tx, y - 10, 0xA2018C);
GL11.glEnable(GL11.GL_BLEND);
if(Botania.dashboardLoaded)
DashboardHud.endRender();
}
EntityPlayer p = mc.thePlayer;
if(e.isDead || !p.worldObj.loadedEntityList.contains(e) || MathHelper.pointDistanceSpace(e.posX, e.posY, e.posZ, p.posX, p.posY, p.posZ) > 32)
@@ -4,6 +4,7 @@ import java.util.function.Consumer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -71,13 +72,36 @@ public final class DashboardHud {
setSample(FLIGHT_BAR, DashboardHud::drawFlightBarSample);
setSample(BOSS_BAR, DashboardHud::drawBossBarSample);
setSample(WAND_MODE, DashboardHud::drawWandModeSample);
setSample(CORPOREA_HINT, bounds -> HUDHandler.renderNearIndexDisplay(HudRegistry.getResolution()));
// Botania's own drawing, which moves itself
CORPOREA_HINT.setPreview((screenWidth, screenHeight) -> HUDHandler.renderNearIndexDisplay(HudRegistry.getResolution()));
setSample(CROSSHAIR_INFO, bounds -> drawCrosshairInfoSample());
for(HudElement element : new HudElement[] { MANA_BAR, FLIGHT_BAR, BOSS_BAR, WAND_MODE, CORPOREA_HINT, CROSSHAIR_INFO })
HudRegistry.register(element);
}
// False means the player hid the element, so skip drawing it and do not call endRender()
public static boolean beginManaBar(ScaledResolution resolution) {
return HudRegistry.beginRender(MANA_BAR, resolution);
}
public static boolean beginBossBar(ScaledResolution resolution) {
return HudRegistry.beginRender(BOSS_BAR, resolution);
}
public static boolean beginWandMode(ScaledResolution resolution) {
return HudRegistry.beginRender(WAND_MODE, resolution);
}
public static boolean beginCorporeaHint(ScaledResolution resolution) {
return HudRegistry.beginRender(CORPOREA_HINT, resolution);
}
public static void endRender() {
HudRegistry.endRender();
}
/** Drawn at the element's default place, and moved like the real one. */
private static void setSample(HudElement element, Consumer<HudBounds> draw) {
element.setPreview((screenWidth, screenHeight) ->
@@ -51,6 +51,7 @@ import vazkii.botania.api.wiki.IWikiProvider;
import vazkii.botania.api.wiki.WikiHooks;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileAltar;
import vazkii.botania.common.block.tile.TileRuneAltar;
@@ -236,10 +237,14 @@ public final class HUDHandler {
int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(disp) / 2;
int y = res.getScaledHeight() - 70;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.fontRenderer.drawStringWithShadow(disp, x, y, color);
GL11.glDisable(GL11.GL_BLEND);
if(!Botania.dashboardLoaded || DashboardHud.beginWandMode(res)) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.fontRenderer.drawStringWithShadow(disp, x, y, color);
GL11.glDisable(GL11.GL_BLEND);
if(Botania.dashboardLoaded)
DashboardHud.endRender();
}
}
profiler.endSection();
}
@@ -262,6 +267,9 @@ public final class HUDHandler {
else return;
}
if(Botania.dashboardLoaded && !DashboardHud.beginManaBar(res))
return;
int rgb = Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F);
GL11.glColor4ub((byte) (rgb >> 16), (byte) (rgb >> 8), (byte) rgb, (byte) (255 - (rgb >> 16)));
mc.renderEngine.bindTexture(manaBar);
@@ -270,6 +278,8 @@ public final class HUDHandler {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5);
GL11.glDisable(GL11.GL_BLEND);
if(Botania.dashboardLoaded)
DashboardHud.endRender();
}
private void renderPoolRecipeHUD(ScaledResolution res, TilePool tile, ItemStack stack) {
@@ -402,6 +412,9 @@ public final class HUDHandler {
}
static void renderNearIndexDisplay(ScaledResolution res) {
if(Botania.dashboardLoaded && !DashboardHud.beginCorporeaHint(res))
return;
Minecraft mc = Minecraft.getMinecraft();
String txt0 = StatCollector.translateToLocal("botaniamisc.nearIndex0");
String txt1 = EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.nearIndex1");
@@ -421,6 +434,8 @@ public final class HUDHandler {
mc.fontRenderer.drawStringWithShadow(txt0, x + 20, y, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(txt1, x + 20, y + 14, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(txt2, x + 20, y + 24, 0xFFFFFF);
if(Botania.dashboardLoaded)
DashboardHud.endRender();
}
public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {