Jump to content

[1.16.5] Help updating entity model code? Or is there a JSON alternative?


SapphireSky

Recommended Posts

I'm trying to make a custom model for a piece of armour, but am having trouble.

The code that Blockbench exports either uses old mappings, the unofficial (or unofficial?) mappings (my project is using whatever is default), or both. I can't tell.

.

I tried updating the exported code to what I assume is the proper equivalent in my case, but ModelRenderer::setRotationPoint(x,y,z) doesn't seem to have any alternative.

The closest thing I can see that affects rotations at all is ModelRenderer::translateAndRotate(matrixstack), but I can't figure out how to use that, much less if that's even the right option to use.

.

This is the exported code vs my attempt at fixing it, in case I did something else wrong as well, I'm going off older tutorials and Google here..:

Exported model class with wrong mappings:

Spoiler

public class iron_wings extends EntityModel<Entity> {
    private final ModelRenderer harness;
    private final ModelRenderer leftwing;
    private final ModelRenderer wingLB3_r1;
    private final ModelRenderer wingLB2_r1;
    private final ModelRenderer wingLB1_r1;
    private final ModelRenderer rightwing;
    private final ModelRenderer wingRB3_r1;
    private final ModelRenderer wingRB2_r1;
    private final ModelRenderer wingRB1_r1;
    private final ModelRenderer wingRB0_r1;

    public iron_wings() {
        textureWidth = 128;
        textureHeight = 128;

        harness = new ModelRenderer(this);
        harness.setRotationPoint(0.0F, 24.0F, 0.0F);
        harness.setTextureOffset(48, 47).addBox(-4.0F, -21.0F, 2.0F, 7.0F, 1.0F, 1.0F, 0.0F, false);
        harness.setTextureOffset(42, 21).addBox(3.0F, -24.0F, -3.0F, 1.0F, 6.0F, 6.0F, 0.0F, false);
        harness.setTextureOffset(42, 9).addBox(-5.0F, -24.0F, -3.0F, 1.0F, 6.0F, 6.0F, 0.0F, false);
        harness.setTextureOffset(48, 36).addBox(-4.5F, -23.0F, 3.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);

        leftwing = new ModelRenderer(this);
        leftwing.setRotationPoint(-0.494F, 4.0F, 0.0F);
        leftwing.setTextureOffset(0, 24).addBox(4.994F, -8.0F, 5.5F, 18.0F, 24.0F, 0.0F, 0.0F, false);

        wingLB3_r1 = new ModelRenderer(this);
        wingLB3_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        leftwing.addChild(wingLB3_r1);
        setRotationAngle(wingLB3_r1, 0.0F, 0.0F, -0.3927F);
        wingLB3_r1.setTextureOffset(36, 9).addBox(5.1323F, -1.9749F, 5.0F, 2.0F, 21.0F, 1.0F, 0.0F, false);

        wingLB2_r1 = new ModelRenderer(this);
        wingLB2_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        leftwing.addChild(wingLB2_r1);
        setRotationAngle(wingLB2_r1, 0.0F, 0.0F, -0.7854F);
        wingLB2_r1.setTextureOffset(42, 33).addBox(8.2505F, 1.1013F, 5.0F, 2.0F, 18.0F, 1.0F, 0.0F, false);
        wingLB2_r1.setTextureOffset(0, 48).addBox(3.2505F, -0.8987F, 5.0F, 9.0F, 2.0F, 1.0F, 0.0F, false);
        wingLB2_r1.setTextureOffset(20, 48).addBox(1.2505F, -1.8987F, 4.0F, 5.0F, 5.0F, 1.0F, 0.0F, false);

        wingLB1_r1 = new ModelRenderer(this);
        wingLB1_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        leftwing.addChild(wingLB1_r1);
        setRotationAngle(wingLB1_r1, 0.0F, 0.0F, 0.3927F);
        wingLB1_r1.setTextureOffset(36, 3).addBox(4.4543F, -11.9856F, 5.0F, 16.0F, 2.0F, 1.0F, 0.0F, false);

        rightwing = new ModelRenderer(this);
        rightwing.setRotationPoint(-0.494F, 4.0F, 0.0F);
        rightwing.setTextureOffset(0, 0).addBox(-23.006F, -8.0F, 5.5F, 18.0F, 24.0F, 0.0F, 0.0F, false);

        wingRB3_r1 = new ModelRenderer(this);
        wingRB3_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        rightwing.addChild(wingRB3_r1);
        setRotationAngle(wingRB3_r1, 0.0F, 0.0F, 0.3927F);
        wingRB3_r1.setTextureOffset(36, 31).addBox(-7.1434F, -1.9703F, 5.0F, 2.0F, 21.0F, 1.0F, 0.0F, false);

        wingRB2_r1 = new ModelRenderer(this);
        wingRB2_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        rightwing.addChild(wingRB2_r1);
        setRotationAngle(wingRB2_r1, 0.0F, 0.0F, -0.7854F);
        wingRB2_r1.setTextureOffset(36, 0).addBox(-18.9995F, -10.3987F, 5.0F, 18.0F, 2.0F, 1.0F, 0.0F, false);

        wingRB1_r1 = new ModelRenderer(this);
        wingRB1_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        rightwing.addChild(wingRB1_r1);
        setRotationAngle(wingRB1_r1, 0.0F, 0.0F, -0.3927F);
        wingRB1_r1.setTextureOffset(36, 6).addBox(-20.6177F, -11.9749F, 5.0F, 16.0F, 2.0F, 1.0F, 0.0F, false);

        wingRB0_r1 = new ModelRenderer(this);
        wingRB0_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
        rightwing.addChild(wingRB0_r1);
        setRotationAngle(wingRB0_r1, 0.0F, 0.0F, 0.7854F);
        wingRB0_r1.setTextureOffset(48, 33).addBox(-12.259F, -0.8902F, 5.0F, 9.0F, 2.0F, 1.0F, 0.0F, false);
        wingRB0_r1.setTextureOffset(48, 41).addBox(-6.259F, -1.8902F, 4.0F, 5.0F, 5.0F, 1.0F, 0.0F, false);
    }

    @Override
    public void setRotationAngles(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
        //previously the render function, render code was moved to a method below
    }

    @Override
    public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
        harness.render(matrixStack, buffer, packedLight, packedOverlay);
        leftwing.render(matrixStack, buffer, packedLight, packedOverlay);
        rightwing.render(matrixStack, buffer, packedLight, packedOverlay);
    }

    public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
}

 

My attempt at fixing them, my problematic methods commented:

Spoiler

public class ModelIronWings extends BipedModel<LivingEntity>
{
	private final ModelRenderer harness;
	private final ModelRenderer leftwing;
	private final ModelRenderer wingLB3_r1;
	private final ModelRenderer wingLB2_r1;
	private final ModelRenderer wingLB1_r1;
	private final ModelRenderer rightwing;
	private final ModelRenderer wingRB3_r1;
	private final ModelRenderer wingRB2_r1;
	private final ModelRenderer wingRB1_r1;
	private final ModelRenderer wingRB0_r1;

	public ModelIronWings(float size)
	{
		super(size, 0, 128, 128);

		harness = new ModelRenderer(this);
		// harness.setRotationPoint(0.0F, 24.0F, 0.0F);
		harness.texOffs(48, 47).addBox(-4.0F, -21.0F, 2.0F, 7.0F, 1.0F, 1.0F, 0.0F, false);
		harness.texOffs(42, 21).addBox(3.0F, -24.0F, -3.0F, 1.0F, 6.0F, 6.0F, 0.0F, false);
		harness.texOffs(42, 9).addBox(-5.0F, -24.0F, -3.0F, 1.0F, 6.0F, 6.0F, 0.0F, false);
		harness.texOffs(48, 36).addBox(-4.5F, -23.0F, 3.0F, 8.0F, 4.0F, 1.0F, 0.0F, false);

		leftwing = new ModelRenderer(this);
		// leftwing.setRotationPoint(-0.494F, 4.0F, 0.0F);
		leftwing.texOffs(0, 24).addBox(4.994F, -8.0F, 5.5F, 18.0F, 24.0F, 0.0F, 0.0F, false);

		wingLB3_r1 = new ModelRenderer(this);
		// wingLB3_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		leftwing.addChild(wingLB3_r1);
		setRotationAngle(wingLB3_r1, 0.0F, 0.0F, -0.3927F);
		wingLB3_r1.texOffs(36, 9).addBox(5.1323F, -1.9749F, 5.0F, 2.0F, 21.0F, 1.0F, 0.0F, false);

		wingLB2_r1 = new ModelRenderer(this);
		// wingLB2_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		leftwing.addChild(wingLB2_r1);
		setRotationAngle(wingLB2_r1, 0.0F, 0.0F, -0.7854F);
		wingLB2_r1.texOffs(42, 33).addBox(8.2505F, 1.1013F, 5.0F, 2.0F, 18.0F, 1.0F, 0.0F, false);
		wingLB2_r1.texOffs(0, 48).addBox(3.2505F, -0.8987F, 5.0F, 9.0F, 2.0F, 1.0F, 0.0F, false);
		wingLB2_r1.texOffs(20, 48).addBox(1.2505F, -1.8987F, 4.0F, 5.0F, 5.0F, 1.0F, 0.0F, false);

		wingLB1_r1 = new ModelRenderer(this);
		// wingLB1_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		leftwing.addChild(wingLB1_r1);
		setRotationAngle(wingLB1_r1, 0.0F, 0.0F, 0.3927F);
		wingLB1_r1.texOffs(36, 3).addBox(4.4543F, -11.9856F, 5.0F, 16.0F, 2.0F, 1.0F, 0.0F, false);

		rightwing = new ModelRenderer(this);
		// rightwing.setRotationPoint(-0.494F, 4.0F, 0.0F);
		rightwing.texOffs(0, 0).addBox(-23.006F, -8.0F, 5.5F, 18.0F, 24.0F, 0.0F, 0.0F, false);

		wingRB3_r1 = new ModelRenderer(this);
		// wingRB3_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		rightwing.addChild(wingRB3_r1);
		setRotationAngle(wingRB3_r1, 0.0F, 0.0F, 0.3927F);
		wingRB3_r1.texOffs(36, 31).addBox(-7.1434F, -1.9703F, 5.0F, 2.0F, 21.0F, 1.0F, 0.0F, false);

		wingRB2_r1 = new ModelRenderer(this);
		// wingRB2_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		rightwing.addChild(wingRB2_r1);
		setRotationAngle(wingRB2_r1, 0.0F, 0.0F, -0.7854F);
		wingRB2_r1.texOffs(36, 0).addBox(-18.9995F, -10.3987F, 5.0F, 18.0F, 2.0F, 1.0F, 0.0F, false);

		wingRB1_r1 = new ModelRenderer(this);
		// wingRB1_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		rightwing.addChild(wingRB1_r1);
		setRotationAngle(wingRB1_r1, 0.0F, 0.0F, -0.3927F);
		wingRB1_r1.texOffs(36, 6).addBox(-20.6177F, -11.9749F, 5.0F, 16.0F, 2.0F, 1.0F, 0.0F, false);

		wingRB0_r1 = new ModelRenderer(this);
		// wingRB0_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
		rightwing.addChild(wingRB0_r1);
		setRotationAngle(wingRB0_r1, 0.0F, 0.0F, 0.7854F);
		wingRB0_r1.texOffs(48, 33).addBox(-12.259F, -0.8902F, 5.0F, 9.0F, 2.0F, 1.0F, 0.0F, false);
		wingRB0_r1.texOffs(48, 41).addBox(-6.259F, -1.8902F, 4.0F, 5.0F, 5.0F, 1.0F, 0.0F, false);
	}

	public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z)
	{
		modelRenderer.xRot = x;
		modelRenderer.yRot = y;
		modelRenderer.zRot = z;
	}
}

 

 

I don't suppose there's any way to make this so much less work and just use standard JSON item models as armour instead...?

Link to comment
Share on other sites

10 hours ago, SapphireSky said:

I don't suppose there's any way to make this so much less work and just use standard JSON item models as armour instead...?

If you're translating individual files, there's not much you can do about it. You could use the updateMappings gradlew task, but that's better for large batches of code. As for JSON item models, that is a much more complicated issue that involves layers and custom transform types. While still possible, the tradeoff isn't really worth it.

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



×
×
  • Create New...

Important Information

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