Jump to content

Recommended Posts

Posted

I want to make a custom first person hand model. Can anyone tell me how can I do this or give me examples of open source mods that have done this

Posted

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.

Posted (edited)
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
Posted (edited)

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
  • 1 year later...
Posted
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

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.