Jump to content

Recommended Posts

Posted

Hey so, I made my gui and all that fancy stuff. But, when ever I display hovering text, this happens:

 

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

 

I really don't know what's causing this. I would really appreciate some help!

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

Make sure you are enabling/disabling all GL states to state they should be (were before drawing).

I'd need code to tell you exacly where (it's all about order).

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

Posted

Here's my Gui class:

 

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;

private int itemPrice;

RenderItem renderedItem;

Item item;

GuiSlider slider;
GuiButton buy;
GuiButton exit;
GuiButton prev;
GuiButton next;
GuiButton exitGui;

private boolean canDisplayPurchase;

public GuiShopBlock() { //ADD THE REST OF THE PAGES
	this.xSize = 176;
	this.ySize = 166;

	renderedItem = new RenderItem();

	canDisplayPurchase = false;
	itemPrice = 0;
	item = null;
}

public void initGui() {
        int k = (this.width - this.xSize) / 2;
        int l = (this.height - this.ySize) / 2;
        
	buttonList.clear();

	slider = new GuiSlider(0, k + 48, l + 40, 72, 14, "Quantity: ", "", 1, 64, 1, false, true);
	buy = new GuiButton(1, k + 49, l + 79, 26, 14, "Buy");
	exit = new GuiButton(2, k + 92, l + 79, 26, 14, "Exit");
	prev = new GuiButton(3, k + 6, l + 145, 30, 18, "Prev");
	next = new GuiButton(4, k + 139, l + 145, 30, 18, "Next");
	exitGui = new GuiButton(5, k + 72, l + 145, 30, 18, "Exit");

	buttonList.add(slider);
	buttonList.add(buy);
	buttonList.add(exit);
	buttonList.add(prev);
	buttonList.add(next);
	buttonList.add(exitGui);

	slider.visible = false;
	buy.visible = false;
	exit.visible = false;
	prev.enabled = false;
}

public void actionPerformed(GuiButton button) {
	int cost = (int)(slider.getValueInt() * itemPrice);
	int userID = this.mc.thePlayer.getEntityId();
	World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
	EntityPlayer player = (EntityPlayer)world.getEntityByID(userID);
	ExtendedPlayer ep = ExtendedPlayer.get(player);

	switch(button.id) {
		case 0:
			break;
		case 1:
			if(canPlayerBuy(cost)) {
				//System.out.println(ep.getCrewCoinAmount());
				ep.modifyCrewCoins(-cost);
				PacketRegistry.network.sendTo(new PacketCoinChangeClient(player, ep.getCrewCoinAmount()), (EntityPlayerMP)player);
				ItemStack stack = new ItemStack(this.item, slider.getValueInt(), 0);

				//System.out.println(this.item);

				if(stack != null) {
					EntityItem item = new EntityItem(world, player.posX, player.posY, player.posZ, stack);

					if(!world.isRemote) {
						world.spawnEntityInWorld(item);
					}
				}

				//System.out.println(ep.getCrewCoinAmount());
				//System.out.println(cost);
				//System.out.println(slider.getValueInt());
				closePurchase();
			}else {
				EventsClientForge.purchaseError();
			}

			break;
		case 2:
			closePurchase();
			break;
	}
}

public void drawScreen(int x, int y, float f) {
	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.renderItemOnGui(Items.emerald, 0, 0);
	this.renderItemOnGui(Items.diamond, 100, 0);

	this.renderItemOnGui(Items.gold_ingot, 0, 25);
	this.renderItemOnGui(Items.iron_ingot, 100, 25);

	this.renderItemOnGui(Items.quartz, 0, 50);
	this.renderItemOnGui(Items.redstone, 100, 50);

	this.drawString(mc.fontRenderer, "Crew Shop", k + 60, l + 8, 0xFFFFFF);
	this.drawString(mc.fontRenderer, "Welcome to the Crew Shop!", k + 20, l + 100, 0xFFFFFF);
	this.drawString(mc.fontRenderer, "To purchase an something,", k + 18, l + 114, 0xFFFFFF);
	this.drawString(mc.fontRenderer, "please click an item above.", k + 20, l + 124, 0xFFFFFF);

	if(this.canDisplayPurchase) {
		this.drawPurchaseOverlay();
	}

	this.drawToolTips(x, y);

	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;

	/* Left Side */
	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.EMERALD, "Emerald");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}

	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.GOLD_INGOT, "Gold Ingot");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}

	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.QUARTZ, "Quartz");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}

	/* Right Side */
	if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.DIAMOND, "Diamond");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}

	if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.IRON_INGOT, "Iron Ingot");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}

	if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) {
		List list = new ArrayList();
		defaultTooltip(list, ItemPrices.REDSTONE, "Redstone");
		this.drawTooltipText(list, mouseX, mouseY, fontRendererObj);
	}
}

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(!this.canDisplayPurchase) {

		/* Left Side */
		if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
			openPurchase(ItemPrices.EMERALD, Items.emerald);
		}

		if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) {
			openPurchase(ItemPrices.GOLD_INGOT, Items.gold_ingot);
		}

		if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) {
			openPurchase(ItemPrices.QUARTZ, Items.quartz);
		}

		/* Right Side */
		if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY && mouseY < boxY + defaultY) {
			openPurchase(ItemPrices.DIAMOND, Items.diamond);
		}

		if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) {
			openPurchase(ItemPrices.IRON_INGOT, Items.iron_ingot);
		}

		if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) {
			openPurchase(ItemPrices.REDSTONE, Items.redstone);
		}
	}

	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);
        RenderHelper.disableStandardItemLighting();
        
        GL11.glPopMatrix();
}

private void drawPurchaseOverlay() {
	//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

	int xSize = 80;
	int ySize = 62;

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

	mc.getTextureManager().bindTexture(crewShopPurchase);

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

	this.renderItemOnGui(this.item, 50, 36);

	//this.drawCenteredString(mc.fontRenderer, "Purchase Item", k + 84, l + 40, 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();
}

private void openPurchase(int itemPrice, Item itemToDrop) {
	this.canDisplayPurchase = true;
	slider.visible = true;
	buy.visible = true;
	exit.visible = true;
	this.itemPrice = itemPrice;
	this.item = itemToDrop;
	slider.maxValue = item.getItemStackLimit();
	slider.updateSlider();
	next.enabled = false;
	exitGui.enabled = false;
}

public void closePurchase() {
	canDisplayPurchase = false;
	slider.visible = false;
	buy.visible = false;
	exit.visible = false;
	slider.setValue(1D);
	slider.maxValue = 64;
	slider.updateSlider();
	this.item = null;
	next.enabled = true;
	exitGui.enabled = true;
}

private void drawTooltipText(List list, int mouseX, int mouseY, FontRenderer fr) {
	if(!this.canDisplayPurchase) {
		this.drawHoveringText(list, mouseX, mouseY, fr);
	}else {
		return;
	}
}

private void defaultTooltip(List list, int itemP, String itemN) {
	list.add(EnumChatFormatting.YELLOW + itemN);
	list.add(EnumChatFormatting.AQUA + "Price: " + getCost(itemP));
}

private boolean canPlayerBuy(int cost) {
	if(ExtendedPlayer.get(this.mc.thePlayer).getCrewCoinAmount() >= cost) {
		return true;
	}else {
		return false;
	}
}

private String getCost(int itemPrice) {
	if(ExtendedPlayer.get(this.mc.thePlayer).getCrewCoinAmount() >= itemPrice) {
		return EnumChatFormatting.GREEN.toString() + itemPrice;
	}else {
		return EnumChatFormatting.RED.toString() + itemPrice;
	}
}

public void keyTyped(char character, int par1) {
	if(character == Keyboard.KEY_E) {
		this.mc.displayGuiScreen((GuiScreen)null);
	}

	super.keyTyped(character, par1);
}

public boolean doesGuiPauseGame() {
	return false;
}
}

 

It's a bit messy because I am still testing some things within it. I mainly just call "this.drawHoveringText()" from the GuiScreen class. Maybe they did something wrong?

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 draw ToolTip after super.drawScreen(x, y, f) called.

 

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

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

Posted

Well... that worked. I feel like the more difficult side of things when it comes to mod creation I understand and overcome. But the simplistic things I overlook and have to post a thread on it. xD Thanks to both of you. :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.

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.