Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom player rendering


Spaceboy Ross
 Share

Recommended Posts

It crashed for me. GitHub: https://github.com/SpaceboyRoss01/MSGundamMod.

 

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		ResourceLocation texture = new ResourceLocation(ms.getBaseResourceLocation()+".png");
		event.getRenderer().bindTexture(texture);
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
	}
}

 

Edited by Spaceboy Ross

The official YouTuber Spaceboy Ross

Link to comment
Share on other sites

17 minutes ago, Spaceboy Ross said:

It crashed for me. GitHub: https://github.com/SpaceboyRoss01/MSGundamMod.

 


@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		ResourceLocation texture = new ResourceLocation(ms.getBaseResourceLocation()+".png");
		event.getRenderer().bindTexture(texture);
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
	}
}

 

Something is null on this line.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 minutes ago, Spaceboy Ross said:

Ok, it's no longer null but the player is still the same size and still has the same skin. How do I render the new skin and entity size?

You have to use the Pre event render it yourself and then cancel the actual rendering from happening.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 minutes ago, Spaceboy Ross said:

Ok, got the scaling to work but I cannot get the custom skin to work.

*doesn't see code* Cool

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		event.getRenderer().bindTexture(new ResourceLocation(ms.getBaseResourceLocation()+".png"));
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
		event.setCanceled(true);
	}
}

 

The official YouTuber Spaceboy Ross

Link to comment
Share on other sites

15 minutes ago, Spaceboy Ross said:

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		event.getRenderer().bindTexture(new ResourceLocation(ms.getBaseResourceLocation()+".png"));
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
		event.setCanceled(true);
	}
}

 

You did one of the three things I said.

 

31 minutes ago, Animefan8888 said:

You have to use the Pre event render it yourself and then cancel the actual rendering from happening.

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

It's still not working.

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
		event.getRenderer().bindTexture(new ResourceLocation(ms.getBaseResourceLocation()+".png"));
		event.getRenderer().doRender((AbstractClientPlayer)player,event.getX(),event.getY(),event.getZ(),player.cameraYaw,event.getPartialRenderTick());
		event.setCanceled(true);
	}
}

 

The official YouTuber Spaceboy Ross

Link to comment
Share on other sites

1 hour ago, Spaceboy Ross said:

It's still not working.

Define not working. 

  • Confused 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

A fix to what?

What's broken?

 

You haven't given us any information about how to diagnose what's wrong. All you've said is "doctor, it hurts."

  • Sad 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The game freezes when my code runs.

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		GL11.glScalef(msmob.scale,msmob.scale,msmob.scale);
		event.getRenderer().bindTexture(new ResourceLocation(ms.getBaseResourceLocation()+".png"));
		event.getRenderer().doRender((AbstractClientPlayer)player,event.getX(),event.getY(),event.getZ(),player.cameraYaw,event.getPartialRenderTick());
		event.setCanceled(true);
	}
}

 

The official YouTuber Spaceboy Ross

Link to comment
Share on other sites

5 minutes ago, Spaceboy Ross said:

The game freezes when my code runs.

You're causing an infinite loop of code by calling event.getRenderer().doRender.

Edited by Animefan8888
Typo

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, Spaceboy Ross said:

Well, how do I actually render the player?

 

2 hours ago, Animefan8888 said:

You have to use the Pre event render it yourself and then cancel the actual rendering from happening.

Write the code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 minute ago, Spaceboy Ross said:

What does rendering it mean? I've canceled the game from rendering the player. 

You want to change the texture for the player and edit the scale. Ok. Editing the scale is easy enough as you already found out. But you cant bind the texture you want because it is bound in the vanilla code you dont have access to. So you have to cancel the vanilla rendering which you have done and then render the player yourself with your own code, using your texture.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

From what I can see and understand, you are trying to use the default Minecraft player model  as your base model, but you are using the default renderer to do it. You can use the MC player model, but you would need to copy it and change the relevant parts, such as what texture is bound to the gl, scale etc.  And then render that instead. The renderer is connected to the default mc model which also hard codes it's texture.

 

That's the easy way, or you can just code the model in yourself.

Edited by ZDoctor
Added
Link to comment
Share on other sites

It doesn't render correctly and it renders upsidedown. GitHub: https://github.com/SpaceboyRoss01/MSGundamMod

To recreate the bug, right click on an entity called RX-78-2 Gundam.

@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
	EntityPlayer player = event.getEntityPlayer();
	IHumanCapability nt = Human.getHuman(player);
	MobileSuit.MSMob msmob = nt.getMS();
	if(msmob != null) {
		MobileSuit ms = msmob.getMSRegistryEntry();
		event.getRenderer().bindTexture(new ResourceLocation(ms.getBaseResourceLocation()+".png"));
		event.setCanceled(true);
		GlStateManager.pushMatrix();
		event.getRenderer().getMainModel().bipedHead.render(0.0625F*msmob.scale);
		event.getRenderer().getMainModel().bipedBody.render(0.0625F*msmob.scale);
		event.getRenderer().getMainModel().bipedLeftLeg.render(0.0625F*msmob.scale);
		event.getRenderer().getMainModel().bipedRightLeg.render(0.0625F*msmob.scale);
		event.getRenderer().getMainModel().bipedLeftArm.render(0.0625F*msmob.scale);
		event.getRenderer().getMainModel().bipedRightArm.render(0.0625F*msmob.scale);
		GlStateManager.popMatrix();
	}
}

 

The official YouTuber Spaceboy Ross

Link to comment
Share on other sites

That's something I never understood as to why (but never bothered to look into it too hard) it happens, but what I do is just Rotate the gl 180 and that should fix it. I assume somewhere in the vanilla code something does that, but I haven't found it.

Edited by ZDoctor
Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.