Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.