From aa53cb5eb4a4ad57e90d6dcb4ffdea74297dd4a2 Mon Sep 17 00:00:00 2001 From: N1nn1 <64173061+N1nn1@users.noreply.github.com> Date: Mon, 6 May 2024 04:21:49 +0200 Subject: [PATCH] Poses, size and animation --- .../client/animation/SunfishAnimation.java | 263 ++++++++++++++++++ .../spawn/client/model/SunfishModel.java | 38 ++- .../com/ninni/spawn/entity/AnglerFish.java | 3 +- .../java/com/ninni/spawn/entity/Clam.java | 1 - .../java/com/ninni/spawn/entity/Herring.java | 2 +- .../java/com/ninni/spawn/entity/Octopus.java | 17 +- .../java/com/ninni/spawn/entity/SeaCow.java | 5 +- .../java/com/ninni/spawn/entity/Sunfish.java | 72 ++++- .../java/com/ninni/spawn/entity/Tuna.java | 3 +- .../java/com/ninni/spawn/entity/Whale.java | 3 +- .../java/com/ninni/spawn/mixin/PoseMixin.java | 41 +++ .../ninni/spawn/registry/SpawnEntityType.java | 2 +- .../com/ninni/spawn/registry/SpawnPose.java | 12 + .../spawn/registry/SpawnSoundEvents.java | 7 - .../registry/SpawnVanillaIntegration.java | 6 +- .../resources/assets/spawn/lang/en_us.json | 6 +- .../models/item/baby_sunfish_bucket.json | 8 +- src/main/resources/assets/spawn/sounds.json | 1 - src/main/resources/spawn.mixins.json | 1 + 19 files changed, 447 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/ninni/spawn/client/animation/SunfishAnimation.java create mode 100644 src/main/java/com/ninni/spawn/mixin/PoseMixin.java create mode 100644 src/main/java/com/ninni/spawn/registry/SpawnPose.java diff --git a/src/main/java/com/ninni/spawn/client/animation/SunfishAnimation.java b/src/main/java/com/ninni/spawn/client/animation/SunfishAnimation.java new file mode 100644 index 0000000..df1c6da --- /dev/null +++ b/src/main/java/com/ninni/spawn/client/animation/SunfishAnimation.java @@ -0,0 +1,263 @@ +package com.ninni.spawn.client.animation; + +import net.minecraft.client.animation.AnimationChannel; +import net.minecraft.client.animation.AnimationDefinition; +import net.minecraft.client.animation.Keyframe; +import net.minecraft.client.animation.KeyframeAnimations; + +public class SunfishAnimation { + + public static final AnimationDefinition IDLE = AnimationDefinition.Builder.withLength(4.0F).looping() + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(1.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(1.73F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(2.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(1.73F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(1.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.degreeVec(-1.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.degreeVec(-1.73F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.degreeVec(-2.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.degreeVec(-1.73F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.degreeVec(-1.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.posVec(0.0F, 0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.posVec(0.0F, 0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.posVec(0.0F, 0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.posVec(0.0F, 0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.posVec(0.0F, -0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.posVec(0.0F, -0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.posVec(0.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.posVec(0.0F, -0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.posVec(0.0F, -0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("topFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("leftFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 30.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 27.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -7.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -7.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 27.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 30.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("bottomFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -2.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 1.73F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 2.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("rightFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -30.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -27.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 7.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 7.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.3333F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -27.32F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -30.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .build(); + + public static final AnimationDefinition SWIM = AnimationDefinition.Builder.withLength(2.0F).looping() + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 6.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(0.0F, 5.2F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 3.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, -3.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.degreeVec(0.0F, -5.2F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, -6.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.degreeVec(0.0F, -5.2F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, -3.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 3.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.degreeVec(0.0F, 5.2F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 6.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.posVec(0.0F, 0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.posVec(0.0F, 0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.posVec(0.0F, 0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.posVec(0.0F, 0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.posVec(0.0F, -0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.posVec(0.0F, -0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.posVec(0.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.posVec(0.0F, -0.87F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.posVec(0.0F, -0.5F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("topFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 40.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(4.0F, 0.0F, 34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(6.93F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(8.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(6.93F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.degreeVec(4.0F, 0.0F, -34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -40.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.degreeVec(-4.0F, 0.0F, -34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(-6.93F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(-8.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(-6.93F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.degreeVec(-4.0F, 0.0F, 34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 40.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("tailFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(0.0F, 17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, -17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.degreeVec(0.0F, -17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.degreeVec(0.0F, 17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, -17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, 17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.degreeVec(0.0F, -17.32F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("bottomFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -40.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-4.0F, 0.0F, -34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(-6.93F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(-8.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(-6.93F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.degreeVec(-4.0F, 0.0F, 34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 40.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.degreeVec(4.0F, 0.0F, 34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(6.93F, 0.0F, 20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(8.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(6.93F, 0.0F, -20.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.degreeVec(4.0F, 0.0F, -34.64F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -40.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .build(); + + public static final AnimationDefinition FLOP = AnimationDefinition.Builder.withLength(12.0F) + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75F, KeyframeAnimations.degreeVec(-4.9953F, -0.2178F, -47.4905F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(10.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(11.25F, KeyframeAnimations.degreeVec(-4.9953F, -0.2178F, -47.4905F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(12.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .build(); + + public static final AnimationDefinition LAND = AnimationDefinition.Builder.withLength(2.0F).looping() + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(-5.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.degreeVec(-5.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(-5.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(-4.9811F, 0.4352F, -85.0189F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(-4.9811F, -0.4352F, -94.9811F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(-5.0F, 0.0F, -90.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("all", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, -10.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.posVec(0.0F, -10.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, -10.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.posVec(0.0F, -6.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.posVec(0.0F, -6.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, -10.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("topFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -7.5F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -15.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -15.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -27.5F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 5.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -7.5F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("topFin", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.posVec(1.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.posVec(1.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.posVec(1.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("tailFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(0.0F, 10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.3333F, KeyframeAnimations.degreeVec(0.0F, 10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, -10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8333F, KeyframeAnimations.degreeVec(0.0F, -10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1667F, KeyframeAnimations.degreeVec(0.0F, 10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3333F, KeyframeAnimations.degreeVec(0.0F, 10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6667F, KeyframeAnimations.degreeVec(0.0F, -10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.8333F, KeyframeAnimations.degreeVec(0.0F, -10.39F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("leftFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, -42.5F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("bottomFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 7.5F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 15.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 15.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 17.5F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(0.0F, 0.0F, -10.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 7.5F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("bottomFin", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.25F, KeyframeAnimations.posVec(1.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5F, KeyframeAnimations.posVec(1.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.6667F, KeyframeAnimations.posVec(1.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.7917F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM) + )) + .addAnimation("rightFin", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 42.5F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .build(); +} diff --git a/src/main/java/com/ninni/spawn/client/model/SunfishModel.java b/src/main/java/com/ninni/spawn/client/model/SunfishModel.java index dabcfda..8593b81 100644 --- a/src/main/java/com/ninni/spawn/client/model/SunfishModel.java +++ b/src/main/java/com/ninni/spawn/client/model/SunfishModel.java @@ -1,5 +1,6 @@ package com.ninni.spawn.client.model; +import com.ninni.spawn.client.animation.SunfishAnimation; import com.ninni.spawn.entity.Sunfish; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -7,6 +8,7 @@ import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.*; +import net.minecraft.util.Mth; @Environment(value= EnvType.CLIENT) @SuppressWarnings("FieldCanBeLocal, unused") @@ -34,8 +36,40 @@ public SunfishModel(ModelPart root) { @Override - public void setupAnim(Sunfish entity, float f, float g, float h, float i, float j) { - + public void setupAnim(Sunfish entity, float limbSwing, float limbSwingAmount, float animationProgress, float headYaw, float headPitch) { + float pi = (float)Math.PI; + this.root.getAllParts().forEach(ModelPart::resetPose); + + + if (!entity.isBaby()) { + this.all.y = 11.0F; + this.all.yRot = 0; + this.all.zRot = 0; + this.tailFin.yRot = 0; + this.leftFin.yRot = 0; + this.rightFin.yRot = 0; + this.topFin.zRot = 0; + this.bottomFin.zRot = 0; + + if (entity.isInWaterOrBubble()) { + this.animateWalk(SunfishAnimation.SWIM, limbSwing, limbSwingAmount, 1.5f, 8.0f); + this.animate(entity.idleAnimationState, SunfishAnimation.IDLE, animationProgress, 1.0f); + this.animate(entity.flopAnimationState, SunfishAnimation.FLOP, animationProgress, 1.0f); + } + else this.animate(entity.landAnimationState, SunfishAnimation.LAND, animationProgress, 1.0f); + } else { + this.all.zRot = pi/2; + this.all.y = Mth.cos(animationProgress * 0.2F) * 1.5F * 0.25F + (entity.getSunfishAge() == -2 ? 22.5F : 19.0F); + this.all.yRot = Mth.cos(animationProgress * 0.2F) * 0.4F * 0.25F; + this.tailFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F; + this.leftFin.yRot = Mth.cos(animationProgress * 0.4F) * 0.8F * 0.25F + 0.8F; + this.rightFin.yRot = Mth.cos(animationProgress * 0.4F + pi) * 0.8F * 0.25F - 0.8F; + this.topFin.zRot = Mth.cos(animationProgress * 0.4F) * 1.6F * 0.25F; + this.bottomFin.zRot = Mth.cos(animationProgress * 0.4F + pi) * 1.6F * 0.25F; + + this.all.xRot += headPitch * (float) (Math.PI / 180); + this.all.yRot += headYaw * (float) (Math.PI / 180); + } } @Override diff --git a/src/main/java/com/ninni/spawn/entity/AnglerFish.java b/src/main/java/com/ninni/spawn/entity/AnglerFish.java index 12fcc74..67aac3c 100644 --- a/src/main/java/com/ninni/spawn/entity/AnglerFish.java +++ b/src/main/java/com/ninni/spawn/entity/AnglerFish.java @@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; @@ -157,7 +158,7 @@ protected SoundEvent getSwimSound() { @Nullable @Override protected SoundEvent getAmbientSound() { - return SpawnSoundEvents.FISH_AMBIENT; + return SoundEvents.EMPTY; } @Nullable diff --git a/src/main/java/com/ninni/spawn/entity/Clam.java b/src/main/java/com/ninni/spawn/entity/Clam.java index 7cac9f5..e5ef78a 100644 --- a/src/main/java/com/ninni/spawn/entity/Clam.java +++ b/src/main/java/com/ninni/spawn/entity/Clam.java @@ -75,7 +75,6 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverLevelAccessor, Dif protected InteractionResult mobInteract(Player player, InteractionHand interactionHand) { ItemStack itemStack = player.getItemInHand(interactionHand); if ((itemStack.isEmpty() || itemStack.getItem() instanceof ClamCaseItem) && this.isAlive()) { - //TODO sound this.playSound(SoundEvents.EMPTY, 1.0f, 1.0f); ItemStack itemStack2 = this.getItemStack(); saveToBucketTag(itemStack2); diff --git a/src/main/java/com/ninni/spawn/entity/Herring.java b/src/main/java/com/ninni/spawn/entity/Herring.java index feef98a..86ab278 100644 --- a/src/main/java/com/ninni/spawn/entity/Herring.java +++ b/src/main/java/com/ninni/spawn/entity/Herring.java @@ -38,7 +38,7 @@ public ItemStack getBucketItemStack() { @Override protected SoundEvent getAmbientSound() { - return SpawnSoundEvents.FISH_AMBIENT; + return SoundEvents.EMPTY; } @Override diff --git a/src/main/java/com/ninni/spawn/entity/Octopus.java b/src/main/java/com/ninni/spawn/entity/Octopus.java index c83fa9e..913d965 100644 --- a/src/main/java/com/ninni/spawn/entity/Octopus.java +++ b/src/main/java/com/ninni/spawn/entity/Octopus.java @@ -323,6 +323,7 @@ public boolean canBeLeashed(Player player) { return false; } + //TODO replace with hashmap public static int getId(Item item) { if (item == Items.BUCKET) return 0; else if (item == Items.GLASS_BOTTLE) return 1; @@ -373,22 +374,6 @@ public void tick() { } } - static class OctopusLookControl extends GoodAmphibiousMovement.GoodAmphibiousLookControl { - private final Octopus octopus; - - public OctopusLookControl(Octopus octopus) { - super(octopus); - this.octopus = octopus; - } - - @Override - public void tick() { - if (!this.octopus.isLocking()) { - super.tick(); - } - } - } - public class OctopusRandomSwim extends RandomSwimmingGoal { public OctopusRandomSwim(PathfinderMob pathfinderMob) { diff --git a/src/main/java/com/ninni/spawn/entity/SeaCow.java b/src/main/java/com/ninni/spawn/entity/SeaCow.java index 50ddc14..d32a16a 100644 --- a/src/main/java/com/ninni/spawn/entity/SeaCow.java +++ b/src/main/java/com/ninni/spawn/entity/SeaCow.java @@ -2,6 +2,7 @@ import com.ninni.spawn.SpawnTags; import com.ninni.spawn.entity.ai.goal.EatSeagrassGoal; +import com.ninni.spawn.entity.common.DeepLurker; import com.ninni.spawn.registry.SpawnBlocks; import com.ninni.spawn.registry.SpawnParticleTypes; import com.ninni.spawn.registry.SpawnSoundEvents; @@ -55,7 +56,7 @@ import static com.ninni.spawn.Spawn.MOD_ID; -public class SeaCow extends WaterAnimal implements Shearable { +public class SeaCow extends WaterAnimal implements Shearable, DeepLurker { public static final ResourceLocation LOOT_COMMON = new ResourceLocation(MOD_ID, "archaeology/sea_cow_common"); public static final ResourceLocation LOOT_RARE = new ResourceLocation(MOD_ID, "archaeology/sea_cow_rare"); private static final EntityDataAccessor ALGAE = SynchedEntityData.defineId(SeaCow.class, EntityDataSerializers.INT); @@ -80,9 +81,9 @@ protected void registerGoals() { this.goalSelector.addGoal(0, this.eatBlockGoal); this.goalSelector.addGoal(1, new AvoidEntityGoal<>(this, Guardian.class, 8.0f, 1.0, 1.0)); this.goalSelector.addGoal(2, new RandomSwimmingGoal(this, 1.0, 10)); + this.goalSelector.addGoal(3, new MoveToSeagrassGoal(1.2f, 12, 1)); this.goalSelector.addGoal(3, new RandomLookAroundGoal(this)); this.goalSelector.addGoal(4, new LookAtPlayerGoal(this, Player.class, 6.0f)); - this.goalSelector.addGoal(5, new MoveToSeagrassGoal(1.2f, 12, 1)); } public static AttributeSupplier.Builder createAttributes() { diff --git a/src/main/java/com/ninni/spawn/entity/Sunfish.java b/src/main/java/com/ninni/spawn/entity/Sunfish.java index c7b7198..5d8d9b4 100644 --- a/src/main/java/com/ninni/spawn/entity/Sunfish.java +++ b/src/main/java/com/ninni/spawn/entity/Sunfish.java @@ -2,6 +2,7 @@ import com.ninni.spawn.SpawnTags; import com.ninni.spawn.registry.SpawnItems; +import com.ninni.spawn.registry.SpawnPose; import com.ninni.spawn.registry.SpawnSoundEvents; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -10,14 +11,17 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; import net.minecraft.util.RandomSource; +import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.control.SmoothSwimmingLookControl; import net.minecraft.world.entity.ai.control.SmoothSwimmingMoveControl; import net.minecraft.world.entity.ai.goal.*; import net.minecraft.world.entity.ai.navigation.PathNavigation; @@ -35,14 +39,21 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; + public class Sunfish extends PathfinderMob implements Bucketable { private static final EntityDataAccessor AGE = SynchedEntityData.defineId(Sunfish.class, EntityDataSerializers.INT); private static final EntityDataAccessor FROM_BUCKET = SynchedEntityData.defineId(Sunfish.class, EntityDataSerializers.BOOLEAN); + public final AnimationState idleAnimationState = new AnimationState(); + public final AnimationState landAnimationState = new AnimationState(); + public final AnimationState flopAnimationState = new AnimationState(); + private int idleAnimationTimeout = 0; + private int landAnimationTimeout = 0; public Sunfish(EntityType entityType, Level level) { super(entityType, level); this.setPathfindingMalus(BlockPathTypes.WATER, 0.0f); this.moveControl = new SmoothSwimmingMoveControl(this, 85, 10, 0.02f, 0.1f, true); + this.lookControl = new SmoothSwimmingLookControl(this, 10); } @Override @@ -56,7 +67,7 @@ protected void registerGoals() { } public static AttributeSupplier.Builder createAttributes() { - return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 30.0).add(Attributes.MOVEMENT_SPEED, 0.2f); + return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 30.0).add(Attributes.MOVEMENT_SPEED, 0.8f); } //@Override @@ -65,6 +76,13 @@ public static AttributeSupplier.Builder createAttributes() { //} + @Nullable + @Override + public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverLevelAccessor, DifficultyInstance difficultyInstance, MobSpawnType mobSpawnType, @Nullable SpawnGroupData spawnGroupData, @Nullable CompoundTag compoundTag) { + + return super.finalizeSpawn(serverLevelAccessor, difficultyInstance, mobSpawnType, spawnGroupData, compoundTag); + } + @Override protected InteractionResult mobInteract(Player player, InteractionHand interactionHand) { if (this.isBaby() && Bucketable.bucketMobPickup(player, interactionHand, this).isPresent()) { @@ -73,6 +91,56 @@ protected InteractionResult mobInteract(Player player, InteractionHand interacti return super.mobInteract(player, interactionHand); } + @Override + public void tick() { + super.tick(); + if (!this.isBaby()) { + if (!this.isInWaterOrBubble()) { + if (this.getPose() != Pose.STANDING) this.setPose(Pose.STANDING); + } else { + if (this.getPose() != Pose.SWIMMING) this.setPose(Pose.SWIMMING); + } + } else { + SpawnPose pose = this.getSunfishAge() == -2 ? SpawnPose.NEWBORN : SpawnPose.BABY; + if (this.getPose() != pose.get()) this.setPose(pose.get()); + } + + if (this.level().isClientSide()) { + this.setupAnimationStates(); + } + } + + @Override + public EntityDimensions getDimensions(Pose pose) { + if (this.isBaby()) { + return pose == SpawnPose.NEWBORN.get() ? EntityDimensions.scalable(0.2F, 0.2F) : EntityDimensions.scalable(0.6F, 0.6F); + } else { + if (pose == Pose.STANDING) return EntityDimensions.scalable(2.2F, 0.5F); + else return EntityDimensions.scalable(1.5F, 2.2F); + } + } + + private void setupAnimationStates() { + if (!this.isBaby()) { + if (this.isInWaterOrBubble()) { + if (this.idleAnimationTimeout <= 0) { + this.idleAnimationTimeout = 20 * 4; + this.idleAnimationState.start(this.tickCount); + } else { + --this.idleAnimationTimeout; + } + } else { + if (this.landAnimationTimeout <= 0) { + this.landAnimationTimeout = 20 * 2; + this.landAnimationState.start(this.tickCount); + } else { + --this.landAnimationTimeout; + } + + } + } + } + public int getSunfishAge() { if (this.isBaby()) return this.getAge() < -12000 ? -2 : -1; return 0; @@ -233,7 +301,7 @@ protected SoundEvent getSwimSound() { @Nullable @Override protected SoundEvent getAmbientSound() { - return SpawnSoundEvents.FISH_AMBIENT; + return SoundEvents.EMPTY; } @Nullable diff --git a/src/main/java/com/ninni/spawn/entity/Tuna.java b/src/main/java/com/ninni/spawn/entity/Tuna.java index 052ac6f..7be4c68 100644 --- a/src/main/java/com/ninni/spawn/entity/Tuna.java +++ b/src/main/java/com/ninni/spawn/entity/Tuna.java @@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; import net.minecraft.stats.Stats; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; @@ -208,7 +209,7 @@ protected SoundEvent getSwimSound() { @Nullable @Override protected SoundEvent getAmbientSound() { - return SpawnSoundEvents.FISH_AMBIENT; + return SoundEvents.EMPTY; } @Nullable diff --git a/src/main/java/com/ninni/spawn/entity/Whale.java b/src/main/java/com/ninni/spawn/entity/Whale.java index 43f19fc..f1fae6a 100644 --- a/src/main/java/com/ninni/spawn/entity/Whale.java +++ b/src/main/java/com/ninni/spawn/entity/Whale.java @@ -7,6 +7,7 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.DamageTypeTags; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; @@ -105,7 +106,7 @@ protected SoundEvent getSwimSound() { @Nullable @Override protected SoundEvent getAmbientSound() { - return SpawnSoundEvents.FISH_AMBIENT; + return SoundEvents.EMPTY; } @Nullable diff --git a/src/main/java/com/ninni/spawn/mixin/PoseMixin.java b/src/main/java/com/ninni/spawn/mixin/PoseMixin.java new file mode 100644 index 0000000..45cdbac --- /dev/null +++ b/src/main/java/com/ninni/spawn/mixin/PoseMixin.java @@ -0,0 +1,41 @@ +package com.ninni.spawn.mixin; + +import com.ninni.spawn.registry.SpawnPose; +import net.minecraft.world.entity.Pose; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.gen.Invoker; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Mixin(Pose.class) +public class PoseMixin { + @Shadow + @Mutable + @Final + private static Pose[] $VALUES; + + @Invoker("") + public static Pose newPose(String name, int id) { + throw new AssertionError(); + } + + @Inject(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Pose;$VALUES:[Lnet/minecraft/world/entity/Pose;", shift = At.Shift.AFTER)) + private static void US$addCustomPose(CallbackInfo ci) { + List poses = new ArrayList<>(Arrays.asList($VALUES)); + Pose last = poses.get(poses.size() - 1); + int i = 1; + for (SpawnPose pose : SpawnPose.values()) { + poses.add(newPose(pose.name(), last.ordinal() + i)); + i++; + } + $VALUES = poses.toArray(new Pose[0]); + } +} \ No newline at end of file diff --git a/src/main/java/com/ninni/spawn/registry/SpawnEntityType.java b/src/main/java/com/ninni/spawn/registry/SpawnEntityType.java index 63ee5c5..bb34810 100644 --- a/src/main/java/com/ninni/spawn/registry/SpawnEntityType.java +++ b/src/main/java/com/ninni/spawn/registry/SpawnEntityType.java @@ -98,7 +98,7 @@ public class SpawnFish{ .defaultAttributes(Sunfish::createAttributes) .spawnGroup(MobCategory.WATER_CREATURE) .spawnRestriction(SpawnPlacements.Type.IN_WATER, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Sunfish::checkSurfaceWaterAnimalSpawnRules) - .dimensions(EntityDimensions.scalable(0.8F, 2F)) + .dimensions(EntityDimensions.scalable(1.5F, 2.2F)) ); public static final EntityType ANGLER_FISH = register( "angler_fish", diff --git a/src/main/java/com/ninni/spawn/registry/SpawnPose.java b/src/main/java/com/ninni/spawn/registry/SpawnPose.java new file mode 100644 index 0000000..adfbc0c --- /dev/null +++ b/src/main/java/com/ninni/spawn/registry/SpawnPose.java @@ -0,0 +1,12 @@ +package com.ninni.spawn.registry; + +import net.minecraft.world.entity.Pose; + +public enum SpawnPose { + NEWBORN, + BABY; + + public Pose get() { + return Pose.valueOf(this.name()); + } +} diff --git a/src/main/java/com/ninni/spawn/registry/SpawnSoundEvents.java b/src/main/java/com/ninni/spawn/registry/SpawnSoundEvents.java index 9c74d03..ca781bb 100644 --- a/src/main/java/com/ninni/spawn/registry/SpawnSoundEvents.java +++ b/src/main/java/com/ninni/spawn/registry/SpawnSoundEvents.java @@ -10,7 +10,6 @@ public interface SpawnSoundEvents { - SoundEvent FISH_AMBIENT = register("entity.fish.ambient"); SoundEvent FISH_FLOP = register("entity.fish.flop"); SoundEvent FISH_SWIM = register("entity.fish.swim"); SoundEvent FISH_HURT = register("entity.fish.hurt"); @@ -76,12 +75,6 @@ public interface SpawnSoundEvents { SoundEvent ROTTEN_WOOD_TRAPDOOR_OPEN = register("block.rotten_wood_trapdoor.open"); SoundEvent ROTTEN_WOOD_TRAPDOOR_CLOSE = register("block.rotten_wood_trapdoor.close"); - //TODO sounds for: - //Algal sand - //Sea cows - //Fish customizer - //Whale - //Whale blocks SoundEvent MUSIC_DISC_BLINK = register("music_disc.blink"); diff --git a/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java b/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java index 5147ce3..e940e52 100644 --- a/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java +++ b/src/main/java/com/ninni/spawn/registry/SpawnVanillaIntegration.java @@ -171,10 +171,10 @@ private static void registerItemModelPredicates() { if (compoundTag != null && compoundTag.contains("Age", 3)) { int a = compoundTag.getInt("Age"); - if (a < -12000) return 0.25f; - else return 0.5f; + if (a < -12000) return 0f; + else return 1f; } - return 0.0F; + return 1f; }); ItemProperties.register(SpawnItems.CLAM_CASE, new ResourceLocation("filled"), (itemStack, clientLevel, livingEntity, i) -> ClamCaseItem.getFullnessDisplay(itemStack)); diff --git a/src/main/resources/assets/spawn/lang/en_us.json b/src/main/resources/assets/spawn/lang/en_us.json index f8f87ca..dca9404 100644 --- a/src/main/resources/assets/spawn/lang/en_us.json +++ b/src/main/resources/assets/spawn/lang/en_us.json @@ -206,5 +206,9 @@ "entity.spawn.krill_swarm": "Krill Swarm", "item.spawn.krill_swarm_spawn_egg": "Krill Swarm Spawn Egg", - "item.spawn.krill_swarm_bucket": "Bucket of Krill Swarm" + "item.spawn.krill_swarm_bucket": "Bucket of Krill Swarm", + + "entity.spawn.sunfish": "Sunfish", + "item.spawn.sunfish_spawn_egg": "Sunfish Spawn Egg", + "item.spawn.baby_sunfish_bucket": "Bucket of Baby Sunfish" } \ No newline at end of file diff --git a/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json b/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json index 9e451c5..f9419b7 100644 --- a/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json +++ b/src/main/resources/assets/spawn/models/item/baby_sunfish_bucket.json @@ -6,15 +6,15 @@ "overrides": [ { "predicate": { - "variant": 0.25 + "age": 0 }, - "model": "spawn:item/baby_sunfish_bucket_baby" + "model": "spawn:item/baby_sunfish_bucket_newborn" }, { "predicate": { - "variant": 0.5 + "age": 1 }, - "model": "spawn:item/baby_sunfish_bucket_newborn" + "model": "spawn:item/baby_sunfish_bucket_baby" } ] } diff --git a/src/main/resources/assets/spawn/sounds.json b/src/main/resources/assets/spawn/sounds.json index 2e4a903..5e53cf6 100644 --- a/src/main/resources/assets/spawn/sounds.json +++ b/src/main/resources/assets/spawn/sounds.json @@ -26,7 +26,6 @@ ], "subtitle": "subtitles.entity.spawn.fish.death" }, - "entity.fish.ambient": { "sounds": [], "subtitle": "subtitles.entity.spawn.fish.ambient" }, "entity.fish.jump": { "sounds": [ "spawn:entity/fish/jump1", diff --git a/src/main/resources/spawn.mixins.json b/src/main/resources/spawn.mixins.json index ad270fb..28a82bd 100644 --- a/src/main/resources/spawn.mixins.json +++ b/src/main/resources/spawn.mixins.json @@ -14,6 +14,7 @@ "MobBucketItemMixin", "OverworldBiomeBuilderMixin", "PlayerMixin", + "PoseMixin", "ServerPlayerMixin", "accessor.NoiseGeneratorSettingsAccessor", "accessor.PlayerAccessor",