Posted January 28, 201510 yr Ok so im working on a gui to display power, but so far I have ran into a problem my power display shows the bar correctly when full but when its filling it displays top going to the bottom but I need to invert it how can I do this
January 28, 201510 yr Ok so im working on a gui to display power, but so far I have ran into a problem my power display shows the bar correctly when full but when its filling it displays top going to the bottom but I need to invert it how can I do this Show the code please as our crystal balls are kinda not working. If my post helped you, please press that "Thank You"-button to show your appreciation. Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding! Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.
January 28, 201510 yr Author Heres the badly laid out gui code I threw together in like 2 minutes at school package com.linumhost.Gui; import java.awt.Font; import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; import java.text.SimpleDateFormat; import java.util.Date; import org.lwjgl.opengl.GL11; import com.linumhost.Blocks.AirGenerator; import com.linumhost.TileEntity.TileEntityAirGeneratorBlock; import com.linumhost.lib.RefStrings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; public class AirGeneratorGui extends GuiScreen { Minecraft mc = Minecraft.getMinecraft(); GuiButton testButton; EntityPlayer player = mc.thePlayer; TileEntityAirGeneratorBlock tile = new TileEntityAirGeneratorBlock(); String title = "Info Block"; AffineTransform affinetransform = new AffineTransform(); FontRenderContext frc = new FontRenderContext(affinetransform,true,true); Font font = new Font("Tahoma", Font.PLAIN, 12); int titleWidth = (int)(font.getStringBounds(title, frc).getWidth()); int titleheight = (int)(font.getStringBounds(title, frc).getHeight()); int tabWidth = 61 + 10; int titleXPos = (tabWidth - titleWidth) / 2; //int powerDisplayHeight = 100 / tile.getEnergyStored(); SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); String time = sdf.format(new Date()); public final int xPowerDisplay = 19; public final int yPowerDisplay = 53; public final int xSizeOfStorage = 13; public final int ySizeOfStorage = 47; public final int xSizeOfInside = 252; public final int ySizeOfInside = 139; public final int xSizeOfTexture = 256; public final int ySizeOfTexture = 156; public final int xSizeOfInterier = 226; public final int ySizeOfInterier = 113; public final int xSizeOfSideGap = 11; public final int ySizeOfSideGap = 115; public final int xSizeOfTopGap = 228; public final int ySizeOfTopGap = 11; public final int xSizeOfBottomGap = xSizeOfTopGap; public final int ySizeOfBottomGap = ySizeOfTopGap; @Override public void drawScreen(int x, int y, float f){ int xPos = (this.width - xSizeOfTexture) / 2; int yPos = (this.height - ySizeOfTexture) / 2; int levelPosX = (xSizeOfTexture) / 2; int levelPosY = (ySizeOfTexture) / 2; int xPowerDisplayPos = (this.width - 19) / 2; int yPowerDisplayPos = (this.height - 53) / 2; int bottom = (ySizeOfTexture - 20 - 2); GL11.glColor4f(1F, 1F, 1F, 1F); mc.renderEngine.bindTexture(new ResourceLocation(RefStrings.MODID, "/textures/gui/airGeneratorBg.png")); drawDefaultBackground(); drawTexturedModalRect(xPos, yPos, 0, 0, xSizeOfTexture, ySizeOfTexture); GL11.glColor4f(1F, 1F, 1F, 1F); mc.renderEngine.bindTexture(new ResourceLocation(RefStrings.MODID, "/textures/gui/energyStorageBar.png")); drawTexturedModalRect(xPos + 137 - xSizeOfStorage, yPos + 63 , 0, 0, xSizeOfStorage, (tile.getEnergyStored()*ySizeOfStorage)/ tile.getMaxEnergyStored()); //drawRect(xPos + 5, bottom + 40, 30, 100, 0x000000); //drawRect(xPos + 5, bottom + 40, 30, powerDisplayHeight, 0xd01414); fontRendererObj.drawString("Air Gen.", xPos + 10 + titleXPos, yPos + 4, 0x000000); fontRendererObj.drawString("Power: " + tile.storage + "/" + tile.getMaxEnergyStored(), xPos + xSizeOfSideGap + 5 , yPos + ySizeOfBottomGap + 100, 0x000000); super.drawScreen(x, y, f); } public void initGui(){ int xSize = 100; int ySize = 20; int xPos = (xSizeOfTexture) / 2; int yPos = (ySizeOfTexture) / 2; int bottom = (ySizeOfTexture - ySize - 2); buttonList.clear(); super.initGui(); } @Override public boolean doesGuiPauseGame(){ return false; } }
January 28, 201510 yr You should use constructor to get your tileentity because at the moment your code generates new tileentity everytime it runs. So yeah, make constructor. If my post helped you, please press that "Thank You"-button to show your appreciation. Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding! Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.
January 28, 201510 yr TileEntityAirGeneratorBlock tile; public AirGeneratorGui(TileEntityAirGeneratorBlock tile) { this.tile = tile; } I am the author of Draconic Evolution
January 28, 201510 yr Author Ok but now back to the issue how can I invert the way it displays the texture
January 28, 201510 yr You need to do this: scaleHeight = maxScaleHeight - (currFlux / (float) maxFlux * maxScaleHeight ) Here's an example of my generator GUI: https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/de/sanandrew/mods/enderstuffp/client/gui/GuiOreGenerator.java#L57 Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
January 28, 201510 yr Author I see your using the cofh api, how exactly could I use it im not sure on how to add apis yet
January 28, 201510 yr I see your using the cofh api, how exactly could I use it im not sure on how to add apis yet The answer does not require the use of an API. Anyway if you want to have compatibiliy between your and some other guy's mod you must use API that you clarity in mcmod.info file. If my post helped you, please press that "Thank You"-button to show your appreciation. Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding! Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.
January 28, 201510 yr Author Ok and another gui related issue, if I use a static variable it will update on the gui from the tile but if I use for example getEnergyStored() it just returns once
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.