Jump to content

How do I correctly render a custom bow in the players hands?


Ethyl_Amine

Recommended Posts

In third person view, my custom bow is rendered as an item as opposed to how the vanilla bow is rendered, I have tried using bFull3d however the bow still does not render as the vanilla bow does, I have tried searching for similar topics but they are outdated, any help with getting this to work in 1.6.2?

 

Ethyl

Link to comment
Share on other sites

I have created an IItemRenderer Class using some older topics, however I'm stuck with the following section:

 

 

private void renderItem(EntityLiving par1EntityLiving, ItemStack par2ItemStack, int par3) {
	Icon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3);

        if (icon == null)
        {
            return;
        }

        if (par2ItemStack.getItemSpriteNumber() == 0)
        {
            this.mc.renderEngine.bindTexture("/terrain.png");
        }
        else
        {
            this.mc.renderEngine.bindTexture("/gui/items.png");
        }

        Tessellator tessellator = Tessellator.instance;
        float f = icon.getMinU();
        float f1 = icon.getMaxU();
        float f2 = icon.getMinV();
        float f3 = icon.getMaxV();
        float f4 = 0.0F;
        float f5 = 0.3F;
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glTranslatef(-f4, -f5, 0.0F);
        float f6 = 1.5F;
        GL11.glScalef(f6, f6, f6);
        GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
        GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
        ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(), 0.0625F);

        if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0)
        {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            this.mc.renderEngine.bindTexture("%blur%/misc/glint.png");
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f7 = 0.76F;
            GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f8 = 0.125F;
            GL11.glScalef(f8, f8, f8);
            float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f9, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f8, f8, f8);
            f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f9, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }

 

 

The renderEngine.bindTexture is throwing an error as well as the icon.getSheetWidth() and icon.getSheetHeight(), I'm assuming this is from before the texture changes since it refers to terrain.png, how do I fix this for 1.6.2? also which textures do I now need to reference instead of the "terrain.png" and the "/gui/items.png"?

 

If this has already been answered elsewhere could you point me in the right direction?

 

 

Link to comment
Share on other sites

yeah in 1.6.2 you need to use ResourceLocation

and call a method from the renderEngine which use that (cant remember the exact name since its like func_xxxx_a(ResourceLocation))

 

beside that you shouldnt need getSheetWidth as getMinU getMaxU getMinV getMaxV should be enough for every needs

 

also, you probably dont need getMin/Max/U/V if you use ResourceLocation instead of the standard iconsheet

 

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I am now using the following in the place of the bindTexture:

 

this.mc.renderEngine.func_110577_a(new ResourceLocation("/assets/MOD/textures/model/TEXTURE.png"));

 

however I am unsure what exactly I need to point the file path towards? Also what is the following line of code in reference to?

 

this.mc.renderEngine.bindTexture("%blur%/misc/glint.png");

Link to comment
Share on other sites

as to where to point the file, theres a tutorial on the wiki about how to properlly setup images in your folders and all that

 

this.mc.renderEngine.bindTexture("%blur%/misc/glint.png");

thsi is 1.5.2 code and basicly points to a file called glint.png in the folder misc somewhere, not sure exactly what it is

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.

Announcements



×
×
  • Create New...

Important Information

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