Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

  • Author
1 minute ago, diesieben07 said:

AbstractClientPlayer#getSkinType returns "default" or "slim".

I know, but how could I use that during rendering?

  • Author
4 minutes ago, diesieben07 said:

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

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;
		}
	}
}

 

  • Author
3 minutes ago, 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.
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

 

  • Author
7 minutes ago, diesieben07 said:

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

You need two ModelPlayer instances.

	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

  • Author
1 minute ago, diesieben07 said:

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

		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?

  • Author
2 minutes ago, diesieben07 said:

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

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?

  • Author
5 minutes ago, 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.

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

 

  • Author
2 minutes ago, 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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.