Jump to content

Recommended Posts

Posted

Hello modders! I need to set (override defaults with) custom skin (or model) for player with my mod.

I can't find anything about changing player model with Forge and player rendering events for Minecraft 1.12.2.

(What i found didn't work for me)

And so, how can i do that?
Thank you for future answers!

p.s sry for my bad english. i'm stupid 14-yo from russia

Posted
50 minutes ago, diesieben07 said:

You can subscribe to RenderPlayerEvent.Pre, cancel it and do your own rendering.

Can you explain more about it?
It will be good if you give me code examples (Sry i am noob)

Posted

Okay i found out how fire up and cancel events. I need to change entity's texture.

I wrote code below but it just makes player model invisible, what am i doing wrong?

@SubscribeEvent
public void onPlayerRenderEvent(RenderPlayerEvent.Pre event){
    event.setCanceled(true);
    ResourceLocation texture = new ResourceLocation("rppassport", "textures/player/male.png");
    event.getRenderer().bindTexture(texture);



}
1 hour ago, diesieben07 said:

You can subscribe to RenderPlayerEvent.Pre, cancel it and do your own rendering.

 

Posted
1 hour ago, diesieben07 said:

When you cancel the event you disable the complete player rendering. You need to do it completely manually. There is no easy hook to just change the texture alone.

How can i do that? Or where i can find manual about that?

Posted (edited)
11 minutes ago, diesieben07 said:

There is no manual.

You need to do your own research by looking at the code and figuring it out.

Where i can find that code? i'm newbie and this is my first mod. Do you know something about it?

Edited by andreyshtern
Posted

I readed some code in net.minecraft and wrote that:
 

@SubscribeEvent
public void onPlayerRenderEvent(RenderPlayerEvent.Pre event){
    event.setCanceled(true);
    ResourceLocation texture = new ResourceLocation("rppassport", "textures/player/male.png");
    event.getRenderer().bindTexture(texture);
    event.getRenderer().doRender((AbstractClientPlayer) event.getEntityPlayer(), event.getX(), event.getY(), event.getZ(), event.getEntity().rotationYaw, event.getPartialRenderTick());


}

 

And that error shows in runtime:

[13:55:53] [Client thread/ERROR] [FML]: Index: 1 Listeners:
[13:55:53] [Client thread/ERROR] [FML]: 0: NORMAL
[13:55:53] [Client thread/ERROR] [FML]: 1: ASM: com.andry.rppassport.RenderHandler@6145981c onPlayerRenderEvent(Lnet/minecraftforge/client/event/RenderPlayerEvent$Pre;)V
[13:55:53] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.RenderPlayerEvent$Pre@35cafcb5:
java.lang.StackOverflowError: null
many text...


Exception fires at:

event.getRenderer().doRender((AbstractClientPlayer)event.getEntityPlayer(),event.getX(),event.getY(),event.getZ(),event.getEntity().rotationYaw,event.getPartialRenderTick());


What am i doing wrong?

Posted
On 8/2/2019 at 2:31 PM, diesieben07 said:

You are telling Minecraft to render a player. Which fires the RenderPlayerEvent (because a player is being rendered). That calls your event subscriber. Which tells Minecraft to render a player again. Which fires the RenderPlayerEvent...

Eventually Java gives up and says nope.

I'm so sorry, but i spent few days for research and i can't find anything, can you help me with render?
I just need Vanilla's RenderPlayer and player skin change. What i need to do?

  • 5 months later...
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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