| 1 | package net.minecraft.client.model.animal.turtle;
|
| 2 |
|
| 3 | import java.util.function.Function;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.client.model.QuadrupedModel;
|
| 7 | import net.minecraft.client.model.geom.ModelPart;
|
| 8 | import net.minecraft.client.renderer.entity.state.TurtleRenderState;
|
| 9 | import net.minecraft.client.renderer.rendertype.RenderType;
|
| 10 | import net.minecraft.resources.Identifier;
|
| 11 | import net.minecraft.util.Mth;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public abstract class TurtleModel extends QuadrupedModel<TurtleRenderState> {
|
| 15 | public TurtleModel(final ModelPart root, final Function<Identifier, RenderType> renderType) {
|
| 16 | super(root, renderType);
|
| 17 | }
|
| 18 |
|
| 19 | public void setupAnim(final TurtleRenderState state) {
|
| 20 | super.setupAnim(state);
|
| 21 | float animationPos = state.walkAnimationPos;
|
| 22 | float animationSpeed = state.walkAnimationSpeed;
|
| 23 | if (state.isOnLand) {
|
| 24 | float layEgg = state.isLayingEgg ? 4.0F : 1.0F;
|
| 25 | float layEggAmplitude = state.isLayingEgg ? 2.0F : 1.0F;
|
| 26 | float swingPos = animationPos * 5.0F;
|
| 27 | float frontSwing = Mth.cos(layEgg * swingPos);
|
| 28 | float hindSwing = Mth.cos(swingPos);
|
| 29 | this.rightFrontLeg.yRot = -frontSwing * 8.0F * animationSpeed * layEggAmplitude;
|
| 30 | this.leftFrontLeg.yRot = frontSwing * 8.0F * animationSpeed * layEggAmplitude;
|
| 31 | this.rightHindLeg.yRot = -hindSwing * 3.0F * animationSpeed;
|
| 32 | this.leftHindLeg.yRot = hindSwing * 3.0F * animationSpeed;
|
| 33 | } else {
|
| 34 | float swingScale = 0.5F * animationSpeed;
|
| 35 | float swing = Mth.cos(animationPos * 0.6662F * 0.6F) * swingScale;
|
| 36 | this.rightHindLeg.xRot = swing;
|
| 37 | this.leftHindLeg.xRot = -swing;
|
| 38 | this.rightFrontLeg.zRot = -swing;
|
| 39 | this.leftFrontLeg.zRot = swing;
|
| 40 | }
|
| 41 | }
|
| 42 | }
|
| 43 |
|