Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.6.4] Item GUI not rescaling properly


Naiakoa
 Share

Recommended Posts

Been working on a lore book for my mod but ended up with a issue with the GUI, the thing will not rescale at all. So after going through all of the other support issues on the forum multiple times I have gotten to the point where the UI scale refuses to work properly or just ends up following the mouse. It is kind of weird but whatever. In the following video it will show what the following issues are, in the bottom right corner of the video will say which section of code is which to define the gui bug. Does anyone know what I am missing that could make the thing rescale and NOT follow the mouse? :/ What I am trying to do for the UI scale is have the UI centered like source 2 but be able to make a custom texture resolution like in source 1...

 

Forge Version:

9.11.1.965

 

Video with Issues

 

(Why video you might ask? Well I am really bad at explaining things...video will explain things better...)

 

Code Source 1

 

package Naiakoa.Nexion.books;

import Naiakoa.Nexion.Blocks.Furnace.Demon.ContainerDemonForge;
import Naiakoa.Nexion.Blocks.Furnace.Demon.TileEntityDemonForge;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;

/**
* Created by Naiakoa on 1/13/14.
*/
public class LoreBookMainGUI extends GuiScreen
{
    private ResourceLocation book = new ResourceLocation("Nexion:textures/gui/Book.png");
    private final int xSizeOfTexture = 250;
    private final int ySizeOfTexture = 245;
    int posX = (this.width - 50) /2;
    int posY = (this.height - 50) /2;
    public LoreBookMainGUI(EntityPlayer player)
    {

    }
    @Override
    public void drawScreen(int x, int y, float f)
    {
        //drawDefaultBackground();
        //GL11.glColor4f(100f,213f,255f,5f);
        Minecraft.getMinecraft().getTextureManager().bindTexture(book);
        drawTexturedQuadFit(x, y, width - 200, height - 200, zLevel);
        super.drawScreen(x,y,f);
    }
    @Override
    public boolean doesGuiPauseGame()
    {
        return false;
    }
    public void initGui()
    {
        this.buttonList.add(new GuiButton(0, posX + 40, posY + 40, 1, 1, "Send Chat"));
    }
    public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel)
    {
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0,1);
        tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1);
        tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1,0);
        tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0);
        tessellator.draw();
    }
    public void actionPerformed(GuiButton button)
    {
        switch(button.id)
        {
            case 0:
            {
                Minecraft.getMinecraft().thePlayer.addChatMessage("Oh Hai Der");
                Minecraft.getMinecraft().thePlayer.addChatMessage("Lore Button 1");
                Minecraft.getMinecraft().thePlayer.addChatMessage("Some Kind of Long Lore");
                Minecraft.getMinecraft().thePlayer.addChatMessage("End of Lore Chapter");
            }
        }
    }
}

 

 

Code Source 1 (modifed)

Only thing that was changed

 

    public void drawScreen(int x, int y, float f)
    {
        //drawDefaultBackground();
        //GL11.glColor4f(100f,213f,255f,5f);
        Minecraft.getMinecraft().getTextureManager().bindTexture(book);
        drawTexturedQuadFit(posX, posY, width - 200, height - 200, zLevel);
        super.drawScreen(x,y,f);
    }

 

 

Source Section 2

 

package Naiakoa.Nexion.books;

import Naiakoa.Nexion.Blocks.Furnace.Demon.ContainerDemonForge;
import Naiakoa.Nexion.Blocks.Furnace.Demon.TileEntityDemonForge;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;

/**
* Created by Naiakoa on 1/13/14.
*/
public class LoreBookMainGUI extends GuiScreen
{
    private ResourceLocation book = new ResourceLocation("Nexion:textures/gui/Book.png");
    private final int xSizeOfTexture = 250;
    private final int ySizeOfTexture = 245;
    public LoreBookMainGUI(EntityPlayer player)
    {

    }
    @Override
    public void drawScreen(int x, int y, float f)
    {
        //drawDefaultBackground();
        //GL11.glColor4f(100f,213f,255f,5f);
        Minecraft.getMinecraft().getTextureManager().bindTexture(book);
        int posX = (this.width - xSizeOfTexture) / 2;
        int posY = (this.height - ySizeOfTexture) / 2;
        drawTexturedModalRect(posX,posY,0,0,xSizeOfTexture,ySizeOfTexture);
        super.drawScreen(x,y,f);
    }
    @Override
    public boolean doesGuiPauseGame()
    {
        return false;
    }
    public void initGui()
    {
        int posX = (this.width - xSizeOfTexture) / 2;
        int posY = (this.height - ySizeOfTexture) / 2;
        this.buttonList.add(new GuiButton(0, posX + 40, posY + 40, 1, 1, "Send Chat"));
    }
    public void actionPerformed(GuiButton button)
    {
        switch(button.id)
        {
            case 0:
            {
                Minecraft.getMinecraft().thePlayer.addChatMessage("Oh Hai Der");
                Minecraft.getMinecraft().thePlayer.addChatMessage("Lore Button 1");
                Minecraft.getMinecraft().thePlayer.addChatMessage("Some Kind of Long Lore");
                Minecraft.getMinecraft().thePlayer.addChatMessage("End of Lore Chapter");
            }
        }
    }
}

 

A modder uses search for solutions, a coder asks for help only after looking into the main source of the game modding. A master java programmer has solutions and is helpful. Be friendly to others, they will be friendly to you (depending on how their day goes ;) )

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.