Jump to content

Recommended Posts

Posted (edited)

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
Posted
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!

Posted

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
Posted (edited)
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
Posted
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.

 

 

Posted
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! :)

Posted

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/

 

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I've been having trouble trying to use forge as it shows a black screen when I open the game, but I can still interact with it and hear the music.  I've done all of the step by steps and most common fixes like updating drivers, keeping up to date with Java, deleting and reinstalling minecraft, restarting my computer MANY times, even smaller things like splash.properties (I didn't have that file so I added it and set it to false thinking it would do something, definitely not) and making sure to prioritize my rtx 3070 in the settings but with no luck. Minecraft works as intended when I uninstall forge and I also don't have any mods currently, it just gives me this issue when I install forge. I also increased the ram usage, made sure my hardware isn't full or anything, and even changed the resolution in hopes it would fix things. I checked my antivirus and firewall but that isn't the issue either. Trust me, I've done everything I can think of. For some reason the black screen does flicker a little into the main menu, but obviously unplayable. I couldn't even make my way to the settings with how little it flickered. I'm not sure if it flickered randomly or if it was because I was messing around moving and clicking a bunch, I didn't really test it that much.  
    • I've had a really weird issue recently,  I wanted to add the Depper and Darker mod on my dedicated server (MC 1.21 with Fabric 0.16.9, hosted on nitroserv.com) but whenever I do add the mod the sever stops doing anything after listing the mods, and I get no crash or error or anything, just a stuck server. Here's a normal log of the server booting up: https://pastebin.com/JipFF2Eh and here's the log of the server doing the weird thing: https://pastebin.com/W4JBh3eX I just don't understand it. I've tried removing other mods (somewhat randomly) but deeper and darker still breaks my server whenever I add it. NitroServ support staff is about as confused as I am and I've had no response from the Deeper and Darker support staff... Now I know this is the Forge support not the Fabric support but I'm just trying to know if anyone has any kind of idea to fix this (aside from not using the mod obviously) Also I still have a bunch of errors and warnings whenever the server does start properly, are there any of them I should be worried about?
    • Delete the config of RandomTweaker (config folder) If there is no change, remove this mod
    • Hello! So i have been trying to make a mod that adds plant fiber to minecraft 1.16.5 (i believe there are mods that add plant fiber but not for 1.16.5) but the problem is that i want to modify the loot table of grass to always drop plant fiber but also keep the vanilla drops. Most common answer i have seen is GlobalLootModifiers. But my tiny brain cant understand any tutorials. So any help is appreciated.
    • Minecraft forge 1.12.2 does not load. Here is both logs. I assume its because of a mod that i have, idk. (L521)
  • Topics

×
×
  • Create New...

Important Information

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