Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.onVoid.helpfuladdons.charger;
- import java.util.ArrayList;
- import java.util.List;
- import org.lwjgl.opengl.GL11;
- import me.onVoid.helpfuladdons.HelpfulAddons;
- import me.onVoid.helpfuladdons.References;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.inventory.GuiContainer;
- import net.minecraft.client.resources.I18n;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ResourceLocation;
- public class GuiCharger extends GuiContainer {
- public static int chargeProgress = 0;
- public static final ResourceLocation guiImg = new ResourceLocation(References.MODID + ":" + "textures/gui/multichargergui.png");
- public ChargerTileEntity charger;
- public GuiCharger(InventoryPlayer pi, ChargerTileEntity ent) {
- super(new ContainerCharger(pi, ent));
- this.charger = ent;
- this.xSize = 176;
- this.ySize = 166;
- }
- @Override
- protected void drawGuiContainerBackgroundLayer(float arg0, int mouseX, int mouseY) {
- GL11.glColor4f(1F, 1F, 1F, 1F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(guiImg);
- drawTexturedModalRect(guiLeft, guiTop, 0,0, xSize, ySize);
- if (ChargerTileEntity.storage.getEnergyStored() > 0){
- int le = ChargerTileEntity.storage.getMaxEnergyStored() / 40;
- HelpfulAddons.amountOutOfForty = ChargerTileEntity.storage.getEnergyStored() / le;
- drawTexturedModalRect(guiLeft + 10, guiTop + 9 + (40 - Math.round(HelpfulAddons.amountOutOfForty)), 176, 0, 13, Math.round(HelpfulAddons.amountOutOfForty));
- }
- }
- public void drawGuiContainerForegroundLayer(int mouseX, int mouseY){
- GL11.glColor4f(1, 1, 1, 1);
- String name = this.charger.hasCustomInventoryName() ? this.charger.getInventoryName() :
- I18n.format(this.charger.getInventoryName(), new Object[0]);
- this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
- this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
- drawToolTips(mouseX, mouseY);
- }
- public void drawToolTips(int mouseX, int mouseY) {
- int boxX = guiLeft + 10; //These are just like the center of the screen.
- int boxY = guiTop + 9; //You make these in order to get a starting point on where to check (With these, it would be the top left of your GUI)
- int defaultX = 12; //These are like the boxes of the area to check.
- int defaultY = 40; //So, if you're rendering an Item to hover over, it would be 16x16.
- //This checks if the mouse is in the correct position on screen. You can add and subtract from boxX and Y to determine where to be.
- if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
- List list = new ArrayList(); //Just the list of text to be added. It is just like the addInformation method now. :P
- list.add(ChargerTileEntity.storage.getEnergyStored() + " / " + ChargerTileEntity.storage.getMaxEnergyStored() + " RF"); //Each time you add something, it's gonna be a new line in the tooltip.
- this.drawHoveringText(list, mouseX - guiLeft, mouseY - guiTop, fontRendererObj);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement