Jump to content

Recommended Posts

Posted (edited)

Hello all,

I have had a concept for a large mod that I want to make which has a variety of features from spicing up core animations of the game to changing the way certain actions work including weapon and tool swings. While changing those actions is something I also need to figure out, I want to focus on changing the animations first. 

 

For some background, while I don't have much experience modding Minecraft, I have a strong background in Java specifically, and as long as I have an explanation to the function of some non intuitive bits of code, I have no problem understanding Minecrafts code. 

 

I was pointed to an older forum post in the Minecraft Mod Development discord: 

 

And while it makes sense, there are a couple of questions about it that I have regarding it, as well as if it still works. 

As a test, I want to create a custom player that does everything the same as the original player. For this, I plan to make a custom Player renderer and model if need be which perform the exact same function. I have found that I can hook into the pre render event for the player, and cancel its rendering. This noticeably makes the player invisible. My goal before changing animations as I mentioned is to make the player appear using my custom renderer, and then start making changes. I made a custom renderer and copied the code from PlayerRenderer, except for some of the render method, which I commented out for now(see below). 

 

public void render(AbstractClientPlayerEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
        this.setModelVisibilities(entityIn);
        //TODO - replace the rendering code with custom stuff
        //if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(entityIn, this, partialTicks, matrixStackIn, bufferIn, packedLightIn))) return;
        //super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
        //net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(entityIn, this, partialTicks, matrixStackIn, bufferIn, packedLightIn));
    }

 

Looking at the code above, I can see the render function I would need to change, but the event posts pose a problem, namely that the this reference is no longer a playerrenderer, and so it will not compile. I have toyed around with passing the original renderer to my custom renderer to use its reference somehow, which leads into my questions(In order of priority).

 

1. If the above forum is no longer usable, or if my code is not on the right track, what resources can I use to get onto the right track? Basically what should I be doing if not this?

2. How, where, and when do I initialize this? It requires a render manager, and a boolean for using small arms. I dont know how, where, or when the original PlayerRenderer is initialized, so I am not sure how to initialize this one. 

--EDIT--

2.5. How would I get started on writing the code to render the custom model in the render function, and how can I use the event bus in this case to post the events?

--END EDIT--

3. Given these steps, do I also need to create a custom model to change the animations of the player? How would I go about changing the animations? I think I have seen the code in the PlayerModel's setRotationAngles method, but I am not sure if that is the code and I still dont quite get how it achieves the animations that way. 

4. Assuming that I have been successful in creating custom animations for existing actions, what is the difficulty/possibility of changing existing actions and making new animations for them? As an example, changing the speed of pickaxe swings while increasing the amount of damage to the block each swing, or changing the swing speed of a sword, and depending on the swing increasing delay(combo attacks)? 

 

My first priority is questions 1 and 2. As far as I know, I absolutely cannot proceed until I have figured those out, which I have not been able to. 3 Is also important but I may be able to figure out myself just by messing around with things and some creative thinking. 4 comes after everything else and isnt a priority for this forum, but I am tossing it around in case anyone has it on the top of their head.

 

I can answer any questions if I wasn't clear on something, thanks in advance!

Edited by MickeyD3557
Forgot something.
  • 2 weeks later...
Posted

After doing some more work on this, I have found some solutions to most of these problems. Regarding 1 and 2, what I ultimately did was create a custom renderer which initialized itself based on information from the original player renderer. I store it as a singleton in the mod class, but its probably possible to use reflection to overwrite the original renderer in the render manager. While I havent done 2.5 yet, it probably isnt that bad. The model doesnt need much of anything for initialization, so making a new one and using it should not be very hard. It updates itself during the render function of the renderer, so modifying it shouldnt be tied to any events. Regarding 3, I still need to look at it a bit more, but it appears that that method is the right place to look when making new animations. Lastly for 4, check out this forum to see a bit more on that: https://forums.minecraftforge.net/topic/86774-1152-custom-player-entity/?tab=comments#comment-407517

 

Hopefully this information helps anyone who has a similar question for modifying the player.

 

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

    • Hey there! I removed Bobby as Pyralis suggested and found that I still had that and a another closely related bug (or same bug, different presentation) wherein a torch only illuminates its own block and gets smoothed 1 block out, then gone.   After comparing your modlist to mine (I'm on fabric, also 1.20.1) I found we had 2 mods with the same versions. Mine || Yours Bobby-5.0.1.jar ||bobby-1.20.1_v5.0.1.jar ImmediatelyFast-Fabric-1.2.17+1.20.4.jar || ImmediatelyFast-Forge-1.2.17+1.20.4.jar Removing ImmediatelyFast.. immediately (😉) seems to have fixed the issue. Since it's client only- no new world needed either! To note, I also removed all mods related to or containing direct requirements for Sodium, Indium and Iris which may have played a role, I did not test with re-adding.
    • For anyone still looking for the equivalent for 1.19.2+, the render type should be set for the model. In datagen, this can be done by using ModelBuilder::renderType, otherwise just add the line directly to the json file. As for the validity of this question, the idiomatic solution is presented nowhere online; ModelBuilder::renderType is never addressed when discussing block render types meaning that the solution I have provided is the first mentioned usage. Furthermore, there are no external references to this function meaning that to discover its existence requires a deep search through Forge's code. Therefore it is not only understandable but expected that most beginner modders would struggle to find this function given the already poor documentation of Forge's API.
    • Same issue without voicechat?
    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
  • Topics

×
×
  • Create New...

Important Information

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