Jump to content

[SOLVED] [1.12.2] How can I detect if the player skin type is slim or default in rendering?


Recommended Posts

Posted (edited)

I need to create a tameable mob that is a complete clone of the player and the player is the owner of it. How could I detect what the owner's skin type is in the rendering?

 

Renderer's constructor:

	public RenderShadowClone(RenderManager rendermanagerIn, boolean useSmallArms) {
		super(rendermanagerIn, new ModelPlayer(0.0F, useSmallArms), 0.5F);
	}

RenderHandler:

		RenderingRegistry.registerEntityRenderingHandler(EntityShadowClone.class, new IRenderFactory<EntityShadowClone>() {
			@Override
			public Render<? super EntityShadowClone> createRenderFor(RenderManager manager) {
				return new RenderShadowClone(manager, false);
			}
		});

 

Edited by FlashHUN
marked as solved
Posted
  On 3/26/2019 at 8:36 PM, diesieben07 said:

Render#doRender gets the entity passed in. From that you need to determine which model to render.

Expand  

So in the RenderShadowClone class it should look something like this?

public class RenderShadowClone extends RenderLiving<EntityShadowClone> {
    
	private static boolean smallArms;
	
	public RenderShadowClone(RenderManager rendermanagerIn) {
		super(rendermanagerIn, new ModelPlayer(0.0F, smallArms), 0.5F);
	}

	@Override
	public ModelPlayer getMainModel()
    {
        return (ModelPlayer)super.getMainModel();
    }

	@Override
	protected ResourceLocation getEntityTexture(EntityShadowClone entity) {
		ResourceLocation skin = null;
		if (entity.getOwner() != null) {
			skin = ((AbstractClientPlayer) entity.getOwner()).getLocationSkin();
		}
		else {
			skin = DefaultPlayerSkin.getDefaultSkinLegacy();
		}
		return skin;
	}
	
	@Override
	protected void applyRotations(EntityShadowClone entityLiving, float p_77043_2_, float rotationYaw, float partialTicks) {
		super.applyRotations(entityLiving, p_77043_2_, rotationYaw, partialTicks);
	}
	
	@Override
	public void doRender(EntityShadowClone entity, double x, double y,
			double z, float entityYaw, float partialTicks) {
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
		if (((AbstractClientPlayer) entity.getOwner()).getSkinType() == "default") {
			this.smallArms = false;
		}
		else {
			this.smallArms = true;
		}
	}
}

 

Posted
  On 3/26/2019 at 8:45 PM, diesieben07 said:
  • You cannot compare Strings using ==. Please learn basic Java.
  • Why is smallArms static?
  • smallArms is a static field, why are you accessing it using this? Your IDE should be giving you a warning about this. And again, please learn basic Java.
  • Your smallArms field does nothing. You only ever write to it, you never read it.
Expand  
public class RenderShadowClone extends RenderLiving<EntityShadowClone> {
    
	private static boolean smallArms;
	
	public RenderShadowClone(RenderManager rendermanagerIn) {
		super(rendermanagerIn, new ModelPlayer(0.0F, getSmallArms()), 0.5F);
	}

	@Override
	public ModelPlayer getMainModel()
    {
        return (ModelPlayer)super.getMainModel();
    }
	
	public static boolean getSmallArms() {
		return smallArms;
	}

	@Override
	protected ResourceLocation getEntityTexture(EntityShadowClone entity) {
		ResourceLocation skin = null;
		if (entity.getOwner() != null) {
			skin = ((AbstractClientPlayer) entity.getOwner()).getLocationSkin();
		}
		else {
			skin = DefaultPlayerSkin.getDefaultSkinLegacy();
		}
		return skin;
	}
	
	@Override
	protected void applyRotations(EntityShadowClone entityLiving, float p_77043_2_, float rotationYaw, float partialTicks) {
		super.applyRotations(entityLiving, p_77043_2_, rotationYaw, partialTicks);
	}
	
	@Override
	public void doRender(EntityShadowClone entity, double x, double y,
			double z, float entityYaw, float partialTicks) {
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
		if (((AbstractClientPlayer) entity.getOwner()).getSkinType().equals("default")) {
			smallArms = false;
		}
		else {
			smallArms = true;
		}
	}
}

Is this better?

The smallArms and getSmallArms() booleans are static because I get this error in the constructor when they're not:

  Quote

Cannot refer to an instance method while explicitly invoking a constructor

Expand  

 

Posted (edited)
  On 3/26/2019 at 8:52 PM, diesieben07 said:

This will not work. You need to learn basic programming.

You need two ModelPlayer instances.

Expand  
	private ModelPlayer playerDef = new ModelPlayer(0.0F, false);
	private ModelPlayer playerSlim = new ModelPlayer(0.0F, true);

Yes, and what should I do with those and where? Sorry for bothering you so much with this, I'm just a bit lost

Edited by FlashHUN
Posted
  On 3/26/2019 at 8:59 PM, diesieben07 said:

When rendering choose if you want small arms or not. And then render one or the other.

Expand  
		RenderingRegistry.registerEntityRenderingHandler(EntityShadowClone.class, new IRenderFactory<EntityShadowClone>() {
			@Override
			public Render<? super EntityShadowClone> createRenderFor(RenderManager manager) {
				return new RenderShadowClone(manager);
			}
		});

So, in here? If so, how?

Posted
  On 3/26/2019 at 9:03 PM, diesieben07 said:

No. That is where your renderer is registered. Rendering happens in Render#doRender.

Expand  

Alright, I am completely lost...

public class RenderShadowClone extends RenderLiving<EntityShadowClone> {
    
	private ModelPlayer playerDef = new ModelPlayer(0.0F, false);
	private ModelPlayer playerSlim = new ModelPlayer(0.0F, true);
	
	public RenderShadowClone(RenderManager rendermanagerIn) {
		super(rendermanagerIn, *model*, 0.5F);
	}

	@Override
	public ModelPlayer getMainModel()
    {
        return (ModelPlayer)super.getMainModel();
    }

	@Override
	protected ResourceLocation getEntityTexture(EntityShadowClone entity) {
		ResourceLocation skin = null;
		if (entity.getOwner() != null) {
			skin = ((AbstractClientPlayer) entity.getOwner()).getLocationSkin();
		}
		else {
			skin = DefaultPlayerSkin.getDefaultSkinLegacy();
		}
		return skin;
	}
	
	@Override
	protected void applyRotations(EntityShadowClone entityLiving, float p_77043_2_, float rotationYaw, float partialTicks) {
		super.applyRotations(entityLiving, p_77043_2_, rotationYaw, partialTicks);
	}
	
	@Override
	public void doRender(EntityShadowClone entity, double x, double y,
			double z, float entityYaw, float partialTicks) {
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
		if (entity.getOwner() != null && entity.getOwner() instanceof EntityPlayer) {
			if (((AbstractClientPlayer) entity.getOwner()).getSkinType().equals("default")) {
				
			}
			else {
				
			}
		}
		else {
			
		}
	}
}

What exactly should I be doing, what method should I be using?

Posted
  On 3/26/2019 at 9:20 PM, diesieben07 said:
  • Have you looked at the versions of doRender in your superclasses? In particular RenderLivingBase, where the actual interesting rendering happens.
  • You need to set RenderLivingBase#mainModel accordingly before rendering or do the whole rendering manually.
Expand  

Yes, I have looked at the versions of doRender in my supers, but I haven't found anything I could use.

Should my doRender look like this then?

	@Override
	public void doRender(EntityShadowClone entity, double x, double y,
			double z, float entityYaw, float partialTicks) {
		if (entity.getOwner() != null && entity.getOwner() instanceof EntityPlayer) {
				if (((AbstractClientPlayer) entity.getOwner()).getSkinType().equals("default")) {
					mainModel = playerDef;
				}
				else {
					mainModel = playerSlim;
				}
			}
			else {
				mainModel = playerDef;
			}
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
	}

If so, how can I then get that in the constructor?

	public RenderShadowClone(RenderManager rendermanagerIn) {
		super(rendermanagerIn, getMainModel(), 0.5F);
	}

gives me this error:

  Quote

Cannot refer to an instance method while explicitly invoking a constructor

Expand  

 

Posted
  On 3/26/2019 at 9:40 PM, diesieben07 said:

Have you looked at what the super constructor does with the model you give it? It simply sets mainModel. So since you overwrite that one every time you render anyways, there is no need to pass anything useful here. Just pass either of the two models.

 

Please, learn to read the code you are using.

Expand  

Thank you for all the help and sorry, I'm just simply new to all of this with only a littlebit of basic knowledge of java.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • "I want to understand how complex mods with ASM transformation and coremods work, such as Xray or AntiXray. Why do they break when you simply rename packages? What features of their architecture make refactoring difficult? And what techniques are used to protect these mods? I am interested in technical aspects in order to better understand the bytecode and Forge loader system."
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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