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!