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

78 lines
4.0 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.model;
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.CubeDeformation;
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.PartDefinition;
import net.minecraft.client.renderer.entity.state.IronGolemRenderState;
import net.minecraft.util.Mth;
public class IronGolemModel
extends EntityModel<IronGolemRenderState> {
private final ModelPart head;
private final ModelPart rightArm;
private final ModelPart leftArm;
private final ModelPart rightLeg;
private final ModelPart leftLeg;
public IronGolemModel(ModelPart root) {
super(root);
this.head = root.getChild("head");
this.rightArm = root.getChild("right_arm");
this.leftArm = root.getChild("left_arm");
this.rightLeg = root.getChild("right_leg");
this.leftLeg = root.getChild("left_leg");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0f, -12.0f, -5.5f, 8.0f, 10.0f, 8.0f).texOffs(24, 0).addBox(-1.0f, -5.0f, -7.5f, 2.0f, 4.0f, 2.0f), PartPose.offset(0.0f, -7.0f, -2.0f));
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 40).addBox(-9.0f, -2.0f, -6.0f, 18.0f, 12.0f, 11.0f).texOffs(0, 70).addBox(-4.5f, 10.0f, -3.0f, 9.0f, 5.0f, 6.0f, new CubeDeformation(0.5f)), PartPose.offset(0.0f, -7.0f, 0.0f));
root.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(60, 21).addBox(-13.0f, -2.5f, -3.0f, 4.0f, 30.0f, 6.0f), PartPose.offset(0.0f, -7.0f, 0.0f));
root.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(60, 58).addBox(9.0f, -2.5f, -3.0f, 4.0f, 30.0f, 6.0f), PartPose.offset(0.0f, -7.0f, 0.0f));
root.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(37, 0).addBox(-3.5f, -3.0f, -3.0f, 6.0f, 16.0f, 5.0f), PartPose.offset(-4.0f, 11.0f, 0.0f));
root.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(60, 0).mirror().addBox(-3.5f, -3.0f, -3.0f, 6.0f, 16.0f, 5.0f), PartPose.offset(5.0f, 11.0f, 0.0f));
return LayerDefinition.create(mesh, 128, 128);
}
@Override
public void setupAnim(IronGolemRenderState state) {
super.setupAnim(state);
float attackTick = state.attackTicksRemaining;
float animationSpeed = state.walkAnimationSpeed;
float animationPos = state.walkAnimationPos;
if (attackTick > 0.0f) {
this.rightArm.xRot = -2.0f + 1.5f * Mth.triangleWave(attackTick, 10.0f);
this.leftArm.xRot = -2.0f + 1.5f * Mth.triangleWave(attackTick, 10.0f);
} else {
int offerFlowerTick = state.offerFlowerTick;
if (offerFlowerTick > 0) {
this.rightArm.xRot = -0.8f + 0.025f * Mth.triangleWave(offerFlowerTick, 70.0f);
this.leftArm.xRot = 0.0f;
} else {
this.rightArm.xRot = (-0.2f + 1.5f * Mth.triangleWave(animationPos, 13.0f)) * animationSpeed;
this.leftArm.xRot = (-0.2f - 1.5f * Mth.triangleWave(animationPos, 13.0f)) * animationSpeed;
}
}
this.head.yRot = state.yRot * ((float)Math.PI / 180);
this.head.xRot = state.xRot * ((float)Math.PI / 180);
this.rightLeg.xRot = -1.5f * Mth.triangleWave(animationPos, 13.0f) * animationSpeed;
this.leftLeg.xRot = 1.5f * Mth.triangleWave(animationPos, 13.0f) * animationSpeed;
this.rightLeg.yRot = 0.0f;
this.leftLeg.yRot = 0.0f;
}
public ModelPart getFlowerHoldingArm() {
return this.rightArm;
}
}