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



×
×
  • Create New...

Important Information

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