Jump to content

Recommended Posts

Posted

Hello,

I am working on a mod in which I would like to add new animations to the player (ex: push a button to rotate the arm up for 1 second). I have spent hours upon hours attempting to get to a point where I am able to control the parts of the character model, but have not had any success.

In my current approach, I have created an ExpressivePlayerModel class which extends PlayerModel. I can manipulate the parts of the player (ModelPart) such as "head," "rightArm," etc. from within this class. Basically what I think I want to do is replace PlayerModel with ExpressivePlayerModel. If I were able to simply change the Minecraft source code, I think this would be solved by changing "PlayerModel" to "ExpressivePlayerModel" in the constructor of PlayerRenderer, but obviously I can not do this.

Based on a few older posts I found on related topics, I think the correct way to go about this is using the RenderPlayerEvent.Pre event. This is where I've been stuck trying different things out for hours with no luck. I tried way too many things to list out here, most recently of which is using an access transformer to make "model" in LivingEntityRenderer public, then in the event do-

event.getRenderer.model = new ExpressivePlayerModel(p_174557_.bakeLayer(p_174558_ ? ModelLayers.PLAYER_SLIM : ModelLayers.PLAYER), p_174558_)

-but I can not even get that to work because I can't figure out how I would get p_174557_ and p_174558_.

One last note, this mod is just for a school project, so I don't care if I have to do anything that would not be compatible with other mods and/or have issues with client/server stuff. This won't be used anywhere else, I just need the character to animate on my screen.

Is anything that I've been doing on the right track? And where should I go from here?

Thanks!

Posted (edited)

I'm not immediately sure, as I haven't done anything like that before, but it seems to me that you're potentially answering your own question: 

  On 11/10/2022 at 9:59 PM, duckynatalie said:

If I were able to simply change the Minecraft source code, I think this would be solved by changing "PlayerModel" to "ExpressivePlayerModel" in the constructor of PlayerRenderer, but obviously I can not do this.

Expand  

Create a new player renderer that extends PlayerRenderer, replace the model for your own and then inside the event, cancel the current one and spawn a new event in it's place. Using your own renderer as the PlayerRenderer perhaps?

The pre event you subscribe to needs the following:

        public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
            super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight);
        }

send everything through, most of which you can steal from the original event before the cancellation, and fire away... I hope? 

 

Oh yeah, you can fire an event like this: 

net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(player, renderer, partialTick, poseStack, multiBufferSource, packedLight));



Again, I'm not sure if this is recommended, safe or anything, but it's where I'd start

Edited by MistaOmega
added potential way to fire event
Posted

Thanks for the response.

What you are describing is actually one of the ways I was trying it before. For the most part, I was able to create a new player renderer that extends PlayerRenderer (ExpressivePlayerRenderer), replace the model with my own, and cancel the event.

@SubscribeEvent
    public static void testAnimationEvent(final RenderPlayerEvent.Pre event) {
        
        EntityRendererProvider.Context context = What do I put right here?;
        boolean isSlim = What do I put right here?;
        ExpressivePlayerRenderer renderer = new ExpressivePlayerRenderer(context, isSlim);
        renderer.setToExpressiveModel(); // Method to replace PlayerModel with ExpressivePlayerModel

        Player player = event.getEntity();
        float partialTick = event.getPartialTick();
        PoseStack poseStack = event.getPoseStack();
        MultiBufferSource multiBufferSource = event.getMultiBufferSource();
        int packedLight = event.getPackedLight();

        event.setCanceled(true);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(player, renderer, partialTick, poseStack, multiBufferSource, packedLight));

    }

However, I can not for the life of me figure out how to initialize context and isSlim. I looked at the code where the PlayerRenderer constructor is used and tried to replicate it but I am still at a total loss for this part. I need that EntityRendererProvider.Context and the boolean to pass into super() in the constructor of ExpressivePlayerRenderer.

Also - I'm pretty new to using events - wouldn't this just repeat forever since whenever there is a RenderPlayerEvent.Pre it just fires another RenderPlayerEvent.Pre?

Does what I have here look good and how would I go about initializing those?

Posted

Getting hold of that context, I'm not sure, I'd have to look way deeper into it, stopping the infinite loop should be as simple as doing an if to check if the renderer is an instanceof ExpressivePlayerRenderer, if it is, don't cancel

Posted

I have spent quite a few more hours digging into this, and I can not figure out how to get the context. Every method I try to solve this problem I end up stuck at the same spot - I do not have the EntityRendererProvider.Context. Does anyone have any suggestions?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My name is Clara Bennett, and I almost let cryptocurrency destroy me.  Two years ago, after selling my green e-commerce startup, I plunged headfirst into the crypto world. yield farming , I was all in. I believed I wasn’t just investing; I was participating in the next great technological revolution. Within months, my portfolio skyrocketed to $200,000. I even started sketching ideas for a blockchain-based microloan platform to empower small entrepreneurs around the world. Crypto felt like pure freedom and limitless potential. I thought I was untouchable. I thought wrong. It happened through a single email. It looked like a standard security update from my wallet provider polished, routine, and harmless. I interacted with it briefly, thinking it was legitimate. Hours later, I checked my account and realized my entire wallet had been drained. Every token, every coin, gone. I sat there in disbelief, replaying the moment over and over. I had built my career on being cautious with technology, yet somehow, I had still been compromised. The blockchain’s promise of "irreversible transactions" now felt like a cruel joke  .Devastated and desperate, I scoured forums for solutions. Most people told me there was no hope once crypto is gone, it’s gone. Still, I refused to give up. That’s when I stumbled across FUNDS RETRIEVER ENGINEER . I decided to reach out. From the beginning, they were empathetic, and honest about the challenges. They explained their process step-by-step, focusing on tracing transactions, tracking down phishing operators, and leveraging advanced blockchain analytics. It wasn't an overnight fix. It took weeks of meticulous investigation, technical recovery work, and legal coordination .But in the end, their persistence paid off. FUNDS RETRIEVER ENGINEER  was able to trace the stolen funds across multiple wallets and exchanges. Through a combination of technical expertise and strategic action, they managed to recover the full amount I had lost. Today, my crypto portfolio is intact once again. More importantly, I’ve regained my confidence though I am now much wiser and far more cautious. I learned the hard way that while crypto offers incredible opportunities, it also demands extreme vigilance. Thanks to FUNDS RETRIEVER ENGINEER , I recovered my lost funds and  also reclaimed my future in the digital economy. For help  W H A T S A P P:  +1  8  0 2 9 5 2 3 4 7 0 E   m  a I L       F U N D S R  E T R  I E V E R  [@]  E  N  G  I  N  E  E  R.  C  O  M
    • 1. Did you try to remove your system cache or something? 2. Also check jar hash before installing (if it's ok): sha1sum jar_name.jar > jar_name.jar.sha1 sha1sum -c jar_name.jar.sha1 Do this a few times with some interval. This can find out if your hash can be different somehow (garbage files inside).  Also try using sha224sum / sha256sum / sha384sum / sha512sum / shasum. And do you have any debug mode during installation?   UPDATED: and it can be just fixing by chmod'ing jar file. Check its -lZ 
    • I get these errors when trying to install any version (this ones for 47.3.33 for instance):  Processor failed, invalid outputs:     /home/user/.local/share/FreesmLauncher/instances/1.20.1/minecraft/libraries/net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-slim.jar       Expected: 9e06bdd77ca6d95b2cced0bf372245f753eeb16a       Actual:   f1e5a0cc3c9f7c58f26524a43c5badc06ca0bac4     /home/user/.local/share/FreesmLauncher/instances/1.20.1/minecraft/libraries/net/minecraft/server/1.20.1-20230612.114412/server-1.20.1-20230612.114412-extra.jar       Expected: 13522e3278befd103064d91a199451df4cd2633f       Actual:   eb1dafb7bee2ace5d55d90b65e73c2196b1991f3 I've tried sklauncher and freesm launcher and they throw the same error, tried installing it with the official forge installer too but same error. Also tried different versions of java: 17, 21, 24. Forge for previous versions install fine, I'm on Linux CachyOS.  
    • I am trying to get a server up and running for Tekxit 3.14 Pi (forge 1.12.2-14.23.5.2860) however I am not getting anywhere. I have specially downloaded this from the tekxit website  - Tekxit by SlayerTheChikken (the link transforms into that sorry)  version 1.0.980 Upon following said instructions I run serverwindows as admin and the only popup I get in the cmd prompt is  No files are added or modified. Eula is set to true by default. I can find no error logs here. reinstalled and installed java 8. also tried jdk 8 as well on top. No luck. Anyone know where I'm going wrong? 
  • Topics

×
×
  • Create New...

Important Information

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