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.

Featured Replies

Posted

I'm trying to render a custom helmet and the helmet rotates fine horizontally but it seems that it rotates on the x/z as well when I look vertically.

 

Here's a picture of what's happening:

https://imgur.com/a/TOYUDqb

 

Item class:

public class MythusArmorVar2 extends ArmorItem
{
    public MythusArmorVar2(IArmorMaterial mat, EquipmentSlotType slot)
    {
        super(mat, slot, new Properties().group(Mythus.MYTHUS_TAB));
    }

    @Nullable
    @Override
    public <A extends BipedModel<?>> A getArmorModel(LivingEntity ent, ItemStack stack, EquipmentSlotType slot, A _default) {
        if(!stack.isEmpty())
        {
            if(stack.getItem() instanceof ArmorItem)
            {
                KabutoHelmModel helm_model = new KabutoHelmModel(1);
                helm_model.bipedHead.showModel = slot == EquipmentSlotType.HEAD;

                helm_model.isChild = _default.isChild;
                helm_model.isSneak = _default.isSneak;
                helm_model.isSitting = _default.isSitting;
                helm_model.rightArmPose = _default.rightArmPose;
                helm_model.leftArmPose = _default.leftArmPose;

                return (A) helm_model;
            }
        }
        return null;
    }
}

 

Model Class:

public class KabutoHelmModel extends BipedModel<LivingEntity> {

	private final ModelRenderer basehelm;

	public KabutoHelmModel(float scale) {
		super(scale,0, 64, 64);
		textureWidth = 64;
		textureHeight = 64;

		basehelm = new ModelRenderer(this);
		basehelm.setRotationPoint(0.0F, 24.0F, 0.0F);
		basehelm.setTextureOffset(34, 0).addBox(-4.0F, -32.0F, -5.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(26, 16).addBox(4.0F, -32.0F, -4.0F, 1.0F, 4.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(23, 0).addBox(5.0F, -28.0F, -4.0F, 1.0F, 2.0F, 9.0F, 0.0F, false);
		basehelm.setTextureOffset(5, 25).addBox(4.0F, -30.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(60, 0).addBox(2.0F, -28.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(36, 16).addBox(-3.0F, -28.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(52, 4).addBox(-1.0F, -28.0F, -5.0F, 2.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(36, 21).addBox(-2.0F, -26.0F, -5.0F, 4.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(48, 9).addBox(1.0F, -27.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(53, 0).addBox(-2.0F, -27.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 19).addBox(-5.0F, -30.0F, -5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 21).addBox(5.0F, -30.0F, -5.0F, 2.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 12).addBox(-7.0F, -30.0F, -5.0F, 2.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 9).addBox(7.0F, -30.0F, -4.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 0).addBox(-8.0F, -30.0F, -4.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 21).addBox(-6.0F, -28.0F, -4.0F, 1.0F, 2.0F, 9.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 9).addBox(-7.0F, -26.0F, -4.0F, 1.0F, 2.0F, 10.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 16).addBox(-6.0F, -26.0F, 5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 26).addBox(5.0F, -26.0F, 5.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 3).addBox(-5.0F, -28.0F, 4.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(28, 0).addBox(4.0F, -28.0F, 4.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 12).addBox(6.0F, -26.0F, -4.0F, 1.0F, 2.0F, 10.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 24).addBox(-5.0F, -32.0F, -4.0F, 1.0F, 4.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(30, 31).addBox(-4.0F, -32.0F, 4.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(22, 28).addBox(-5.0F, -28.0F, 5.0F, 10.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 11).addBox(-6.0F, -26.0F, 6.0F, 12.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 14).addBox(-3.0F, -29.0F, -6.0F, 6.0F, 1.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(34, 5).addBox(-3.0F, -31.0F, -6.0F, 6.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 0).addBox(-4.0F, -33.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(18, 13).addBox(-5.0F, -35.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(17, 9).addBox(-6.0F, -37.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(22, 24).addBox(3.0F, -33.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 16).addBox(2.0F, -33.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(12, 9).addBox(3.0F, -35.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(5, 9).addBox(4.0F, -37.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(24, 4).addBox(-3.0F, -33.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(4, 16).addBox(-4.0F, -35.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 16).addBox(-5.0F, -37.0F, -6.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(15, 24).addBox(4.0F, -35.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(11, 24).addBox(5.0F, -37.0F, -6.0F, 1.0F, 3.0F, 1.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 0).addBox(-4.0F, -33.0F, -4.0F, 8.0F, 1.0F, 8.0F, 0.0F, false);
		basehelm.setTextureOffset(0, 33).addBox(-1.0F, -34.0F, 0.0F, 2.0F, 1.0F, 2.0F, 0.0F, false);
		this.bipedHead.addChild(basehelm);
	}

	@Override
	public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
		basehelm.setRotationPoint(0.0F, 24.0F, 0.0F);
		basehelm.render(matrixStack, buffer, packedLight, packedOverlay);
	}

	//TODO figure out why it isn't working
	@Override
	public void setRotationAngles(LivingEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
		super.setRotationAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
		this.basehelm.copyModelAngles(this.bipedHead);
	}
}

 

Howdy

 

You might find this link useful - it is a working example of how model rotations work, including an 'interactive' tool for adjusting your model parameters by typing commands- makes it a lot easier to tweak the render translations and rotations.

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe80_model_renderer

 

Off the cuff- the rotation point is probably not correct.  i.e. when your head tilts back, the y origin of rotation in your model doesn't correspond to the centre of rotation of the head.

 

-TGG

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.