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

[1.12.2] Custom armor rotates different than player with small arms


Meldexun
 Share

Recommended Posts

So i have made a armor with a custom model. The model is tight on the player skin and is working properly with a normal Skin (the 4x12x4 arms from steve).

But with a skin with small arms the arms aren't rotating the same way as my armor. This results in the arms coming out of the armor from the  swing animation.

 

That's the model class:

	ModelRenderer diveRightArm;
		
	public Model() {
      	super(0.0F);
		this.textureWidth = 64;
		this.textureHeight = 64;
      
		diveRightArm = new ModelRenderer(this, 0, 80);
		diveRightArm.addBox(-2.0F, -2.0F, -2.0F, 4, 12, 4, 0.001F);
		diveRightArm.setRotationPoint(0.0F, 0.5F, 0.0F);
		diveRightArm.setTextureSize(textureWidthIn, textureHeightIn);
		diveRightArm.mirror = true;
		setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
	}
	
	@Override
	public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	}

 

The arms should be covered:

2019-04-17_02_12_16.png.ed35de9ff40c1bf72769810640a6d75d.png

Link to comment
Share on other sites

So i found out that when i extend my model class ModelPlayer instead of ModelBiped my model is rotating correctly with the arms. But that results in other problems. For example in multiplayer the armor is just rendered for yourself and others don't see it.

Has anyone experience with that?

Link to comment
Share on other sites

11 hours ago, Xumuk said:

In order not to create new threads, I'll ask my question here.

Make a new thread, having two people with different problems (even if the symptoms are the same) on the same thread never works out so as a general rule make your own thread. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

15 hours ago, Meldexun said:

For example in multiplayer the armor is just rendered for yourself and others don't see it.

Has anyone experience with that?

This usually means that you are using Minecraft#player when you shouldn’t be. Post your new code (all of it)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

3 hours ago, Cadiboo said:

This usually means that you are using Minecraft#player when you shouldn’t be.

I'm never using for this part of my mod.

 

So thats my new model class:

@SideOnly(Side.CLIENT)
public class ModelDivingGear extends ModelPlayer {
	
	ModelRenderer diveRightArm;
	ModelRenderer diveLeftArm;
	
	public ModelDivingGear(float scale, boolean smallArmsIn) {
		super(scale, smallArmsIn);
		this.textureHeight = 128;
		this.textureWidth = 64;
		
		//arms
		if (smallArmsIn) {
			diveRightArm = this.createCube(0, 48 + 32, -2.0F, -2.0F, -2.0F, 3, 12, 4, 0.251F);
			setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
			diveLeftArm = this.createCube(0, 48 + 32, -2.0F, -2.0F, -2.0F, 3, 12, 4, 0.251F);
			setRotation(diveLeftArm, 0.0F, (float) Math.PI, 0.0F);
		} else {
			diveRightArm = this.createCube(0, 48 + 32, -3.0F, -2.0F, -2.0F, 4, 12, 4, 0.251F);
			setRotation(diveRightArm, 0.0F, 0.0F, 0.0F);
			diveLeftArm = this.createCube(0, 48 + 32, -3.0F, -2.0F, -2.0F, 4, 12, 4, 0.251F);
			setRotation(diveLeftArm, 0.0F, (float) Math.PI, 0.0F);
		}
		
		bipedRightArm.addChild(diveRightArm);
		bipedLeftArm.addChild(diveLeftArm);
		
	}

	@Override
	public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	}
	
	private void setRotation(ModelRenderer model, float x, float y, float z) {
		model.rotateAngleX = x;
		model.rotateAngleY = y;
		model.rotateAngleZ = z;
	}
	
	private ModelRenderer createCube(int texOffX, int texOffY, float offX, float offY, float offZ, int width, int height, int depth, float scale) {
		ModelRenderer m = new ModelRenderer(this, texOffX, texOffY);
		m.addBox(offX, offY, offZ, width, height, depth, scale);
		m.setRotationPoint(0.0F, 0.0F, 0.0F);
		m.setTextureSize(textureWidth, textureHeight);
		m.mirror = true;
		return m;
	}
	
}

 

Here i create the model:

@EventBusSubscriber(Side.CLIENT)
public class ArmorModels {

	public static ModelDivingGear divingGearModel;
	public static ModelDivingGear divingGearModelSlim;
	public static ModelDivingGearLegs divingGearModelLegs;
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		divingGearModel = new ModelDivingGear(0.0F, false);
		divingGearModelSlim = new ModelDivingGear(0.0F, true);
		divingGearModelLegs = new ModelDivingGearLegs(0.0F);
	}
	
}

 

And i override the getArmorModel method:

	@SideOnly(Side.CLIENT)
	@Override
	public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped _default) {
		return armorSlot == EntityEquipmentSlot.LEGS ? ArmorModels.divingGearModelLegs : entityLiving instanceof EntityPlayer && ((EntityPlayerSP) entityLiving).getSkinType().equals("slim") ? ArmorModels.divingGearModelSlim : ArmorModels.divingGearModel;
	}

 

I thought the getArmorModel method always passes you an EntityPlayerSP when a player is wearing the armor. But it may pass an EntityPlayerMP on servers? Is that right? That the only point that i don't really know about.

Edited by Meldexun
Link to comment
Share on other sites

12 hours ago, Meldexun said:

I thought the getArmorModel method always passes you an EntityPlayerSP when a player is wearing the armor. But it may pass an EntityPlayerMP on servers? Is that right? That the only point that i don't really know about.

Armor models are client side only so it will never pass an EntityPlayerMP. It may pass you an EntityOtherPlayerMP though. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

8 hours ago, Cadiboo said:

Armor models are client side only so it will never pass an EntityPlayerMP. It may pass you an EntityOtherPlayerMP though. 

Yeah, i also found this out already after some testing. So i'm now checking for AbstractClientPlayer (it may be named different). Also i changed my model again and all seems to work fine now. Thank you for the help.

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.