94 lines
4.6 KiB
Java
94 lines
4.6 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.model;
|
|
|
|
import net.minecraft.client.model.HumanoidModel;
|
|
import net.minecraft.client.model.PlayerModel;
|
|
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.MeshDefinition;
|
|
import net.minecraft.client.model.geom.builders.PartDefinition;
|
|
import net.minecraft.client.renderer.entity.ArmorModelSet;
|
|
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
|
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
|
import net.minecraft.util.Mth;
|
|
|
|
public class AbstractPiglinModel<S extends HumanoidRenderState>
|
|
extends HumanoidModel<S> {
|
|
private static final String LEFT_SLEEVE = "left_sleeve";
|
|
private static final String RIGHT_SLEEVE = "right_sleeve";
|
|
private static final String LEFT_PANTS = "left_pants";
|
|
private static final String RIGHT_PANTS = "right_pants";
|
|
public final ModelPart leftSleeve;
|
|
public final ModelPart rightSleeve;
|
|
public final ModelPart leftPants;
|
|
public final ModelPart rightPants;
|
|
public final ModelPart jacket;
|
|
public final ModelPart rightEar;
|
|
public final ModelPart leftEar;
|
|
|
|
public AbstractPiglinModel(ModelPart root) {
|
|
super(root, RenderTypes::entityTranslucent);
|
|
this.leftSleeve = this.leftArm.getChild(LEFT_SLEEVE);
|
|
this.rightSleeve = this.rightArm.getChild(RIGHT_SLEEVE);
|
|
this.leftPants = this.leftLeg.getChild(LEFT_PANTS);
|
|
this.rightPants = this.rightLeg.getChild(RIGHT_PANTS);
|
|
this.jacket = this.body.getChild("jacket");
|
|
this.rightEar = this.head.getChild("right_ear");
|
|
this.leftEar = this.head.getChild("left_ear");
|
|
}
|
|
|
|
public static MeshDefinition createMesh(CubeDeformation g) {
|
|
MeshDefinition mesh = PlayerModel.createMesh(g, false);
|
|
PartDefinition root = mesh.getRoot();
|
|
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(16, 16).addBox(-4.0f, 0.0f, -2.0f, 8.0f, 12.0f, 4.0f, g), PartPose.ZERO);
|
|
PartDefinition head = AbstractPiglinModel.addHead(g, mesh);
|
|
head.clearChild("hat");
|
|
return mesh;
|
|
}
|
|
|
|
public static ArmorModelSet<MeshDefinition> createArmorMeshSet(CubeDeformation innerDeformation, CubeDeformation outerDeformation) {
|
|
return PlayerModel.createArmorMeshSet(innerDeformation, outerDeformation).map(mesh -> {
|
|
PartDefinition root = mesh.getRoot();
|
|
PartDefinition head = root.getChild("head");
|
|
head.addOrReplaceChild("left_ear", CubeListBuilder.create(), PartPose.ZERO);
|
|
head.addOrReplaceChild("right_ear", CubeListBuilder.create(), PartPose.ZERO);
|
|
return mesh;
|
|
});
|
|
}
|
|
|
|
public static PartDefinition addHead(CubeDeformation g, MeshDefinition mesh) {
|
|
PartDefinition root = mesh.getRoot();
|
|
PartDefinition head = root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0f, -8.0f, -4.0f, 10.0f, 8.0f, 8.0f, g).texOffs(31, 1).addBox(-2.0f, -4.0f, -5.0f, 4.0f, 4.0f, 1.0f, g).texOffs(2, 4).addBox(2.0f, -2.0f, -5.0f, 1.0f, 2.0f, 1.0f, g).texOffs(2, 0).addBox(-3.0f, -2.0f, -5.0f, 1.0f, 2.0f, 1.0f, g), PartPose.ZERO);
|
|
head.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(51, 6).addBox(0.0f, 0.0f, -2.0f, 1.0f, 5.0f, 4.0f, g), PartPose.offsetAndRotation(4.5f, -6.0f, 0.0f, 0.0f, 0.0f, -0.5235988f));
|
|
head.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(39, 6).addBox(-1.0f, 0.0f, -2.0f, 1.0f, 5.0f, 4.0f, g), PartPose.offsetAndRotation(-4.5f, -6.0f, 0.0f, 0.0f, 0.0f, 0.5235988f));
|
|
return head;
|
|
}
|
|
|
|
@Override
|
|
public void setupAnim(S state) {
|
|
super.setupAnim(state);
|
|
float animationPos = ((HumanoidRenderState)state).walkAnimationPos;
|
|
float animationSpeed = ((HumanoidRenderState)state).walkAnimationSpeed;
|
|
float defaultAngle = 0.5235988f;
|
|
float frequency = ((HumanoidRenderState)state).ageInTicks * 0.1f + animationPos * 0.5f;
|
|
float amplitude = 0.08f + animationSpeed * 0.4f;
|
|
this.leftEar.zRot = -0.5235988f - Mth.cos(frequency * 1.2f) * amplitude;
|
|
this.rightEar.zRot = 0.5235988f + Mth.cos(frequency) * amplitude;
|
|
}
|
|
|
|
@Override
|
|
public void setAllVisible(boolean visible) {
|
|
super.setAllVisible(visible);
|
|
this.leftSleeve.visible = visible;
|
|
this.rightSleeve.visible = visible;
|
|
this.leftPants.visible = visible;
|
|
this.rightPants.visible = visible;
|
|
this.jacket.visible = visible;
|
|
}
|
|
}
|
|
|