Jump to content

Recommended Posts

Posted

Probably a stupidly simple issue... But I made an item renderer and it worked fine, but after a code edit, it just... stopped... working... Anyway... If anyone can help that'd be great :D

 

 

(Please note that I changed a few names of stuff to keep the mod a secret...)

 

 

CustomItemRenderer Code:


public class ItemRenderHandler implements IItemRenderer
{
ModelBase renderModel = null;
int renderID = 0;

public ItemRenderHandler(String par1Name, int par2RenderID)
{
	MainModFile.log(Level.INFO, "Registering ItemRenderHandler for " + par1Name + " with render ID " + par2RenderID + ".");

	this.renderID = par2RenderID;

	switch(this.renderID)
	{
		case(0):
			renderModel = new ModelBook();
			break;
		default:
			break;
	}
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	MainModFile.log(Level.INFO, "Handle Render Type.");
	return true;
}


@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
	if(type.equals(ItemRendererHelper.BLOCK_3D))
	{
		MainModFile.log(Level.INFO, "Block_3D is enabled.");
		return false;
	}
	MainModFile.log(Level.INFO, "Block_3D is not enabled.");
	return true;
}


@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	MainModFile.log(Level.INFO, "Rendering Item!");
	GL11.glPushMatrix();
	switch(this.renderID)
	{
		case(0):
			ClientProxy.mc.renderEngine.bindTexture(CommonProxy.PATH + "book.png");
			switch (type)
			{
				case EQUIPPED:
					if(ClientProxy.mc.gameSettings.thirdPersonView == 0)
					{
						GL11.glTranslatef(1F, 0.6F, 0F);
						GL11.glRotatef(0F, 1, 0, 0);
						GL11.glRotatef(180F, 0, 1, 0);
						GL11.glRotatef(20F, 0, 0, 1);
					} else {
						GL11.glTranslatef(0.5F, 1.3F, 0.8F);
						GL11.glRotatef(0F, 1, 0, 0);
						GL11.glRotatef(140F, 0, 1, 0);
						GL11.glRotatef(0F, 0, 0, 1);
					}
					GL11.glScalef(2.25F, 2.25F, 2.25F);
					renderModel.render((Entity)null, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
					break;
				case INVENTORY:
					GL11.glTranslatef(0F, 0F, 0F);
					GL11.glRotatef(170F, 1, 0, 0);
					GL11.glRotatef(65F, 0, 1, 0);
					GL11.glRotatef(-50F, 0, 0, 1);
					GL11.glScalef(1.5F, 1.5F, 1.5F);
					renderModel.render((Entity)null, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
					break;
				case ENTITY:
					GL11.glTranslatef(0F, 1F, 0F);
					GL11.glRotatef(1F, 1, 0, 0);
					GL11.glRotatef(1F, 0, 1, 0);
					GL11.glRotatef(90F, 0, 0, 1);
					GL11.glScalef(1.5F, 1.5F, 1.5F);
					renderModel.render((Entity)null, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0625F);
					break;
				default:
					break;
			}
			break;
		case(1):
			ClientProxy.mc.renderEngine.bindTexture(CommonProxy.PATH + "Glow.png");
            GL11.glDepthFunc(GL11.GL_LEQUAL);
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);
			switch (type)
			{
				case EQUIPPED:
					if(ClientProxy.mc.gameSettings.thirdPersonView == 0)
					{
						for (int j = 0; j < 1; ++j)
				        {
							GL11.glTranslatef(1F, 0.6F, 0F);
							GL11.glRotatef(0F, 1, 0, 0);
							GL11.glRotatef(180F, 0, 1, 0);
							GL11.glRotatef(20F, 0, 0, 1);
				        }
					} else {
						for (int j = 0; j < 1; ++j)
				        {
							GL11.glTranslatef(0.5F, 1.3F, 0.8F);
							GL11.glRotatef(0F, 1, 0, 0);
							GL11.glRotatef(140F, 0, 1, 0);
							GL11.glRotatef(0F, 0, 0, 1);
				        }
					}
					GL11.glScalef(2.25F, 2.25F, 2.25F);
					break;
				case INVENTORY:
					for (int j = 0; j < 1; ++j)
			        {
						GL11.glTranslatef(0F, 0F, 0F);
						GL11.glRotatef(170F, 1, 0, 0);
						GL11.glRotatef(65F, 0, 1, 0);
						GL11.glRotatef(-50F, 0, 0, 1);
						GL11.glScalef(1.5F, 1.5F, 1.5F);
			        }
					break;
				case ENTITY:
					for (int j = 0; j < 1; ++j)
			        {
						GL11.glTranslatef(0F, 1F, 0F);
						GL11.glRotatef(1F, 1, 0, 0);
						GL11.glRotatef(1F, 0, 1, 0);
						GL11.glRotatef(90F, 0, 0, 1);
						GL11.glScalef(1.5F, 1.5F, 1.5F);
			        }
					break;
				default:
					break;
			}

			GL11.glDisable(GL11.GL_TEXTURE_2D);
	        GL11.glEnable(GL11.GL_BLEND);
	        GL11.glDepthMask(false);
	        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	        
	        Tessellator tessellator = Tessellator.instance;
	        tessellator.startDrawing(GL11.GL_QUADS);
	        tessellator.addVertex(0, 0, 0);
	        tessellator.addVertex(0, 25, 0);
	        tessellator.addVertex(25, 25, 0);
	        tessellator.addVertex(25, 0, 0);
	        tessellator.draw();
	        
	        GL11.glDepthMask(true);
	        GL11.glDisable(GL11.GL_BLEND);
	        GL11.glEnable(GL11.GL_TEXTURE_2D);
	        
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glDepthFunc(GL11.GL_EQUAL);
			break;
		default:
			break;
	}
	GL11.glPopMatrix();
}
}

 

 

ClientProxy:


public class ClientProxy extends CommonProxy
{
public static Minecraft mc;

@Override
public void setUpRenderThings()
{
	mc = FMLClientHandler.instance().getClient();

	MinecraftForgeClient.registerItemRenderer(ItemIDs.BOOK_ID, new ItemRenderHandler(Strings.BOOK_NAME, 0));
	MinecraftForgeClient.registerItemRenderer(ItemIDs.GLOW_ID, new ItemRenderHandler(Strings.GLOW_NAME, 1));
}
}

 

 

I can confirm that the itemrenderers are getting added, but nothing else in the file is.

 

 

Cheers,

  Stumblinbear

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.