2025-11-24 22:52:51 +03:00

74 lines
3.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.model;
import java.util.Set;
import net.minecraft.client.model.BabyModelTransform;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.MeshTransformer;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.entity.state.ChickenRenderState;
import net.minecraft.util.Mth;
public class ChickenModel
extends EntityModel<ChickenRenderState> {
public static final String RED_THING = "red_thing";
public static final float Y_OFFSET = 16.0f;
public static final MeshTransformer BABY_TRANSFORMER = new BabyModelTransform(false, 5.0f, 2.0f, 2.0f, 1.99f, 24.0f, Set.of("head", "beak", "red_thing"));
private final ModelPart head;
private final ModelPart rightLeg;
private final ModelPart leftLeg;
private final ModelPart rightWing;
private final ModelPart leftWing;
public ChickenModel(ModelPart root) {
super(root);
this.head = root.getChild("head");
this.rightLeg = root.getChild("right_leg");
this.leftLeg = root.getChild("left_leg");
this.rightWing = root.getChild("right_wing");
this.leftWing = root.getChild("left_wing");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = ChickenModel.createBaseChickenModel();
return LayerDefinition.create(mesh, 64, 32);
}
protected static MeshDefinition createBaseChickenModel() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
PartDefinition head = root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-2.0f, -6.0f, -2.0f, 4.0f, 6.0f, 3.0f), PartPose.offset(0.0f, 15.0f, -4.0f));
head.addOrReplaceChild("beak", CubeListBuilder.create().texOffs(14, 0).addBox(-2.0f, -4.0f, -4.0f, 4.0f, 2.0f, 2.0f), PartPose.ZERO);
head.addOrReplaceChild(RED_THING, CubeListBuilder.create().texOffs(14, 4).addBox(-1.0f, -2.0f, -3.0f, 2.0f, 2.0f, 2.0f), PartPose.ZERO);
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 9).addBox(-3.0f, -4.0f, -3.0f, 6.0f, 8.0f, 6.0f), PartPose.offsetAndRotation(0.0f, 16.0f, 0.0f, 1.5707964f, 0.0f, 0.0f));
CubeListBuilder leg = CubeListBuilder.create().texOffs(26, 0).addBox(-1.0f, 0.0f, -3.0f, 3.0f, 5.0f, 3.0f);
root.addOrReplaceChild("right_leg", leg, PartPose.offset(-2.0f, 19.0f, 1.0f));
root.addOrReplaceChild("left_leg", leg, PartPose.offset(1.0f, 19.0f, 1.0f));
root.addOrReplaceChild("right_wing", CubeListBuilder.create().texOffs(24, 13).addBox(0.0f, 0.0f, -3.0f, 1.0f, 4.0f, 6.0f), PartPose.offset(-4.0f, 13.0f, 0.0f));
root.addOrReplaceChild("left_wing", CubeListBuilder.create().texOffs(24, 13).addBox(-1.0f, 0.0f, -3.0f, 1.0f, 4.0f, 6.0f), PartPose.offset(4.0f, 13.0f, 0.0f));
return mesh;
}
@Override
public void setupAnim(ChickenRenderState state) {
super.setupAnim(state);
float flapAngle = (Mth.sin(state.flap) + 1.0f) * state.flapSpeed;
this.head.xRot = state.xRot * ((float)Math.PI / 180);
this.head.yRot = state.yRot * ((float)Math.PI / 180);
float animationSpeed = state.walkAnimationSpeed;
float animationPos = state.walkAnimationPos;
this.rightLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed;
this.leftLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed;
this.rightWing.zRot = flapAngle;
this.leftWing.zRot = -flapAngle;
}
}