74 lines
4.0 KiB
Java
74 lines
4.0 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.QuadrupedModel;
|
|
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.TurtleRenderState;
|
|
import net.minecraft.util.Mth;
|
|
|
|
public class TurtleModel
|
|
extends QuadrupedModel<TurtleRenderState> {
|
|
private static final String EGG_BELLY = "egg_belly";
|
|
public static final MeshTransformer BABY_TRANSFORMER = new BabyModelTransform(true, 120.0f, 0.0f, 9.0f, 6.0f, 120.0f, Set.of("head"));
|
|
private final ModelPart eggBelly;
|
|
|
|
public TurtleModel(ModelPart root) {
|
|
super(root);
|
|
this.eggBelly = root.getChild(EGG_BELLY);
|
|
}
|
|
|
|
public static LayerDefinition createBodyLayer() {
|
|
MeshDefinition mesh = new MeshDefinition();
|
|
PartDefinition root = mesh.getRoot();
|
|
root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(3, 0).addBox(-3.0f, -1.0f, -3.0f, 6.0f, 5.0f, 6.0f), PartPose.offset(0.0f, 19.0f, -10.0f));
|
|
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(7, 37).addBox("shell", -9.5f, 3.0f, -10.0f, 19.0f, 20.0f, 6.0f).texOffs(31, 1).addBox("belly", -5.5f, 3.0f, -13.0f, 11.0f, 18.0f, 3.0f), PartPose.offsetAndRotation(0.0f, 11.0f, -10.0f, 1.5707964f, 0.0f, 0.0f));
|
|
root.addOrReplaceChild(EGG_BELLY, CubeListBuilder.create().texOffs(70, 33).addBox(-4.5f, 3.0f, -14.0f, 9.0f, 18.0f, 1.0f), PartPose.offsetAndRotation(0.0f, 11.0f, -10.0f, 1.5707964f, 0.0f, 0.0f));
|
|
boolean legHeight = true;
|
|
root.addOrReplaceChild("right_hind_leg", CubeListBuilder.create().texOffs(1, 23).addBox(-2.0f, 0.0f, 0.0f, 4.0f, 1.0f, 10.0f), PartPose.offset(-3.5f, 22.0f, 11.0f));
|
|
root.addOrReplaceChild("left_hind_leg", CubeListBuilder.create().texOffs(1, 12).addBox(-2.0f, 0.0f, 0.0f, 4.0f, 1.0f, 10.0f), PartPose.offset(3.5f, 22.0f, 11.0f));
|
|
root.addOrReplaceChild("right_front_leg", CubeListBuilder.create().texOffs(27, 30).addBox(-13.0f, 0.0f, -2.0f, 13.0f, 1.0f, 5.0f), PartPose.offset(-5.0f, 21.0f, -4.0f));
|
|
root.addOrReplaceChild("left_front_leg", CubeListBuilder.create().texOffs(27, 24).addBox(0.0f, 0.0f, -2.0f, 13.0f, 1.0f, 5.0f), PartPose.offset(5.0f, 21.0f, -4.0f));
|
|
return LayerDefinition.create(mesh, 128, 64);
|
|
}
|
|
|
|
@Override
|
|
public void setupAnim(TurtleRenderState state) {
|
|
super.setupAnim(state);
|
|
float animationPos = state.walkAnimationPos;
|
|
float animationSpeed = state.walkAnimationSpeed;
|
|
if (state.isOnLand) {
|
|
float layEgg = state.isLayingEgg ? 4.0f : 1.0f;
|
|
float layEggAmplitude = state.isLayingEgg ? 2.0f : 1.0f;
|
|
float swingPos = animationPos * 5.0f;
|
|
float frontSwing = Mth.cos(layEgg * swingPos);
|
|
float hindSwing = Mth.cos(swingPos);
|
|
this.rightFrontLeg.yRot = -frontSwing * 8.0f * animationSpeed * layEggAmplitude;
|
|
this.leftFrontLeg.yRot = frontSwing * 8.0f * animationSpeed * layEggAmplitude;
|
|
this.rightHindLeg.yRot = -hindSwing * 3.0f * animationSpeed;
|
|
this.leftHindLeg.yRot = hindSwing * 3.0f * animationSpeed;
|
|
} else {
|
|
float swing;
|
|
float swingScale = 0.5f * animationSpeed;
|
|
this.rightHindLeg.xRot = swing = Mth.cos(animationPos * 0.6662f * 0.6f) * swingScale;
|
|
this.leftHindLeg.xRot = -swing;
|
|
this.rightFrontLeg.zRot = -swing;
|
|
this.leftFrontLeg.zRot = swing;
|
|
}
|
|
this.eggBelly.visible = state.hasEgg;
|
|
if (this.eggBelly.visible) {
|
|
this.root.y -= 1.0f;
|
|
}
|
|
}
|
|
}
|
|
|