From 0d9a18b41a5999a9097e886a4ef790fd099ba0f1 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 18 Oct 2018 19:08:15 +0200 Subject: [PATCH] made the aura display use less numbers and more niceity --- .../naturesaura/aura/BasicAuraContainer.java | 2 +- .../naturesaura/events/ClientEvents.java | 65 ++++++++++++++++-- .../assets/naturesaura/lang/en_US.lang | 5 +- .../naturesaura/textures/gui/overlays.png | Bin 0 -> 1304 bytes 4 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/assets/naturesaura/textures/gui/overlays.png diff --git a/src/main/java/de/ellpeck/naturesaura/aura/BasicAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/aura/BasicAuraContainer.java index 0c888fbd..ef31f45c 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/BasicAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/BasicAuraContainer.java @@ -41,7 +41,7 @@ public class BasicAuraContainer implements IAuraContainer { @Override public int getAuraColor() { - return 0x00FF00; + return 0x1E891E; } public void writeNBT(NBTTagCompound compound) { diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 17e540cd..2e4531e0 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -7,11 +7,17 @@ import de.ellpeck.naturesaura.aura.IAuraContainerProvider; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleMagic; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; @@ -27,6 +33,8 @@ import java.util.List; @SideOnly(Side.CLIENT) public class ClientEvents { + private static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png"); + @SubscribeEvent public void onDebugRender(RenderGameOverlayEvent.Text event) { if (Minecraft.getMinecraft().gameSettings.showDebugInfo) { @@ -61,13 +69,15 @@ public class ClientEvents { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); - if (event.getType() == ElementType.ALL && mc.currentScreen == null) { + if (event.getType() == ElementType.ALL /*&& mc.currentScreen == null*/) { ScaledResolution res = event.getResolution(); if (mc.player != null) { ItemStack stack = mc.player.getHeldItemMainhand(); if (!stack.isEmpty() && stack.getItem() == ModItems.EYE) { int maxAura = 0; int aura = 0; + int total = 0; + for (TileEntity tile : Helper.getTileEntitiesInArea(mc.world, mc.player.getPosition(), 15)) { if (tile instanceof IAuraContainerProvider) { IAuraContainerProvider provider = (IAuraContainerProvider) tile; @@ -75,11 +85,28 @@ public class ClientEvents { IAuraContainer container = provider.container(); maxAura += container.getMaxAura(); aura += container.getStoredAura(); + total++; } } } - String area = "Aura in the area: " + aura + " / " + maxAura; - mc.fontRenderer.drawString(area, 5, 5, 0xFFFFFF, true); + + GlStateManager.pushMatrix(); + mc.getTextureManager().bindTexture(OVERLAYS); + + GlStateManager.color(0.8F, 0.25F, 0.25F); + float totalPercentage = total / 1500F; + int tHeight = MathHelper.ceil(Math.min(1F, totalPercentage) * 75); + if (tHeight < 75) + Gui.drawModalRectWithCustomSizedTexture(3, 17, 6, 12, 6, 75 - tHeight, 256, 256); + if (tHeight > 0) + Gui.drawModalRectWithCustomSizedTexture(3, 17 + 75 - tHeight, 0, 12 + 75 - tHeight, 6, tHeight, 256, 256); + + GlStateManager.color(0.25F, 0.8F, 0.25F); + int aHeight = MathHelper.ceil(aura / (float) maxAura * 75); + if (aHeight < 75) + Gui.drawModalRectWithCustomSizedTexture(12, 17, 6, 12, 6, 75 - aHeight, 256, 256); + if (aHeight > 0) + Gui.drawModalRectWithCustomSizedTexture(12, 17 + 75 - aHeight, 0, 12 + 75 - aHeight, 6, aHeight, 256, 256); if (mc.objectMouseOver != null) { BlockPos pos = mc.objectMouseOver.getBlockPos(); @@ -87,13 +114,37 @@ public class ClientEvents { TileEntity tile = mc.world.getTileEntity(pos); if (tile instanceof IAuraContainerProvider) { IAuraContainer container = ((IAuraContainerProvider) tile).container(); - String s = "Aura stored: " + container.getStoredAura() + " / " + container.getMaxAura(); - mc.fontRenderer.drawString(s, - (res.getScaledWidth() - mc.fontRenderer.getStringWidth(s)) / 2, res.getScaledHeight() / 4 * 3, - container.getAuraColor(), true); + + int color = container.getAuraColor(); + GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F); + + int x = res.getScaledWidth() / 2 - 50; + int y = res.getScaledHeight() / 2 + 25; + int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 100F); + + if (width < 100) + Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 100 - width, 6, 256, 256); + if (width > 0) + Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256); + + IBlockState state = mc.world.getBlockState(pos); + ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player); + String s = blockStack.getDisplayName(); + mc.fontRenderer.drawString(s, x + 50 - mc.fontRenderer.getStringWidth(s) / 2F, y - 9, color, true); } } } + + if (totalPercentage > 1F) { + mc.fontRenderer.drawString("+", 3F, 9.5F, 0xBB3333, true); + } + + float scale = 0.75F; + GlStateManager.scale(scale, scale, scale); + mc.fontRenderer.drawString(I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"), 3 / scale, 3 / scale, 0xBB3333, true); + mc.fontRenderer.drawString(I18n.format("info." + NaturesAura.MOD_ID + ".aura_percentage"), 12 / scale, 10 / scale, 0x33BB33, true); + + GlStateManager.popMatrix(); } } } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 4fa6ad62..559e61bd 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -16,4 +16,7 @@ item.naturesaura.gold_leaf.name=Gold Leaf item.naturesaura.infused_iron.name=Infused Iron container.naturesaura.tree_ritual.name=Tree Infusion -container.naturesaura.altar.name=Natural Altar \ No newline at end of file +container.naturesaura.altar.name=Natural Altar + +info.naturesaura.aura_in_area=Provider Amount +info.naturesaura.aura_percentage=Saturation \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/gui/overlays.png b/src/main/resources/assets/naturesaura/textures/gui/overlays.png new file mode 100644 index 0000000000000000000000000000000000000000..363cfa2b799344dc517168f7bc069b5e5d3328c9 GIT binary patch literal 1304 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(kk47* z5n0T@z_$;C8DBYVJOC7wC~=J_3C>R|DNig)Whh9@%q!8$OD$0_(KFODOxBv?4K!z( zr;B4qMcmt4hJG^KOs;`pk9$}nloYly2bDQKn!>A4sjYK>(fX5IRfy@KO*a0MCI3C2 zH>vN+E=I@j>&;oOURl`H{wjI+SN8d%qMZk3Tk8M&{rmUnyLazCJw082PxIrw_U8^3 z>ix5E{9rzpxuAw4KR;i8zJ2{OS(*2L3;B2$^3O8-VU}RH*B#wZ&#;|g&-Bk0b`^W} zKaN>5nWg@8WlVg0d|qCjU;O^Mr@edjJwN`t-s0R*E6)$x=ZOD5eE9Iw=jZ3|S$zEX z@nROJ9Us1YDf#*FF?;@-r%#`L`tzs8>Rcn^gSCF@9Idlw6( z(-{s-^nk39a6ul3_b-CZV`?+eg=IF&sx0E98Gc0kd(R-V|7ZOCaC