Skip to content

Commit

Permalink
Animation updates to sharks, fish, and manglerfish
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticKoko committed Dec 2, 2024
1 parent 92e5c89 commit 766d311
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
import software.bernie.geckolib.core.animation.AnimatableManager
import software.bernie.geckolib.core.animation.AnimationController
import software.bernie.geckolib.core.animation.AnimationState
import software.bernie.geckolib.core.animation.EasingType
import software.bernie.geckolib.util.GeckoLibUtil

@Suppress("LeakingThis", "UNUSED_PARAMETER")
Expand Down Expand Up @@ -131,7 +130,7 @@ open class HybridAquaticFishEntity(
return
}

if (isWet) {
if (isSubmergedInWater) {
moistness = getMaxMoistness()
} else {
moistness -= 1
Expand Down Expand Up @@ -310,17 +309,14 @@ open class HybridAquaticFishEntity(
//#region Animations
override fun registerControllers(controllerRegistrar: AnimatableManager.ControllerRegistrar) {
controllerRegistrar.add(
AnimationController(
this,
"Swim/Idle",
20
) { state: AnimationState<HybridAquaticFishEntity> ->
if (state.isMoving) {
state.setAndContinue(DefaultAnimations.SWIM)
} else {
state.setAndContinue(DefaultAnimations.IDLE)
}
}.setOverrideEasingType(EasingType.EASE_IN_OUT_SINE)
AnimationController(this, "Swim/Idle", 5,
AnimationController.AnimationStateHandler { state: AnimationState<HybridAquaticFishEntity> ->
if (state.isMoving) {
return@AnimationStateHandler state.setAndContinue(DefaultAnimations.SWIM)
} else {
return@AnimationStateHandler state.setAndContinue(DefaultAnimations.IDLE)
}
})
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import software.bernie.geckolib.constant.DefaultAnimations
import software.bernie.geckolib.core.animation.AnimatableManager
import software.bernie.geckolib.core.animation.AnimationController
import software.bernie.geckolib.core.animation.AnimationState
import software.bernie.geckolib.core.`object`.PlayState

class ManglerfishEntity(entityType: EntityType<out HybridAquaticMinibossEntity>, world: World) :
HybridAquaticMinibossEntity(entityType, world) {
Expand Down Expand Up @@ -126,13 +125,7 @@ class ManglerfishEntity(entityType: EntityType<out HybridAquaticMinibossEntity>,
})
)
controllerRegistrar.add(
AnimationController(this, "Attack", 0,
AnimationController.AnimationStateHandler { state: AnimationState<HybridAquaticMinibossEntity> ->
if (this.handSwinging) return@AnimationStateHandler state.setAndContinue(DefaultAnimations.ATTACK_BITE)
state.controller.forceAnimationReset()
PlayState.STOP
})
)
DefaultAnimations.genericAttackAnimation(this, DefaultAnimations.ATTACK_BITE))
}

//#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache
import software.bernie.geckolib.core.animation.AnimatableManager
import software.bernie.geckolib.core.animation.AnimationController
import software.bernie.geckolib.core.animation.AnimationState
import software.bernie.geckolib.core.animation.EasingType
import software.bernie.geckolib.util.GeckoLibUtil
import java.util.*

Expand Down Expand Up @@ -234,23 +233,17 @@ open class HybridAquaticSharkEntity(
//#region Animations
override fun registerControllers(controllerRegistrar: AnimatableManager.ControllerRegistrar) {
controllerRegistrar.add(
AnimationController(
this,
"Swim/Run",
20
) { state: AnimationState<HybridAquaticSharkEntity> ->
if (!this.isSubmergedInWater && isOnGround) {
state.setAndContinue(DefaultAnimations.SIT)
} else {
AnimationController(this, "Walk/Run/Idle", 0,
AnimationController.AnimationStateHandler { state: AnimationState<HybridAquaticSharkEntity> ->
if (state.isMoving) {
state.setAndContinue(if (this.isSprinting) DefaultAnimations.RUN else DefaultAnimations.SWIM)
return@AnimationStateHandler state.setAndContinue(if (this.isSprinting) DefaultAnimations.RUN else DefaultAnimations.SWIM)
} else {
state.setAndContinue(DefaultAnimations.SWIM)
return@AnimationStateHandler state.setAndContinue(DefaultAnimations.SWIM)
}
}
}.setOverrideEasingType(EasingType.EASE_IN_OUT_SINE)
})
)
controllerRegistrar.add(DefaultAnimations.genericAttackAnimation(this, DefaultAnimations.ATTACK_BITE))
controllerRegistrar.add(
DefaultAnimations.genericAttackAnimation(this, DefaultAnimations.ATTACK_BITE))
}

override fun getAnimatableInstanceCache(): AnimatableInstanceCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,49 @@
},
"move.swim": {
"loop": true,
"animation_length": 1,
"animation_length": 2,
"bones": {
"body": {
"rotation": [0, "Math.sin(query.anim_time * 360)*-5", 0]
"rotation": [0, "Math.sin(query.anim_time * 180)*-5", 0]
},
"body_2": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"tail": {
"rotation": [0, "Math.cos(query.anim_time * 360)*22.5", 0]
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"tail_fin": {
"rotation": [0, "Math.sin(query.anim_time * 180)*15", 0]
},
"right_fin": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"left_fin": {
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
}
}
},
"move.run": {
"loop": true,
"animation_length": 1,
"bones": {
"body": {
"rotation": [0, "Math.sin(query.anim_time * 360)*-10", 0]
},
"body_2": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"tail": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"tail_fin": {
"rotation": [0, "Math.sin(query.anim_time * 360)*15", 0]
},
"right_fin": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"left_fin": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,72 @@
"loop": true,
"animation_length": 4,
"bones": {
"pelvic_fin": {
"rotation": {
"vector": [0, 0, "Math.sin(query.anim_time * 90)*10"]
}
"body": {
"rotation": ["Math.cos(query.anim_time * 90)*2.5", 0, 0],
"position": [0, "Math.sin(query.anim_time * 90)*-0.25", 0]
},
"dorsal_fin": {
"rotation": {
"vector": [0, 0, "Math.sin(query.anim_time * 90)*10"]
}
"right_fin": {
"rotation": [0, 0, "Math.cos(query.anim_time * 90)*10"]
},
"left_fin": {
"rotation": [0, 0, "Math.cos(query.anim_time * 90)*-10"]
},
"tail": {
"rotation": [0, "Math.cos(query.anim_time * 90)*5", 0]
},
"tail_fin": {
"rotation": [0, "Math.sin(query.anim_time * 90)*5", 0]
},
"body_2": {
"rotation": [0, "Math.cos(query.anim_time * 90)*5", 0]
}
}
},
"move.swim": {
"loop": true,
"animation_length": 2,
"bones": {
"body": {
"rotation": {
"vector": ["Math.cos(query.anim_time * 90)*2.5", 0, 0]
},
"position": {
"vector": [0, "Math.sin(query.anim_time * 90)*-0.25", 0]
}
"rotation": [0, "Math.sin(query.anim_time * 180)*-5", 0]
},
"right_fin": {
"rotation": {
"vector": [0, 0, "Math.cos(query.anim_time * 90)*5"]
}
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"left_fin": {
"rotation": {
"vector": [0, 0, "Math.cos(query.anim_time * 90)*-5"]
}
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"tail": {
"rotation": {
"vector": [0, "Math.cos(query.anim_time * 90)*10", 0]
}
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
},
"tail_fin": {
"rotation": {
"vector": [0, "Math.sin(query.anim_time * 90)*10", 0]
}
"rotation": [0, "Math.sin(query.anim_time * 180)*15", 0]
},
"body_2": {
"rotation": [0, "Math.cos(query.anim_time * 180)*10", 0]
}
}
},
"move.swim": {
"move.run": {
"loop": true,
"animation_length": 1,
"bones": {
"body": {
"rotation": {
"vector": [0, "Math.sin(query.anim_time * 360)*-5", 0]
}
"rotation": [0, "Math.sin(query.anim_time * 360)*-10", 0]
},
"right_fin": {
"rotation": {
"vector": [0, "Math.sin(query.anim_time * 360)*10", 0]
}
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"left_fin": {
"rotation": {
"vector": [0, "Math.cos(query.anim_time * 360)*-10", 0]
}
},
"body2": {
"rotation": {
"vector": [0, "Math.cos(query.anim_time * 360)*5", 0]
}
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"tail": {
"rotation": {
"vector": [0, "Math.cos(query.anim_time * 360)*10", 0]
}
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
},
"tail_fin": {
"rotation": {
"vector": [0, "Math.cos(query.anim_time * 360)*15", 0]
}
"rotation": [0, "Math.sin(query.anim_time * 360)*15", 0]
},
"body_2": {
"rotation": [0, "Math.cos(query.anim_time * 360)*10", 0]
}
}
},
Expand Down

0 comments on commit 766d311

Please sign in to comment.