Jump to content

[1.7.10] Lighting glitch with Hovering Text


HappyKiller1O1

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The mobs are moving normally for a second, then freeze, then go back to normal, and this repeats. I describe this as mob lag, bc they stutter as if they were lagging. I don't have the best wifi, but that shouldn't matter since its 10mbps which is enough for a server. I have 8 gigs of ram for it, no optimizations have worked, if there is anything more you may need to help lmk, ill describe. The modlist is pretty hefty: VS_ClockworkSurvivalSupportV1.4 aether-1.20.1-1.2.0-neoforge.jar alexsdelight-1.5.jar alexsmobs-1.22.7.jar appleskin-forge-mc1.20.1-2.5.1.jar backpacked-forge-1.20.1-2.2.5.jar balm-forge-1.20.1-7.2.1.jar bettervillage-forge-1.20.1-3.2.0.jar BiomesOPlenty-1.20.1-18.0.0.598.jar botarium-forge-1.20.1-2.3.2.jar CGM-Unofficial-1.4.11+Forge+1.20.1.jar citadel-2.5.2-1.20.1.jar clockwork-1.20.1-0.1.2-forge-05f5d5fbbb.jar configured-forge-1.20.1-2.2.2.jar connectivity-1.20.1-4.9.jar create-1.20.1-0.5.1.f.jar create-new-age-forge-1.20.1-1.1.2.jar createarmoryv0.6.1n.jar createbigcannons-forge-1.20.1-0.5.3.b.jar createchunkloading-1.6.0-forge.jar createdeco-2.0.1-1.20.1-forge.jar createdieselgenerators-1.20.1-1.2h.jar createendertransmission-2.0.7-1.20.1.jar create_misc_and_things_ 1.20.1_4.0A.jar cristellib-1.1.5-forge.jar cupboard-1.20.1-2.3.jar curios-forge-5.7.0+1.20.1.jar destroy-1.20.1-0.8.jar Dungeon Crawl-1.20.1-2.3.14.jar FallingTree-1.20.1-4.3.4.jar FarmersDelight-1.20.1-1.2.4.jar framework-forge-1.20.1-0.6.26.jar geckolib-forge-1.20.1-4.4.2.jar InsaneLib-1.12.1-mc1.20.1.jar Jade-1.20.1-forge-11.8.0.jar jei-1.20.1-forge-15.3.0.4.jar journeymap-1.20.1-5.9.18-forge.jar JustEnoughResources-1.20.1-1.4.0.247.jar kotlinforforge-4.10.0-all.jar l2library-2.4.23.jar libraryferret-forge-1.20.1-4.0.0.jar macawsbridgesbop-1.20-1.1.jar mcw-bridges-2.1.0-mc1.20.4forge.jar moonlight-1.20-2.9.17-forge.jar morevillagers-forge-1.20.1-5.0.0.jar Mo_ZombiesWave-1.20.1-0.1.0-forge.jar NaturesCompass-1.20.1-1.11.2-forge.jar Placebo-1.20.1-8.6.1.jar refinedstorage-1.12.4.jar soundphysics-forge-1.20.1-1.1.2.jar spark-1.10.53-forge.jar stealing_villagers-forge-1.20.1-1.0.0.jar s_a_b-1.3.0_1.20.1.jar takesapillage-1.0.3-1.20.1.jar TerraBlender-forge-1.20.1-3.0.1.4.jar tombstone-1.20.1-8.6.2.jar Towns-and-Towers-1.12-Fabric+Forge.jar twilightforest-1.20.1-4.3.2145-universal.jar valkyrienskies-120-2.1.3-beta.1.jar veinmining-forge-1.3.0+1.20.1.jar waystones-forge-1.20-14.1.3.jar YungsApi-1.20-Forge-4.0.3.jar YungsBetterDesertTemples-1.20-Forge-3.0.3.jar YungsBetterDungeons-1.20-Forge-4.0.3.jar YungsBetterEndIsland-1.20-Forge-2.0.5.jar YungsBetterJungleTemples-1.20-Forge-2.0.4.jar YungsBetterMineshafts-1.20-Forge-4.0.4.jar YungsBetterNetherFortresses-1.20-Forge-2.0.5.jar YungsBetterOceanMonuments-1.20-Forge-3.0.4.jar YungsBetterStrongholds-1.20-Forge-4.0.3.jar YungsBetterWitchHuts-1.20-Forge-3.0.3.jar YungsBridges-1.20-Forge-4.0.3.jar zaynens_leather_from_rotten_flesh_mod_1.20.1.jar
    • Thank you so much! Unfortunately before reading this I reinstalled my java installer. Now when I try to open the forge installer I receive an error message stating 'Unable to install Java' even though I have definitely downloaded and installed the latest version. Any idea what this could be or how I could fix it?  
    • IT WORKED! THANK YOU!
    • sorry for the stuborn ness ss   test code logs and planks return nothing on minable but i can use the other tags  name minecraft:oak_log BlockTags.LOGS name minecraft:oak_planks BlockTags.PLANKS   it kinda works but its not like like perfect             
    • I'm making a custom modpack for 1.20.1 and everything else seems to work except this Passive skilltree mod. The world loads fine but when I press the keybind to open the mod's GUI, the world immediately saves and crashes with this report: https://pastebin.com/svEPsRty Any help or insight towards the right direction is greatly appreciated!
  • Topics

×
×
  • Create New...

Important Information

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