Jump to content

Recommended Posts

Posted
package net.arsenalnetwork.arsenalmod.client.render.item;

import net.arsenalnetwork.arsenalmod.item.tools.ItemMelee;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL12;

public class RenderItem extends TileEntityItemStackRenderer
{

    @Override
    public void renderByItem(ItemStack itemStackIn) {
        Minecraft mc = Minecraft.getMinecraft();

        final EntityPlayer player = Minecraft.getMinecraft().player;

        if (itemStackIn != null)
        {
            GlStateManager.pushMatrix();

            if (itemStackIn.getItem() instanceof ItemMelee)
            {
                if (!player.isSwingInProgress)
                {
                    /**
                     * For the right hand
                     */
                    GlStateManager.pushMatrix();
                    GlStateManager.glEnableClientState(GL12.GL_RESCALE_NORMAL);
                    mc.getTextureManager().bindTexture(((EntityPlayerSP) player).getLocationSkin());
                    GlStateManager.translate(1F, 1F, 0F);
                    GlStateManager.rotate(125.0F, 0.0F, 0.0F, 1.0F);
                    GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
                    GlStateManager.scale(1.0F, 1.8F, 1.0F);
                    GlStateManager.translate(0.19F, -1.14F, 0.3F);
                    Render render = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(mc.player);
                    mc.getRenderManager().getEntityRenderObject(mc.player);
                    RenderPlayer renderPlayer = (RenderPlayer)render;
                    float f11 = 1.0F;
                    GlStateManager.scale(f11, f11, f11);
                    renderPlayer.renderRightArm(mc.player);
                    GlStateManager.popMatrix();
                }

                this.renderItemThirdPerson((EntityPlayer) player, itemStackIn);

                GlStateManager.popMatrix();

                return;
            }
        }
    }

    public void renderItemThirdPerson(EntityPlayer player, ItemStack itemStack)
    {
        GlStateManager.translate(0.0F, 0.0F, -0.05F);

        GlStateManager.rotate(180, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-15, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(78, 0.0F, 1.0F, 0.0F);

        GlStateManager.translate(0.0F, 0.7F, 0.25F);

        GlStateManager.rotate(15, 0.0F, 0.0F, 1.0F);

        double scale = 1.2D;
        GlStateManager.scale(scale, scale, scale);
    }
}
Posted
1 minute ago, V0idWa1k3r said:

renderByItem. The one that takes in partialTicks aswell as the ItemStack but both work.

You are not actually rendering the item in the code you've provided.

wym?

 

Posted
Just now, V0idWa1k3r said:

Apart from messing with GL matrix this

does nothing in your implementation.

So yeah 

if (itemStackIn.getItem() instanceof ItemMelee)

trying to get all the melee items that are created and render that hand. Why doesn't it work like what am i doing wrong?

Posted
5 minutes ago, FireIsH0t said:

Why doesn't it work like what am i doing wrong?

 

7 minutes ago, V0idWa1k3r said:

this

Quote

public void renderItemThirdPerson(EntityPlayer player, ItemStack itemStack)

does nothing in your implementation.

 

Also show where you assign the TEISR to your item.

 

4 minutes ago, FireIsH0t said:

1.12.2

ItemStack can't be null in 1.12.2. It can only be empty. But you already know that not to be the case if the render method is even executed. This check is pointless

Posted
1 minute ago, V0idWa1k3r said:

 

 

Also show where you assign the TEISR to your item.

 

ItemStack can't be null in 1.12.2. It can only be empty. But you already know that not to be the case if the render method is even executed. This check is pointless

@Override
public void renderByItem(ItemStack itemStackIn) {
    Minecraft mc = Minecraft.getMinecraft();

    final EntityPlayer player = Minecraft.getMinecraft().player;
    
        GlStateManager.pushMatrix();
        
        if (itemStackIn.getItem() instanceof ItemMelee)
        {
            if (!player.isSwingInProgress)
            {
                /**
                 * For the right hand
                 */
                GlStateManager.pushMatrix();
                GlStateManager.glEnableClientState(GL12.GL_RESCALE_NORMAL);
                mc.getTextureManager().bindTexture(((EntityPlayerSP) player).getLocationSkin());
                GlStateManager.translate(1F, 1F, 0F);
                GlStateManager.rotate(125.0F, 0.0F, 0.0F, 1.0F);
                GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
                GlStateManager.scale(1.0F, 1.8F, 1.0F);
                GlStateManager.translate(0.19F, -1.14F, 0.3F);
                Render render = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(mc.player);
                mc.getRenderManager().getEntityRenderObject(mc.player);
                RenderPlayer renderPlayer = (RenderPlayer)render;
                float f11 = 1.0F;
                GlStateManager.scale(f11, f11, f11);
                renderPlayer.renderRightArm(mc.player);
                GlStateManager.popMatrix();
            }

            this.renderItemThirdPerson((EntityPlayer) player, itemStackIn);

            GlStateManager.popMatrix();

            return;
    }
}

 

Removed that null thing "Also show where you assign the TEISR to your item." ?

Posted
4 minutes ago, FireIsH0t said:

"Also show where you assign the TEISR to your item." ?

Exactly as it sounds. a TEISR needs to be assigned to the item using Item#setTileEntityItemStackRenderer(one of the options anyway). Code isn't magic, it's not going to just work because you've made some classes.

Posted
@SideOnly(Side.CLIENT)
@Nullable
private net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr;

@SideOnly(Side.CLIENT)
public void setTileEntityItemStackRenderer(@Nullable net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr)
{
    this.teisr = teisr;
}

this right?

Posted
package net.arsenalnetwork.arsenalmod.client.render.item;

import net.arsenalnetwork.arsenalmod.item.tools.ItemMelee;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL12;

import javax.annotation.Nullable;

public class RenderItem extends TileEntityItemStackRenderer
{

    @Override
    public void renderByItem(ItemStack itemStackIn) {
        Minecraft mc = Minecraft.getMinecraft();

        final EntityPlayer player = Minecraft.getMinecraft().player;

            GlStateManager.pushMatrix();

            if (itemStackIn.getItem() instanceof ItemMelee)
            {
                if (!player.isSwingInProgress)
                {
                    /**
                     * For the right hand
                     */
                    GlStateManager.pushMatrix();
                    GlStateManager.glEnableClientState(GL12.GL_RESCALE_NORMAL);
                    mc.getTextureManager().bindTexture(((EntityPlayerSP) player).getLocationSkin());
                    GlStateManager.translate(1F, 1F, 0F);
                    GlStateManager.rotate(125.0F, 0.0F, 0.0F, 1.0F);
                    GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
                    GlStateManager.scale(1.0F, 1.8F, 1.0F);
                    GlStateManager.translate(0.19F, -1.14F, 0.3F);
                    Render render = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(mc.player);
                    mc.getRenderManager().getEntityRenderObject(mc.player);
                    RenderPlayer renderPlayer = (RenderPlayer)render;
                    float f11 = 1.0F;
                    GlStateManager.scale(f11, f11, f11);
                    renderPlayer.renderRightArm(mc.player);
                    GlStateManager.popMatrix();
                }

                this.renderItemThirdPerson((EntityPlayer) player, itemStackIn);

                GlStateManager.popMatrix();

                return;
        }
    }

    public void renderItemThirdPerson(EntityPlayer player, ItemStack itemStack)
    {
        GlStateManager.translate(0.0F, 0.0F, -0.05F);

        GlStateManager.rotate(180, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-15, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(78, 0.0F, 1.0F, 0.0F);

        GlStateManager.translate(0.0F, 0.7F, 0.25F);

        GlStateManager.rotate(15, 0.0F, 0.0F, 1.0F);

        double scale = 1.2D;
        GlStateManager.scale(scale, scale, scale);
    }

    @SideOnly(Side.CLIENT)
    @Nullable
    private net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr;

    @SideOnly(Side.CLIENT)
    public void setTileEntityItemStackRenderer(@Nullable net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr)
    {
        this.teisr = teisr;
    }
}

 

ok boom.

Posted

I didn't tell you "Oh, see these methods in the Item class? Yeah, copy them into your TEISR class, it will magically find your class by these methods and just work". I told you

11 minutes ago, V0idWa1k3r said:

a TEISR needs to be assigned to the item using Item#setTileEntityItemStackRenderer(one of the options anyway). Code isn't magic, it's not going to just work because you've made some classes.

This means "invoke Item#setTileEntityItemStackRenderer to bind your TEISR to the item". No, don't invoke it in your TEISR. Do it somewhere that makes sense, somewhere where you know it will be executed by the game. Like in your client proxy.

Posted

What’s wrong with just using a JSON model?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
5 minutes ago, Cadiboo said:

What’s wrong with just using a JSON model?

I don't think you can draw a player's hand with a json model since, well, the game renders the quads you provide with the default texture atlas. The player's hand on the other hand uses the player's skin as it's texture, which is a separate texture object.

I mean, I can kinda see how you might be able to do it with a custom IBakedModel but it would be breaking multiple things and borderline a dirty hack. I think that a TEISR is a solution here, but feel free to disagree.

Posted
5 minutes ago, V0idWa1k3r said:

I don't think you can draw a player's hand with a json model since, well, the game renders the quads you provide with the default texture atlas. The player's hand on the other hand uses the player's skin as it's texture, which is a separate texture object.

I mean, I can kinda see how you might be able to do it with a custom IBakedModel but it would be breaking multiple things and borderline a dirty hack. I think that a TEISR is a solution here, but feel free to disagree.

I am a bit confused now lol

Posted

Alright Update:

 

New RenderBaseBall Class: https://hastebin.com/yatirebome.java

 

And have this in my ClientEventSubscriber:

@SubscribeEvent
public static void onRegisterModelsEvent(final ModelRegistryEvent event) {

    ModItems.BASEBALL_BAT.setTileEntityItemStackRenderer(new RenderBaseBallBat());

 

but the hand still doesnt render onto the baseball bat item

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.