Jump to content

Recommended Posts

Posted

The title says it all. I want to render a gui over another gui that is already displayed. I went to the Minecraft.displayGuiScreen to see if there is a work around but it seems to always close the gui if another is going to be displayed. Any way around this?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

If you are opening GUIs using Minecraft.getMinecraft().displayGuiScreen(GuiScreen) your mod becomes multiplayer inpompatible. If you try to play multiplayer with that, it always opens the gui to server's owner. For example, server owner has his server and you are it's admin and you installed your mod to this server. And when you open the gui, the gui opens to admin. I think you don't want this.

Use:

player.openGui(ModInstance, GuiID, world, x, y, z);

And I recommend to watch diesieben07's tutorial about simple packet handling. It's very usefull if you are changing something like tile entity that is on server side.

Tutorial link http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

I didn't know using displayGuiScreen did that, but thanks. I already know how to make a gui handler, just thought that way was easier. xD And, how would I use those events to display a Gui over another? Maybe just a simple example would be nice. :)

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Main idea is:

You save fields inside your own storage (event class for example).

Initialize them inside GuiScreenEvent.InitGuiEvent by checking if event.gui is instance of gui desired.

And then draw those elements in GuiScreenEvent.DrawScreenEvent, do button actions in GuiScreenEvent.ActionPerformedEvent.

 

 

1.7.10 is no longer supported by forge, you are on your own.

Posted

That is so much work. ;-; I think I'll just have to deal with not having it drawn over. I have way too many gui's to display over. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

So, I am trying to do what you told me Ernio but, this happens. ;-;

 

http://i.imgur.com/Lqfv5jY.png

http://i.imgur.com/eWQHSBh.png

 

Here's where I render it in my EventForgeClient Class:

 

@SubscribeEvent
public void onGuiScreenDrawn(DrawScreenEvent event) {
	int width = event.gui.width;
	int height = event.gui.height;

	int xSize = 80;
	int ySize = 40;

	if(event.gui instanceof GuiShopBlock) {
		if(GuiShopBlock.getDisplayE()) {
			this.drawPurchaseOverlay("Emerald", Items.emerald, 500, width, height, xSize, ySize, event.gui.mc, event.gui);
			System.out.println("Emerald is True");
		}
	}
}

private void drawPurchaseOverlay(String title, Item itemForRender, int price, int width, int height, int xSize, int ySize, Minecraft mc, GuiScreen gui) {
	GL11.glPushMatrix();

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        int k = (width - xSize) / 2;
        int l = (height - ySize) / 2;

	mc.getTextureManager().bindTexture(crewShopPurchase);

	gui.drawTexturedModalRect(k, l, 0, 0, width, height);

	gui.drawCenteredString(mc.fontRenderer, "Purchase: " + title + "'s", k, l, 0xFFFFFF);

	RenderHelper.enableGUIStandardItemLighting();
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        
        //GL11.glScalef(2.00F, 2.00F, 2.00F);
        
        renderedItem.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(itemForRender), k + 25, l + 25);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        
        GL11.glPopMatrix();
}

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

If you're wondering, when I click the Emerald is when it attempts to draw the texture overlay. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Since the Gui is yours, You can just draw the overlay Gui after the main Gui is drawn, in the method 'drawScreen'.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I'm stupid huh? xD I'll go do that now :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

That works but, it's still doing what was shown above. Am I doing something wrong with OpenGL?

 

public class GuiShopBlock extends GuiScreen {

public static final ResourceLocation texture = new ResourceLocation(MR.TNAME + "textures/gui/crew_shop.png");
private static final ResourceLocation crewShopPurchase = new ResourceLocation(MR.TNAME + "textures/gui/crew_shop_purchase.png");

private int xSize;
private int ySize;

RenderItem renderedItem;

private static boolean displayE;

public GuiShopBlock() {
	this.xSize = 176;
	this.ySize = 166;

	renderedItem = new RenderItem();

	displayE = false;
}

public void initGui() {
        int k = (this.width - this.xSize) / 2;
        int l = (this.height - this.ySize) / 2;
        
	buttonList.clear();
	//buttonList.add(new GuiSlider(0, k + 25, l + 25, 30, 20, "", "", 1, 64, 1, false, true));
}

public void actionPerformed(GuiButton button) {

}

public void drawScreen(int x, int y, float f) { //Add buttons for shop
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        int k = (this.width - this.xSize) / 2;
        int l = (this.height - this.ySize) / 2;

	mc.getTextureManager().bindTexture(texture);

	this.drawTexturedModalRect(k, l, 0, 0, xSize, ySize);

	this.drawString(mc.fontRenderer, "Crew Shop", k + 60, l + 4, 0xFFFFFF);

	this.renderItemOnGui(Items.emerald, 0, 0);
	this.renderItemOnGui(Items.diamond, 100, 0);

	this.drawToolTips(x, y);

	if(this.getDisplayE()) {
		this.drawPurchaseOverlay("Emerald", Items.emerald, 500);
	}

	super.drawScreen(x, y, f);
}

public void drawToolTips(int mouseX, int mouseY) {
    int boxX = (this.width - this.xSize) / 2 + 25;
    int boxY = (this.height - this.ySize) / 2 + 25;

	int defaultX = 16;
	int defaultY = 16;

	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
		List list = new ArrayList();
		list.add("DEAFULT TEXT");
		this.drawHoveringText(list, mouseX, mouseY, fontRendererObj);
		//System.out.println("SHOULD DRAW THE TEXT");
	}
}

public void mouseClicked(int mouseX, int mouseY, int which) {
    int boxX = (this.width - this.xSize) / 2 + 25;
    int boxY = (this.height - this.ySize) / 2 + 25;

	int defaultX = 16;
	int defaultY = 16;

	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
		this.displayE = true;
		//FMLNetworkHandler.openGui(this.mc.thePlayer, CrewMod.instance, GuiId.guiPurchase, this.mc.theWorld, (int)this.mc.thePlayer.posX, (int)this.mc.thePlayer.posY, (int)this.mc.thePlayer.posZ);
		//System.out.println("SHOULD DISPLAY EMERALD SCREEN");
	}

	super.mouseClicked(mouseX, mouseY, which);
}

public void renderItemOnGui(Item item, int mulX, int mulY) {
        int k = (this.width - this.xSize) / 2 + 25;
        int l = (this.height - this.ySize) / 2 + 25;
        
	GL11.glPushMatrix();

	RenderHelper.enableGUIStandardItemLighting();
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        
        //GL11.glScalef(2.00F, 2.00F, 2.00F);
        
        renderedItem.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(item), k + mulX, l + mulY);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        
        GL11.glPopMatrix();
}

private void drawPurchaseOverlay(String title, Item itemForRender, int price) {
	GL11.glPushMatrix();

	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        int k = (this.width - this.xSize) / 2;
        int l = (this.height - this.ySize) / 2;

	mc.getTextureManager().bindTexture(crewShopPurchase);

	this.drawTexturedModalRect(k, l, 0, 0, this.width, this.height);

	this.drawCenteredString(mc.fontRenderer, "Purchase: " + title + "'s", k, l, 0xFFFFFF);

	RenderHelper.enableGUIStandardItemLighting();
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        
        //GL11.glScalef(2.00F, 2.00F, 2.00F);
        
        renderedItem.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(itemForRender), k + 25, l + 25);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        
        GL11.glPopMatrix();
}

public boolean doesGuiPauseGame() {
	return false;
}

public static boolean getDisplayE() {
	return displayE;
}
}

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

How does your texture look like? Does it contain 4 images?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

No, it doesn't. I fixed it by rendering the items on the gui after I rendered the overlay. But, the items overlap the overlay. How would I render the items behind the overlay?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

You should render the item after the overlay is rendered.. There is no other way for this.

+ It would be your UV problem. Don't use drawTexturedModalRect.

        since it uses fixed u/x rate, it would use wrong UV and might cause problems like yours.

  Instead make your own version for that. There you should set the (u,v) to (0,1),(1,1),(1,0),(0,0).

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

So, creating my own would render it over the items? I do not see how this would work. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

No, it will solve this problem: http://i.imgur.com/Lqfv5jY.png

+ I said this thing wrong: You should render the item after the overlay is rendered. You should render item before the overlay is rendered.

And, draw the tooltip after everything is rendered.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Well, when I render it after the items are rendered, I get quite a weird lighting glitch and, the items still overlap. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Well, when I render it after the items are rendered, I get quite a weird lighting glitch and, the items still overlap. xD

Weird lighting glitch would be from tooltip rendering. As I said, render the Tooltip AFTER everything is rendered.

And item overlapping cannot happen if item is rendered before the overlay is rendered...

So, post your current code.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.