Jump to content

Recommended Posts

Posted

Hello all.

This is my first time posting here. I have had some trouble with Gui rendering  in my mod.

As shown by the screenshots below, when the sixth slot in the custom hotbar is filled, the entire game begins to go nuts. The bar behind it darkens, the chat becomes a solid box and item names become "doubled"?

 

width=800 height=428http://i1317.photobucket.com/albums/t627/Mitchell_Bagot/screenshot1_zpsk0l1nfei.png[/img]width=800 height=426http://i1317.photobucket.com/albums/t627/Mitchell_Bagot/screenshot2_zps4my3rz1b.png[/img]

 

Here is my Gui code here, just ask if anything more is required. Thank you for the help!\

 

package com.slugterra.gui;

import org.lwjgl.opengl.GL11;

import com.slugterra.entity.properties.ExtendedPlayer;
import com.slugterra.lib.Strings;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

public class GuiSlugBeltOverlay extends Gui{

private Minecraft mc;
public static int selslot;
protected static final RenderItem itemRenderer = new RenderItem();

public GuiSlugBeltOverlay(Minecraft mc){
	super();
	this.mc = mc;
}

private ExtendedPlayer props;

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event){
	if(event.isCancelable() || event.type != ElementType.HOTBAR){
		return;
	}
	ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
	int k = scaledresolution.getScaledWidth();
	int l = scaledresolution.getScaledHeight();
	GL11.glDisable(GL11.GL_LIGHTING);

	//get player properties
	if(props == null){
		props = ExtendedPlayer.get((EntityPlayer)this.mc.thePlayer);
		this.selslot = props.invslot;
	}

	for (int i1 = 0; i1 < 6; ++i1)
	{
		int k1 = l / 2 - 87 + i1 * 22;//change last value to push up or down
		this.renderInventorySlot(i1, 6, k1);
	}

	GL11.glEnable(GL11.GL_BLEND);

	//rendering bar
	this.mc.renderEngine.bindTexture(new ResourceLocation(Strings.MODID + ":textures/gui/slughotbar2.png"));
	this.drawTexturedModalRect(2, l/2-90, 0, 0, 24, 133);

	//rendering square thing over hotbar
	this.mc.renderEngine.bindTexture(new ResourceLocation(Strings.MODID + ":textures/gui/hotbarsquare.png"));
	this.drawTexturedModalRect(2, (22 * selslot) + (l/2-92)+1, 0, 0, 26, 26);
}

private void renderInventorySlot(int p_73832_1_, int p_73832_2_, int p_73832_3_)
{
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_BLEND);
	ItemStack itemstack = props.inventory.getStackInSlot(p_73832_1_);

	if (itemstack != null)
	{
		float f1 = (float)itemstack.animationsToGo;

		if (f1 > 0.0F)
		{
			GL11.glPushMatrix();
			float f2 = 1.0F + f1 / 5.0F;
			GL11.glTranslatef((float)(p_73832_2_ + , (float)(p_73832_3_ + 12), 0.0F);
			GL11.glScalef(1.0F / f2, (f2 + 1.0F) / 2.0F, 1.0F);
			GL11.glTranslatef((float)(-(p_73832_2_ + ), (float)(-(p_73832_3_ + 12)), 0.0F);
		}

		itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), itemstack, p_73832_2_, p_73832_3_);

		if (f1 > 0.0F)
		{
			GL11.glPopMatrix();
		}

		//itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), itemstack, p_73832_2_, p_73832_3_);
	}
}

}

 

Posted

Always go for the Minecraft version the latest recommended version of Forge is for, and in this case 1.11.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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



×
×
  • Create New...

Important Information

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