Jump to content

[1.12.2] Player replace ModelRenderer


ricepuffz

Recommended Posts

Hi, I'm trying to manipulate the player model yet again, but now it's in 1.12.2.

This time I wanted to try to replace the player's ModelBiped ModelRenderers, so I did. I replaced only the bipedBody variable but now the player's body part is not being rendered at all. From what I've seen the ModelRenderer contains no methods that actually render the model, which is why I thought that I could just replace it with a different model and still have it render just as before. Here is the code I have so far:

	private boolean initialized = false;
	private static final ResourceLocation rl = new ResourceLocation("examplemod", "models/boxbody.png");
	
	ModelBase bodyModel = null;
	ModelRenderer body = null;
	
	@SubscribeEvent
	public void RenderPlayerEvent(RenderPlayerEvent.Pre event)
	{
		if (!initialized)
		{
			bodyModel = new ModelBody();
			body = new ModelRenderer(bodyModel);
			event.getRenderer().getMainModel().bipedBody = body;
			initialized = true;
		}
		
		Minecraft.getMinecraft().renderEngine.bindTexture(rl);
	}
public class ModelBody extends ModelBase
{
	private final ModelRenderer body;
	
	public ModelBody()
	{
		textureWidth = 64;
		textureHeight = 32;
		
		
		body = new ModelRenderer(this, 0, 0);
		body.setRotationPoint(0.0F, 0.0F, 0.0F);
		body.addBox(-8.0F, -8.0F, -8.0F, 16, 16, 16, 0.0F);
	}
	
	@Override
	public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
	{
		body.render(scale);
	}
}

 

Any help or suggestions for a different approach are appreciated :)

Edited by ricepuffz
Link to comment
Share on other sites

5 hours ago, diesieben07 said:

You can't do this, the whole model needs to be rendered with just one texture.

Thanks for the info. Still, I'm not sure how to set the texture that is going to be used for the model and after having looked through several classes, including the EntityPlayer class and all its superclasses, I can't seem to find a variable that hold the ResourceLocation to the texture or anything similar. The closest thing I found was:

public ResourceLocation getEntityTexture(AbstractClientPlayer entity)
{
    return entity.getLocationSkin();
}

in the RenderPlayer class, but I'm quite sure how I would make use of that. My guess would be that I would somehow have to let AbstractClientPlayer::hasSkin always return true and let AbstractClientPlayer::getLocationSkin return the ResourceLocation of the texture I want to use.

If I'm absolutely wrong and my approach can't work at all would you mind guiding me in the right direction?

Thanks!

Link to comment
Share on other sites

That is the correct way to do it ;)

 

This is my code

 

@Mixin(value = AbstractClientPlayer.class)
public abstract class MixinAbstractClientPlayer extends MixinEntityPlayer
{
	@Shadow
	@Nullable
	protected abstract NetworkPlayerInfo getPlayerInfo();
    @Inject(method = "hasSkin", at = @At("RETURN"), cancellable = true)
	public void hasSkin(CallbackInfoReturnable<Boolean> cir)
	{
		PlayerSkin.HasSkin event = new PlayerSkin.HasSkin(getPlayerInfo(), cir.getReturnValue());
		MinecraftForge.EVENT_BUS.post(event);
		cir.setReturnValue(event.result);
	}
	
	@Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("RETURN"), cancellable = true)
	public void getSkin(CallbackInfoReturnable<ResourceLocation> cir)
	{
		PlayerSkin.GetSkin event = new PlayerSkin.GetSkin(getPlayerInfo(), cir.getReturnValue());
		MinecraftForge.EVENT_BUS.post(event);
		cir.setReturnValue(event.skinLocation);
	}
}

 

  • Thanks 1
Link to comment
Share on other sites

59 minutes ago, cookiedragon234 said:

That is the correct way to do it ;)

 

This is my code

 


@Mixin(value = AbstractClientPlayer.class)
public abstract class MixinAbstractClientPlayer extends MixinEntityPlayer
{
	@Shadow
	@Nullable
	protected abstract NetworkPlayerInfo getPlayerInfo();
    @Inject(method = "hasSkin", at = @At("RETURN"), cancellable = true)
	public void hasSkin(CallbackInfoReturnable<Boolean> cir)
	{
		PlayerSkin.HasSkin event = new PlayerSkin.HasSkin(getPlayerInfo(), cir.getReturnValue());
		MinecraftForge.EVENT_BUS.post(event);
		cir.setReturnValue(event.result);
	}
	
	@Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("RETURN"), cancellable = true)
	public void getSkin(CallbackInfoReturnable<ResourceLocation> cir)
	{
		PlayerSkin.GetSkin event = new PlayerSkin.GetSkin(getPlayerInfo(), cir.getReturnValue());
		MinecraftForge.EVENT_BUS.post(event);
		cir.setReturnValue(event.skinLocation);
	}
}

 

I'm pretty sure Mixin didn't exist in 1.12.2 though? I can't find any of the classes you specified in your code in the forge version I am using (forge-1.12.2-14.23.5.2768)

Thanks for the idea tho! I'll do some more research on modifying vanilla code tomorrow and see if I can do it myself :)

Edited by ricepuffz
Link to comment
Share on other sites

1 hour ago, ricepuffz said:

I'm pretty sure Mixin didn't exist in 1.12.2 though? I can't find any of the classes you specified in your code in the forge version I am using (forge-1.12.2-14.23.5.2768)

Thanks for the idea tho! I'll do some more research on modifying vanilla code tomorrow and see if I can do it myself :)

That is coremodding. It is not recommended on this forum. In fact, your problem does not need coremodding to solve.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

8 hours ago, DavidM said:

That is coremodding. It is not recommended on this forum. In fact, your problem does not need coremodding to solve.

Well, how would I go about achieving a different entity texture without coremodding then? As I said, I couldn't figure it out myself by looking at all the forge provided classes.

Thanks for all the information though! :)

Link to comment
Share on other sites

Okay, so since no more replies were coming in I decided to read up on the JVM architecture as well as Java bytecode and ASM and managed to create a coremod to do what I explained in a previous post of mine, which works just fine. Now I'm running into the issue of the skin not loading right, aka even with the standard player model and a skin file which is just a full on 64x64 black and white gradient with no transparent pixels the player looks black and pink like this: 

image.png.8a4875f6f4c88b963c1f1eff05f44b49.png

I am certain that it's not an issue with the bytecode manipulation itself, but more that my approach is still wrong (or that the png format is not being accepted or whatever), which is why I think that it's okay to continue this thread (correct me if this is straight up a coremodding issue, although I don't really know where else to look for help if not here). This was my last idea so I'm kind of desperate now :"

I would be more than glad if someone could help me. (Even suggestions of different approaches or hypotheses would be highly appreciated)

 

If any more information of what I've done so far is required just ask and I'll add it.

 

Also I found this thread where the exact same issue with the skin was present: https://www.minecraftforge.net/forum/topic/44152-bug-only-a-few-custom-skins-work/

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI <a href="https://imgbb.com/"><img src="https://i.ibb.co/GnjSVpx/daftar1-480x480.webp" alt="daftar1-480x480" border="0" /></a> Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit pulsa adalah situs slot deposit pulsa tanpa potongan apapun yang dijamin garansi terpercaya, dimana kamu bisa bermain slot dengan melakukan deposit pulsa dan tanpa dikenakan potongan apapun sehingga dana yang masuk ke dalam akun akan 100% utuh. Proses penarikan dana juga dijamin gampang dan tidak sulit sehingga kamu tidak perlu khawatir akan kemenangan yang akan kamu peroleh dengan sangat mudah jika bermain disini.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT PULSA TANPA POTONGAN ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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