FemaleVillagerOverrideModel

unlisted ⁨1⁩ ⁨file⁩ 2025-03-31 21:46:16 UTC

pastefile1

Raw
package net.mca.client.model;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.model.ModelData;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.ModelPartBuilder;
import net.minecraft.client.model.ModelPartData;
import net.minecraft.client.model.ModelTransform;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.ModelWithHat;
import net.minecraft.client.render.entity.model.ModelWithHead;
import net.minecraft.client.render.entity.model.SinglePartEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.MerchantEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.client.render.entity.VillagerEntityRenderer;


@Environment(EnvType.CLIENT)
public class FemaleVillagerOverrideModel<T extends Entity> extends SinglePartEntityModel<T> implements ModelWithHead, ModelWithHat {
    private final ModelPart root;
    private final ModelPart head;
    private final ModelPart hat;
    private final ModelPart hatRim;
    private final ModelPart rightLeg;
    private final ModelPart leftLeg;
    protected final ModelPart nose;
    private final ModelPart skirtlayer1;
    private final ModelPart skirtlayer2;
    private final ModelPart skirtlayer3;
    private final ModelPart skirtlayer4;
    private final ModelPart skirtlayer5;

    public FemaleVillagerOverrideModel(ModelPart root) {
        this.root = root;
        this.head = root.getChild("head");
        this.hat = this.head.getChild("hat");
        this.hatRim = this.hat.getChild("hat_rim");
        this.nose = this.head.getChild("nose");
        this.rightLeg = root.getChild("right_leg");
        this.leftLeg = root.getChild("left_leg");
        this.skirtlayer1 = root.getChild("skirtlayer1");
        this.skirtlayer2 = root.getChild("skirtlayer2");
        this.skirtlayer3 = root.getChild("skirtlayer3");
        this.skirtlayer4 = root.getChild("skirtlayer4");
        this.skirtlayer5 = root.getChild("skirtlayer5");
    }

    public static ModelData getModelData() {
        ModelData modelData = new ModelData();
        ModelPartData modelPartData = modelData.getRoot();
        float f = 0.5F;
        ModelPartData modelPartData2 = modelPartData.addChild("head", ModelPartBuilder.create().uv(0, 0).cuboid(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F), ModelTransform.NONE);
        ModelPartData modelPartData3 = modelPartData2.addChild("hat", ModelPartBuilder.create().uv(32, 0).cuboid(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new Dilation(0.51F)), ModelTransform.NONE);
        modelPartData3.addChild("hat_rim", ModelPartBuilder.create().uv(30, 47).cuboid(-8.0F, -8.0F, -6.0F, 16.0F, 16.0F, 1.0F), ModelTransform.rotation((-(float)Math.PI / 2F), 0.0F, 0.0F));
        modelPartData2.addChild("nose", ModelPartBuilder.create().uv(24, 0).cuboid(-1.0F, -1.0F, -6.0F, 2.0F, 4.0F, 2.0F), ModelTransform.pivot(0.0F, -2.0F, 0.0F));
        ModelPartData modelPartData4 = modelPartData.addChild("body", ModelPartBuilder.create().uv(16, 20).cuboid(-4.0F, 0.0F, -3.0F, 8.0F, 12.0F, 6.0F), ModelTransform.NONE);
        modelPartData4.addChild("jacket", ModelPartBuilder.create().uv(0, 38).cuboid(-4.0F, 0.0F, -3.0F, 8.0F, 20.0F, 6.0F, new Dilation(0.5F)), ModelTransform.NONE);
        modelPartData.addChild("arms", ModelPartBuilder.create().uv(44, 22).cuboid(-8.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F).uv(44, 22).cuboid(4.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, true).uv(40, 38).cuboid(-4.0F, 2.0F, -2.0F, 8.0F, 4.0F, 4.0F), ModelTransform.of(0.0F, 3.0F, -1.0F, -0.75F, 0.0F, 0.0F));
        modelPartData.addChild("right_leg", ModelPartBuilder.create().uv(0, 22).cuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F), ModelTransform.pivot(-2.0F, 12.0F, 0.0F));
        modelPartData.addChild("left_leg", ModelPartBuilder.create().uv(0, 22).mirrored().cuboid(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F), ModelTransform.pivot(2.0F, 12.0F, 0.0F));
        modelPartData.addChild("skirtlayer1", ModelPartBuilder.create().uv(21, 26).cuboid(-6.0F, -14.0F, -5.0F, 12.0F, 0.0F, 10.0F, new Dilation(0.0F))
                .uv(10, 26).cuboid(-6.0F, -12.0F, -5.0F, 12.0F, 0.0F, 10.0F, new Dilation(0.0F))
                .uv(6, 16).mirrored().cuboid(-6.0F, -14.0F, -5.0F, 0.0F, 2.0F, 10.0F, new Dilation(0.0F)).mirrored(false)
                .uv(20, 16).cuboid(6.0F, -14.0F, -5.0F, 0.0F, 2.0F, 10.0F, new Dilation(0.0F))
                .uv(20, 26).cuboid(-6.0F, -14.0F, 5.0F, 12.0F, 2.0F, 0.0F, new Dilation(0.0F))
                .uv(20, 29).cuboid(-6.0F, -14.0F, -5.0F, 12.0F, 2.0F, 0.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, 22.0F, 0.0F));
        modelPartData.addChild("skirtlayer2", ModelPartBuilder.create().uv(18, 26).cuboid(-7.0F, -14.0F, -6.0F, 14.0F, 0.0F, 12.0F, new Dilation(0.0F))
                .uv(4, 26).cuboid(-7.0F, -12.0F, -6.0F, 14.0F, 0.0F, 12.0F, new Dilation(0.0F))
                .uv(16, 21).cuboid(-7.0F, -14.0F, -6.0F, 0.0F, 2.0F, 12.0F, new Dilation(0.0F))
                .uv(16, 20).cuboid(7.0F, -14.0F, -6.0F, 0.0F, 2.0F, 12.0F, new Dilation(0.0F))
                .uv(19, 30).cuboid(-7.0F, -14.0F, -6.0F, 14.0F, 2.0F, 0.0F, new Dilation(0.0F))
                .uv(16, 26).cuboid(-7.0F, -14.0F, 6.0F, 14.0F, 2.0F, 0.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, 24.0F, 0.0F));
        modelPartData.addChild("skirtlayer3", ModelPartBuilder.create().uv(8, 24).cuboid(-8.0F, -12.0F, -7.0F, 16.0F, 0.0F, 14.0F, new Dilation(0.0F))
                .uv(-8, 24).cuboid(-8.0F, -10.0F, -7.0F, 16.0F, 0.0F, 14.0F, new Dilation(0.0F))
                .uv(16, 14).cuboid(-8.0F, -12.0F, -7.0F, 0.0F, 2.0F, 14.0F, new Dilation(0.0F))
                .uv(16, 17).cuboid(8.0F, -12.0F, -7.0F, 0.0F, 2.0F, 14.0F, new Dilation(0.0F))
                .uv(18, 32).cuboid(-8.0F, -12.0F, -7.0F, 16.0F, 2.0F, 0.0F, new Dilation(0.0F))
                .uv(12, 31).cuboid(-8.0F, -12.0F, 7.0F, 16.0F, 2.0F, 0.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, 24.0F, 0.0F));
        modelPartData .addChild("skirtlayer4", ModelPartBuilder.create().uv(5, 22).cuboid(-9.0F, -10.0F, -8.0F, 18.0F, 0.0F, 16.0F, new Dilation(0.0F))
                .uv(-12, 21).cuboid(-9.0F, -8.0F, -8.0F, 18.0F, 0.0F, 16.0F, new Dilation(0.0F))
                .uv(16, 18).cuboid(-9.0F, -10.0F, -8.0F, 0.0F, 2.0F, 16.0F, new Dilation(0.0F))
                .uv(16, 18).cuboid(9.0F, -10.0F, -8.0F, 0.0F, 2.0F, 16.0F, new Dilation(0.0F))
                .uv(17, 34).cuboid(-9.0F, -10.0F, -8.0F, 18.0F, 2.0F, 0.0F, new Dilation(0.0F))
                .uv(8, 34).cuboid(-9.0F, -10.0F, 8.0F, 18.0F, 2.0F, 0.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, 24.0F, 0.0F));
        modelPartData.addChild("skirtlayer5", ModelPartBuilder.create().uv(0, 20).cuboid(-10.0F, -8.0F, -9.0F, 20.0F, 0.0F, 18.0F, new Dilation(0.0F))
                .uv(0, 20).cuboid(-10.0F, -6.0F, -9.0F, 20.0F, 0.0F, 18.0F, new Dilation(0.0F))
                .uv(16, 17).cuboid(-10.0F, -8.0F, -9.0F, 0.0F, 2.0F, 18.0F, new Dilation(0.0F))
                .uv(16, 17).cuboid(10.0F, -8.0F, -9.0F, 0.0F, 2.0F, 18.0F, new Dilation(0.0F))
                .uv(16, 35).cuboid(-10.0F, -8.0F, -9.0F, 20.0F, 2.0F, 0.0F, new Dilation(0.0F))
                .uv(24, 35).cuboid(-10.0F, -8.0F, 9.0F, 20.0F, 2.0F, 0.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, 24.0F, 0.0F));
        return modelData;
    }

    public ModelPart getPart() {
        return this.root;
    }

    public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
        boolean bl = false;
        if (entity instanceof MerchantEntity) {
            bl = ((MerchantEntity)entity).getHeadRollingTimeLeft() > 0;
        }

        this.head.yaw = headYaw * ((float)Math.PI / 180F);
        this.head.pitch = headPitch * ((float)Math.PI / 180F);
        if (bl) {
            this.head.roll = 0.3F * MathHelper.sin(0.45F * animationProgress);
            this.head.pitch = 0.4F;
        } else {
            this.head.roll = 0.0F;
        }

        this.rightLeg.pitch = MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance * 0.5F;
        this.leftLeg.pitch = MathHelper.cos(limbAngle * 0.6662F + (float)Math.PI) * 1.4F * limbDistance * 0.5F;
        this.rightLeg.yaw = 0.0F;
        this.leftLeg.yaw = 0.0F;
    }

    public ModelPart getHead() {
        return this.head;
    }

    public void setHatVisible(boolean visible) {
        this.head.visible = visible;
        this.hat.visible = visible;
        this.hatRim.visible = visible;
    }
    public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
        skirtlayer1.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        skirtlayer2.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        skirtlayer3.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        skirtlayer4.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
        skirtlayer5.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
    }
}