From f3c9db1267f7e321318280e0747af05554b7d0dd Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Wed, 5 Feb 2014 15:19:47 +0000 Subject: [PATCH] Rework of the mana display HUD. --- .../client/core/handler/HUDHandler.java | 52 ++++++++++++------ .../client/core/helper/RenderHelper.java | 12 ++++ .../botania/client/lib/LibResources.java | 1 + .../block/subtile/SubTileGenerating.java | 2 +- .../botania/common/block/tile/TilePool.java | 2 +- .../common/block/tile/TileSpreader.java | 4 +- resources/assets/botania/lang/en_US.lang | 7 +-- .../assets/botania/textures/gui/manaHud.png | Bin 0 -> 4486 bytes 8 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 resources/assets/botania/textures/gui/manaHud.png diff --git a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java index af4f7e577..2d3a01c44 100644 --- a/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java +++ b/MODSRC/vazkii/botania/client/core/handler/HUDHandler.java @@ -11,10 +11,13 @@ */ package vazkii.botania.client.core.handler; +import java.awt.Color; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; @@ -23,10 +26,14 @@ import net.minecraftforge.event.ForgeSubscribe; import org.lwjgl.opengl.GL11; import vazkii.botania.api.IWandHUD; +import vazkii.botania.client.core.helper.RenderHelper; +import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.item.ModItems; public final class HUDHandler { + private static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD); + @ForgeSubscribe public void onDrawScreen(RenderGameOverlayEvent.Post event) { if(event.type == ElementType.ALL) { @@ -39,27 +46,38 @@ public final class HUDHandler { } } } - public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) { - int type = 0; - if(mana >= 0) { - type = 1; - double percentage = (double) mana / (double) maxMana * 100; - if(percentage == 100) - type = 5; - else if(percentage >= 75) - type = 4; - else if(percentage >= 50) - type = 3; - else if(percentage > 0) - type = 2; - } - String filling = StatCollector.translateToLocal("botaniamisc.status" + type); +// String filling = StatCollector.translateToLocal("botaniamisc.status" + type); + GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Minecraft mc = Minecraft.getMinecraft(); - mc.fontRenderer.drawStringWithShadow(name, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2, res.getScaledHeight() / 2 + 10, color); - mc.fontRenderer.drawStringWithShadow(filling, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filling) / 2, res.getScaledHeight() / 2 + 20, color); + int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2; + int y = res.getScaledHeight() / 2 + 10; + + mc.fontRenderer.drawStringWithShadow(name, x, y, color); + + x = res.getScaledWidth() / 2 - 51; + y += 10; + + GL11.glColor4f(1F, 1F, 1F, 0.5F); + mc.renderEngine.bindTexture(manaBar); + RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5); + + int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); + RenderHelper.drawTexturedModalRect(x + 1 + manaPercentage, y + 1, 0, 0, 5, 100 - manaPercentage, 3); + + Color color_ = new Color(color); + GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(),(byte) color_.getBlue(), (byte) 127); + RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, manaPercentage, 3); + + if(mana < 0) { + String text = StatCollector.translateToLocal("botaniamisc.statusUnknown"); + x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; + y -= 1; + mc.fontRenderer.drawStringWithShadow(text, x, y, color); + } + GL11.glDisable(GL11.GL_BLEND); } } diff --git a/MODSRC/vazkii/botania/client/core/helper/RenderHelper.java b/MODSRC/vazkii/botania/client/core/helper/RenderHelper.java index 6328e65d5..06ddac85b 100644 --- a/MODSRC/vazkii/botania/client/core/helper/RenderHelper.java +++ b/MODSRC/vazkii/botania/client/core/helper/RenderHelper.java @@ -109,4 +109,16 @@ public final class RenderHelper { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); } + + public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), (double)z, (double)((float)(par3 + 0) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), (double)z, (double)((float)(par3 + par5) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), (double)z, (double)((float)(par3 + par5) * f), (double)((float)(par4 + 0) * f1)); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)z, (double)((float)(par3 + 0) * f), (double)((float)(par4 + 0) * f1)); + tessellator.draw(); + } } diff --git a/MODSRC/vazkii/botania/client/lib/LibResources.java b/MODSRC/vazkii/botania/client/lib/LibResources.java index 6d6a02ca1..41f9d1b01 100644 --- a/MODSRC/vazkii/botania/client/lib/LibResources.java +++ b/MODSRC/vazkii/botania/client/lib/LibResources.java @@ -24,6 +24,7 @@ public final class LibResources { public static final String EMTPY_TEXTURE = "emptyTexture"; + public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; diff --git a/MODSRC/vazkii/botania/common/block/subtile/SubTileGenerating.java b/MODSRC/vazkii/botania/common/block/subtile/SubTileGenerating.java index bf97a7737..54cb5feb6 100644 --- a/MODSRC/vazkii/botania/common/block/subtile/SubTileGenerating.java +++ b/MODSRC/vazkii/botania/common/block/subtile/SubTileGenerating.java @@ -111,7 +111,7 @@ public class SubTileGenerating extends SubTileEntity { @Override public boolean onWanded(EntityPlayer player, ItemStack wand) { knownMana = mana; - player.worldObj.playSoundAtEntity(player, "random.orb", 1F, 1F); + player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F); return super.onWanded(player, wand); } diff --git a/MODSRC/vazkii/botania/common/block/tile/TilePool.java b/MODSRC/vazkii/botania/common/block/tile/TilePool.java index 6fc730798..410b2c329 100644 --- a/MODSRC/vazkii/botania/common/block/tile/TilePool.java +++ b/MODSRC/vazkii/botania/common/block/tile/TilePool.java @@ -138,7 +138,7 @@ public class TilePool extends TileMod implements IManaPool { nbttagcompound.setInteger(TAG_KNOWN_MANA, getCurrentMana()); PacketDispatcher.sendPacketToPlayer(new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound), (Player) player); } - worldObj.playSoundAtEntity(player, "random.orb", 1F, 1F); + worldObj.playSoundAtEntity(player, "random.orb", 0.11F, 1F); } public void renderHUD(Minecraft mc, ScaledResolution res) { diff --git a/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java b/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java index b4d37ff97..8d66306dc 100644 --- a/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java +++ b/MODSRC/vazkii/botania/common/block/tile/TileSpreader.java @@ -156,7 +156,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector nbttagcompound.setInteger(TAG_KNOWN_MANA, mana); PacketDispatcher.sendPacketToPlayer(new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, nbttagcompound), (Player) player); } - worldObj.playSoundAtEntity(player, "random.orb", 1F, 1F); + worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F); } else { MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5); if(pos != null && pos.hitVec != null && !worldObj.isRemote) { @@ -309,9 +309,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector int y = res.getScaledHeight() / 2 + 30; mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, color); - GL11.glDisable(GL11.GL_DEPTH_TEST); new RenderItem().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); } diff --git a/resources/assets/botania/lang/en_US.lang b/resources/assets/botania/lang/en_US.lang index c34fe382c..898160030 100644 --- a/resources/assets/botania/lang/en_US.lang +++ b/resources/assets/botania/lang/en_US.lang @@ -6,12 +6,7 @@ botaniamisc.back=Back botaniamisc.craftingContainer=Returns on Crafting botaniamisc.shapeless=Shapeless Recipe botaniamisc.oredict=Ore Dictionary Recipe -botaniamisc.status0=Unknown Status -botaniamisc.status1=Empty -botaniamisc.status2=Mostly Empty -botaniamisc.status3=Moderately Full -botaniamisc.status4=Almost Full -botaniamisc.status5=Full +botaniamisc.statusUnknown=Unknown Status botaniamisc.color=%s Tinted # COLORS diff --git a/resources/assets/botania/textures/gui/manaHud.png b/resources/assets/botania/textures/gui/manaHud.png new file mode 100644 index 0000000000000000000000000000000000000000..c20c60c8cb73728b605c4213b1c8c1b880f9a352 GIT binary patch literal 4486 zcmeH~`9D-|*vF5^zEzfxvW0}Pi|k_?YnHKPi85o~QuZy`i;#69C5Ewu&@}da9U*Cq zC3~`!r6G*x^vm-HJg@JM&w1VFbzkSa?(?~?>;1WYxKGj@6Fnw+Zh8O!m|*(a<^Vte zh7XbkQ=7d)++Z3>PKnXX&JNi zWzFQH8OybfQBwbbV07L1yDo<+#9;@vIN|b0PcxI ztxf>Z1&4WI6u{k={OlA(=>Xp)*F1+zxz1Mi!F zc04OX9YD(nNSP(Z-2kYR=f#gH)#l}a z_a15#Vd)ZO4)-bl7>c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