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

167 lines
8.7 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.model;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.AnimationUtils;
import net.minecraft.client.model.ArmedModel;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.HeadedModel;
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.ArmedEntityRenderState;
import net.minecraft.client.renderer.entity.state.IllagerRenderState;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.monster.AbstractIllager;
public class IllagerModel<S extends IllagerRenderState>
extends EntityModel<S>
implements ArmedModel<S>,
HeadedModel {
private final ModelPart head;
private final ModelPart hat;
private final ModelPart arms;
private final ModelPart leftLeg;
private final ModelPart rightLeg;
private final ModelPart rightArm;
private final ModelPart leftArm;
public IllagerModel(ModelPart root) {
super(root);
this.head = root.getChild("head");
this.hat = this.head.getChild("hat");
this.hat.visible = false;
this.arms = root.getChild("arms");
this.leftLeg = root.getChild("left_leg");
this.rightLeg = root.getChild("right_leg");
this.leftArm = root.getChild("left_arm");
this.rightArm = root.getChild("right_arm");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
PartDefinition head = root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0f, -10.0f, -4.0f, 8.0f, 10.0f, 8.0f), PartPose.offset(0.0f, 0.0f, 0.0f));
head.addOrReplaceChild("hat", CubeListBuilder.create().texOffs(32, 0).addBox(-4.0f, -10.0f, -4.0f, 8.0f, 12.0f, 8.0f, new CubeDeformation(0.45f)), PartPose.ZERO);
head.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(24, 0).addBox(-1.0f, -1.0f, -6.0f, 2.0f, 4.0f, 2.0f), PartPose.offset(0.0f, -2.0f, 0.0f));
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(16, 20).addBox(-4.0f, 0.0f, -3.0f, 8.0f, 12.0f, 6.0f).texOffs(0, 38).addBox(-4.0f, 0.0f, -3.0f, 8.0f, 20.0f, 6.0f, new CubeDeformation(0.5f)), PartPose.offset(0.0f, 0.0f, 0.0f));
PartDefinition arms = root.addOrReplaceChild("arms", CubeListBuilder.create().texOffs(44, 22).addBox(-8.0f, -2.0f, -2.0f, 4.0f, 8.0f, 4.0f).texOffs(40, 38).addBox(-4.0f, 2.0f, -2.0f, 8.0f, 4.0f, 4.0f), PartPose.offsetAndRotation(0.0f, 3.0f, -1.0f, -0.75f, 0.0f, 0.0f));
arms.addOrReplaceChild("left_shoulder", CubeListBuilder.create().texOffs(44, 22).mirror().addBox(4.0f, -2.0f, -2.0f, 4.0f, 8.0f, 4.0f), PartPose.ZERO);
root.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0f, 0.0f, -2.0f, 4.0f, 12.0f, 4.0f), PartPose.offset(-2.0f, 12.0f, 0.0f));
root.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(0, 22).mirror().addBox(-2.0f, 0.0f, -2.0f, 4.0f, 12.0f, 4.0f), PartPose.offset(2.0f, 12.0f, 0.0f));
root.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 46).addBox(-3.0f, -2.0f, -2.0f, 4.0f, 12.0f, 4.0f), PartPose.offset(-5.0f, 2.0f, 0.0f));
root.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(40, 46).mirror().addBox(-1.0f, -2.0f, -2.0f, 4.0f, 12.0f, 4.0f), PartPose.offset(5.0f, 2.0f, 0.0f));
return LayerDefinition.create(mesh, 64, 64);
}
@Override
public void setupAnim(S state) {
boolean crossedArms;
super.setupAnim(state);
this.head.yRot = ((IllagerRenderState)state).yRot * ((float)Math.PI / 180);
this.head.xRot = ((IllagerRenderState)state).xRot * ((float)Math.PI / 180);
if (((IllagerRenderState)state).isRiding) {
this.rightArm.xRot = -0.62831855f;
this.rightArm.yRot = 0.0f;
this.rightArm.zRot = 0.0f;
this.leftArm.xRot = -0.62831855f;
this.leftArm.yRot = 0.0f;
this.leftArm.zRot = 0.0f;
this.rightLeg.xRot = -1.4137167f;
this.rightLeg.yRot = 0.31415927f;
this.rightLeg.zRot = 0.07853982f;
this.leftLeg.xRot = -1.4137167f;
this.leftLeg.yRot = -0.31415927f;
this.leftLeg.zRot = -0.07853982f;
} else {
float animationSpeed = ((IllagerRenderState)state).walkAnimationSpeed;
float animationPos = ((IllagerRenderState)state).walkAnimationPos;
this.rightArm.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 2.0f * animationSpeed * 0.5f;
this.rightArm.yRot = 0.0f;
this.rightArm.zRot = 0.0f;
this.leftArm.xRot = Mth.cos(animationPos * 0.6662f) * 2.0f * animationSpeed * 0.5f;
this.leftArm.yRot = 0.0f;
this.leftArm.zRot = 0.0f;
this.rightLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed * 0.5f;
this.rightLeg.yRot = 0.0f;
this.rightLeg.zRot = 0.0f;
this.leftLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed * 0.5f;
this.leftLeg.yRot = 0.0f;
this.leftLeg.zRot = 0.0f;
}
AbstractIllager.IllagerArmPose pose = ((IllagerRenderState)state).armPose;
if (pose == AbstractIllager.IllagerArmPose.ATTACKING) {
if (((ArmedEntityRenderState)state).getMainHandItemState().isEmpty()) {
AnimationUtils.animateZombieArms(this.leftArm, this.rightArm, true, state);
} else {
AnimationUtils.swingWeaponDown(this.rightArm, this.leftArm, ((IllagerRenderState)state).mainArm, ((IllagerRenderState)state).attackAnim, ((IllagerRenderState)state).ageInTicks);
}
} else if (pose == AbstractIllager.IllagerArmPose.SPELLCASTING) {
this.rightArm.z = 0.0f;
this.rightArm.x = -5.0f;
this.leftArm.z = 0.0f;
this.leftArm.x = 5.0f;
this.rightArm.xRot = Mth.cos(((IllagerRenderState)state).ageInTicks * 0.6662f) * 0.25f;
this.leftArm.xRot = Mth.cos(((IllagerRenderState)state).ageInTicks * 0.6662f) * 0.25f;
this.rightArm.zRot = 2.3561945f;
this.leftArm.zRot = -2.3561945f;
this.rightArm.yRot = 0.0f;
this.leftArm.yRot = 0.0f;
} else if (pose == AbstractIllager.IllagerArmPose.BOW_AND_ARROW) {
this.rightArm.yRot = -0.1f + this.head.yRot;
this.rightArm.xRot = -1.5707964f + this.head.xRot;
this.leftArm.xRot = -0.9424779f + this.head.xRot;
this.leftArm.yRot = this.head.yRot - 0.4f;
this.leftArm.zRot = 1.5707964f;
} else if (pose == AbstractIllager.IllagerArmPose.CROSSBOW_HOLD) {
AnimationUtils.animateCrossbowHold(this.rightArm, this.leftArm, this.head, true);
} else if (pose == AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE) {
AnimationUtils.animateCrossbowCharge(this.rightArm, this.leftArm, ((IllagerRenderState)state).maxCrossbowChargeDuration, ((IllagerRenderState)state).ticksUsingItem, true);
} else if (pose == AbstractIllager.IllagerArmPose.CELEBRATING) {
this.rightArm.z = 0.0f;
this.rightArm.x = -5.0f;
this.rightArm.xRot = Mth.cos(((IllagerRenderState)state).ageInTicks * 0.6662f) * 0.05f;
this.rightArm.zRot = 2.670354f;
this.rightArm.yRot = 0.0f;
this.leftArm.z = 0.0f;
this.leftArm.x = 5.0f;
this.leftArm.xRot = Mth.cos(((IllagerRenderState)state).ageInTicks * 0.6662f) * 0.05f;
this.leftArm.zRot = -2.3561945f;
this.leftArm.yRot = 0.0f;
}
this.arms.visible = crossedArms = pose == AbstractIllager.IllagerArmPose.CROSSED;
this.leftArm.visible = !crossedArms;
this.rightArm.visible = !crossedArms;
}
private ModelPart getArm(HumanoidArm arm) {
if (arm == HumanoidArm.LEFT) {
return this.leftArm;
}
return this.rightArm;
}
public ModelPart getHat() {
return this.hat;
}
@Override
public ModelPart getHead() {
return this.head;
}
@Override
public void translateToHand(IllagerRenderState state, HumanoidArm arm, PoseStack poseStack) {
this.root.translateAndRotate(poseStack);
this.getArm(arm).translateAndRotate(poseStack);
}
}