Jump to content

How to make a custom first person hand model


Jetug

Recommended Posts

On 3/26/2023 at 6:07 PM, ChampionAsh5357 said:

I would look at PlayerRenderer#renderHand to see how a hand is rendered normally. Then it's just creating the java model and replacing it via RenderArmEvent and canceling it. If you also want to replace the rendering of whatever is in the hand as well, use RenderHandEvent instead.

I wrote this code and my hand model renders but doesn't follow camera rotation(https://imgur.com/1pgyxUl). I took the PoseStack installation code from GameRenderer#renderLeve.

   @OnlyIn(Dist.CLIENT)
    @SubscribeEvent()
    public static void onRenderHand(RenderArmEvent event)
    {
        if(handRenderer == null)
            handRenderer = new CustomHandRenderer();

        var minecraft = Minecraft.getInstance();
        var camera = minecraft.gameRenderer.getMainCamera();
        var poseStack = new PoseStack();

        poseStack.mulPose(Vector3f.XP.rotationDegrees(camera.getXRot()));
        poseStack.mulPose(Vector3f.YP.rotationDegrees(camera.getYRot() + 180.0F));
        applyItemArmTransform(poseStack, HumanoidArm.RIGHT, 1);

        handRenderer.render(
                null,
                poseStack,
                event.getMultiBufferSource(),
                event.getPackedLight());
        event.setCanceled(true);
    }

For rendering I use GeckoLib

Edited by Jetug
Link to comment
Share on other sites

Turns out it was much easier 

    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent()
    public static void onRenderHand(RenderArmEvent event)
    {
        if(handRenderer == null)
            handRenderer = new CustomHandRenderer();

        var poseStack = new PoseStack();
        poseStack.translate(0.5, -0.5, -0.6);

        handRenderer.render(
                null,
                poseStack,
                event.getMultiBufferSource(),
                event.getPackedLight());
        event.setCanceled(true);
    }

https://i.imgur.com/tHo5mqo.png

Edited by Jetug
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 3/30/2023 at 9:24 AM, Jetug said:

Turns out it was much easier 

    @OnlyIn(Dist.CLIENT)
    @SubscribeEvent()
    public static void onRenderHand(RenderArmEvent event)
    {
        if(handRenderer == null)
            handRenderer = new CustomHandRenderer();

        var poseStack = new PoseStack();
        poseStack.translate(0.5, -0.5, -0.6);

        handRenderer.render(
                null,
                poseStack,
                event.getMultiBufferSource(),
                event.getPackedLight());
        event.setCanceled(true);
    }

https://i.imgur.com/tHo5mqo.png

whats your "CustomHandRenderer"?

  • Like 1
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.



×
×
  • Create New...

Important Information

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