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 000000000..c20c60c8c Binary files /dev/null and b/resources/assets/botania/textures/gui/manaHud.png differ