Compare commits

...
Author SHA1 Message Date
Landon Wills 34d7d86c97 Fix deserialization issue 2025-07-01 23:20:13 -04:00
Landon Wills 4136cbf630 Merge branch 'main' into submarine-riding-behaviour_gisketch 2025-07-01 23:12:05 -04:00
Landon Wills d583e33348 Merge branch 'main' into submarine-riding-behaviour_gisketch 2025-06-30 11:54:54 -04:00
Polymeta ea36243e26 fix submarine not diving when on water surface
refactor boat into boatlike behaviour to make it easier to extend

commit seaking model for submarine testing

revert lapras JSON to original state

Signed-off-by: Polymeta <40173118+Polymeta@users.noreply.github.com>
2025-06-03 11:28:54 +01:00
Polymeta b3cc37a97b Merge branch 'refs/heads/main' into submarine-riding-behaviour_gisketch 2025-06-03 09:42:22 +01:00
gisketch 0d8a71f833 dummy submarine commit 2025-05-30 11:34:29 +08:00
21 changed files with 554 additions and 66 deletions

No files matched your search

@@ -15,6 +15,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
@@ -82,6 +83,8 @@ interface RidingBehaviour<Settings : RidingBehaviourSettings, State : RidingBeha
fun turnOffOnGround(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
fun canStandOnFluid(settings: Settings, state: State, vehicle: PokemonEntity, fluidState: FluidState): Boolean
fun dismountOnShift(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
fun shouldRotatePokemonHead(settings: Settings, state: State, vehicle: PokemonEntity): Boolean
@@ -15,6 +15,7 @@ import com.cobblemon.mod.common.api.riding.behaviour.types.land.VehicleBehaviour
import com.cobblemon.mod.common.api.riding.behaviour.types.liquid.BoatBehaviour
import com.cobblemon.mod.common.api.riding.behaviour.types.liquid.BurstBehaviour
import com.cobblemon.mod.common.api.riding.behaviour.types.liquid.DolphinBehaviour
import com.cobblemon.mod.common.api.riding.behaviour.types.liquid.SubmarineBehaviour
import net.minecraft.resources.ResourceLocation
object RidingBehaviours {
@@ -25,6 +26,7 @@ object RidingBehaviours {
register(DolphinBehaviour.KEY, DolphinBehaviour())
register(HorseBehaviour.KEY, HorseBehaviour())
register(BoatBehaviour.KEY, BoatBehaviour())
register(SubmarineBehaviour.KEY, SubmarineBehaviour())
register(GliderBehaviour.KEY, GliderBehaviour())
register(HelicopterBehaviour.KEY, HelicopterBehaviour())
register(JetBehaviour.KEY, JetBehaviour())
@@ -15,6 +15,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
@@ -139,6 +140,11 @@ class RidingController<Settings : RidingBehaviourSettings, State : RidingBehavio
return behaviour.turnOffOnGround(settings, state, vehicle)
}
override fun canStandOnFluid(settings: Settings, state: State, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
if (!isActive(settings, state, vehicle)) return false
return behaviour.canStandOnFluid(settings, state, vehicle, fluidState)
}
override fun shouldRoll(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
if (!isActive(settings, state, vehicle)) return false
return behaviour.shouldRoll(settings, state, vehicle)
@@ -18,16 +18,15 @@ import com.cobblemon.mod.common.api.riding.posing.PoseOption
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
import com.cobblemon.mod.common.entity.PoseType
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.*
import com.cobblemon.mod.common.util.math.geometry.toRadians
import net.minecraft.client.Minecraft
import net.minecraft.network.FriendlyByteBuf
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import org.joml.Vector3f
@@ -451,6 +450,10 @@ class BirdBehaviour : RidingBehaviour<BirdSettings, BirdState> {
return false
}
override fun canStandOnFluid(settings: BirdSettings, state: BirdState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: BirdSettings, state: BirdState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -476,6 +479,7 @@ class BirdBehaviour : RidingBehaviour<BirdSettings, BirdState> {
}
class BirdSettings : RidingBehaviourSettings {
@Transient
override val key = BirdBehaviour.KEY
var infiniteAltitude: Expression = "false".asExpression()
@@ -26,6 +26,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
@@ -175,6 +176,10 @@ class GliderBehaviour : RidingBehaviour<GliderSettings, RidingBehaviourState> {
return false
}
override fun canStandOnFluid(settings: GliderSettings, state: RidingBehaviourState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: GliderSettings, state: RidingBehaviourState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -191,6 +196,7 @@ class GliderBehaviour : RidingBehaviour<GliderSettings, RidingBehaviourState> {
}
class GliderSettings : RidingBehaviourSettings {
@Transient
override val key = GliderBehaviour.KEY
var glideSpeed: Expression = "0.1".asExpression()
@@ -25,6 +25,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -256,6 +257,10 @@ class HelicopterBehaviour : RidingBehaviour<HelicopterSettings, RidingBehaviourS
return false
}
override fun canStandOnFluid(settings: HelicopterSettings, state: RidingBehaviourState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: HelicopterSettings, state: RidingBehaviourState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -277,6 +282,7 @@ class HelicopterBehaviour : RidingBehaviour<HelicopterSettings, RidingBehaviourS
class HelicopterSettings : RidingBehaviourSettings {
@Transient
override val key = HelicopterBehaviour.KEY
var gravity: Expression = "1.0".asExpression()
@@ -17,7 +17,6 @@ import com.cobblemon.mod.common.entity.PoseType
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.util.*
import com.cobblemon.mod.common.util.math.geometry.toRadians
import net.fabricmc.loader.impl.lib.sat4j.core.Vec
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.Mth
@@ -25,11 +24,11 @@ import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
import org.joml.Matrix3f
import org.joml.Vector3f
import kotlin.math.*
class HoverBehaviour : RidingBehaviour<HoverSettings, HoverState> {
@@ -436,6 +435,15 @@ class HoverBehaviour : RidingBehaviour<HoverSettings, HoverState> {
return false
}
override fun canStandOnFluid(
settings: HoverSettings,
state: HoverState,
vehicle: PokemonEntity,
fluidState: FluidState
): Boolean {
return false
}
override fun dismountOnShift(
settings: HoverSettings,
state: HoverState,
@@ -464,6 +472,7 @@ class HoverBehaviour : RidingBehaviour<HoverSettings, HoverState> {
}
class HoverSettings : RidingBehaviourSettings {
@Transient
override val key = HoverBehaviour.KEY
var canJump = "true".asExpression()
@@ -25,6 +25,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -351,6 +352,10 @@ class JetBehaviour : RidingBehaviour<JetSettings, JetState> {
return false
}
override fun canStandOnFluid(settings: JetSettings, state: JetState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: JetSettings, state: JetState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -371,6 +376,7 @@ class JetBehaviour : RidingBehaviour<JetSettings, JetState> {
}
class JetSettings : RidingBehaviourSettings {
@Transient
override val key = JetBehaviour.KEY
var gravity: Expression = "0".asExpression()
@@ -21,6 +21,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
@@ -146,6 +147,17 @@ class CompositeBehaviour : RidingBehaviour<CompositeSettings, CompositeState> {
}
}
override fun canStandOnFluid(
settings: CompositeSettings,
state: CompositeState,
vehicle: PokemonEntity,
fluidState: FluidState
): Boolean {
return chooseBehaviour(settings, state) { behaviour, behaviourSettings, behaviourState ->
behaviour.canStandOnFluid(behaviourSettings, behaviourState, vehicle, fluidState)
}
}
override fun shouldRoll(
settings: CompositeSettings,
state: CompositeState,
@@ -75,6 +75,7 @@ object FallStrategy : CompositeRidingStrategy<FallCompositeSettings> {
}
class FallCompositeSettings : CompositeSettings() {
@Transient
override val key = FallStrategy.key
var minimumForwardSpeed: Expression = "0.0".asExpression()
@@ -25,6 +25,7 @@ import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.ai.attributes.Attributes
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -415,6 +416,15 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
return false
}
override fun canStandOnFluid(
settings: HorseSettings,
state: HorseState,
vehicle: PokemonEntity,
fluidState: FluidState
): Boolean {
return false
}
override fun dismountOnShift(
settings: HorseSettings,
state: HorseState,
@@ -443,6 +453,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
}
class HorseSettings : RidingBehaviourSettings {
@Transient
override val key = HorseBehaviour.KEY
var canJump = "true".asExpression()
@@ -24,6 +24,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -245,6 +246,15 @@ class VehicleBehaviour : RidingBehaviour<VehicleSettings, VehicleState> {
return false
}
override fun canStandOnFluid(
settings: VehicleSettings,
state: VehicleState,
vehicle: PokemonEntity,
fluidState: FluidState
): Boolean {
return false
}
override fun dismountOnShift(
settings: VehicleSettings,
state: VehicleState,
@@ -273,6 +283,7 @@ class VehicleBehaviour : RidingBehaviour<VehicleSettings, VehicleState> {
}
class VehicleSettings : RidingBehaviourSettings {
@Transient
override val key = VehicleBehaviour.KEY
var canJump = "true".asExpression()
@@ -24,6 +24,7 @@ import net.minecraft.util.Mth
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -31,22 +32,19 @@ import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
abstract class BoatLikeBehaviour<Settings: BoatSettings, State: BoatState> : RidingBehaviour<Settings, State> {
companion object {
val KEY = cobblemonResource("liquid/boat")
val TOP_SPEED = 2.0
const val TOP_SPEED = 2.0
}
override val key = KEY
override fun getRidingStyle(settings: BoatSettings, state: BoatState): RidingStyle {
override fun getRidingStyle(settings: Settings, state: State): RidingStyle {
return RidingStyle.LIQUID
}
val poseProvider = PoseProvider<BoatSettings, BoatState>(PoseType.FLOAT)
.with(PoseOption(PoseType.SWIM) { _, _, entity -> entity.isSwimming && entity.entityData.get(PokemonEntity.MOVING) })
override fun isActive(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Boolean {
override fun isActive(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
if (state.jumpBuffer.get() != -1) {
return true
}
@@ -60,8 +58,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun tick(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player,
input: Vec3
@@ -88,17 +86,17 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
super.tick(settings, state, vehicle, driver, input)
}
override fun pose(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): PoseType {
override fun pose(settings: Settings, state: State, vehicle: PokemonEntity): PoseType {
return poseProvider.select(settings, state, vehicle)
}
override fun speed(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity, driver: Player): Float {
override fun speed(settings: Settings, state: State, vehicle: PokemonEntity, driver: Player): Float {
return state.rideVelocity.get().length().toFloat()
}
override fun rotation(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: LivingEntity
): Vec2 {
@@ -107,8 +105,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun velocity(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player,
input: Vec3
@@ -123,7 +121,7 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
return state.rideVelocity.get()
}
private fun applyVelocityFromInput(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: BoatState): Vec3 {
private fun applyVelocityFromInput(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: State): Vec3 {
val speed = vehicle.getRideStat(RidingStat.SPEED, RidingStyle.LIQUID, 0.8, TOP_SPEED)
val acceleration = vehicle.getRideStat(RidingStat.ACCELERATION, RidingStyle.LIQUID, 0.05, 0.5)
@@ -148,7 +146,7 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
)
}
private fun applyJump(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: BoatState): Vec3 {
protected open fun applyJump(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: State): Vec3 {
if (!driver.jumping) return velocity // Not jumping
if (state.jumpBuffer.get() != -1) return velocity // Already jumped very recently
if (!hasStamina(state)) return velocity // Has no stamina
@@ -159,7 +157,7 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
return Vec3(velocity.x, velocity.y + jumpStrength, velocity.z)
}
private fun applyGravity(velocity: Vec3, vehicle: PokemonEntity, settings: BoatSettings, state: BoatState): Vec3 {
protected open fun applyGravity(velocity: Vec3, vehicle: PokemonEntity, settings: Settings, state: State): Vec3 {
if (state.jumpBuffer.get() == -1 && vehicle.isInWater || vehicle.isUnderWater) {
return Vec3(velocity.x, -0.05, velocity.z)
}
@@ -168,7 +166,7 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
return Vec3(velocity.x, max(velocity.y - gravity, terminalVelocity), velocity.z)
}
private fun applyStrafeRotation(vehicle: PokemonEntity, driver: Player, state: BoatState) {
private fun applyStrafeRotation(vehicle: PokemonEntity, driver: Player, state: State) {
val skill = vehicle.getRideStat(RidingStat.SKILL, RidingStyle.LIQUID, 0.5, 1.5)
val strafe = driver.xxa
if (abs(strafe) > 0) {
@@ -177,19 +175,19 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
}
private fun hasStamina(state: BoatState): Boolean {
protected fun hasStamina(state: State): Boolean {
return state.stamina.get() != 0f
}
private fun consumeStamina(vehicle: PokemonEntity, state: BoatState, drain: Float) {
protected fun consumeStamina(vehicle: PokemonEntity, state: State, drain: Float) {
val stamina = vehicle.getRideStat(RidingStat.STAMINA, RidingStyle.LIQUID, 1.0, 5.0)
state.stamina.set(max(0f, state.stamina.get() - drain / stamina.toFloat()))
state.staminaBuffer.set(0)
}
override fun updatePassengerRotation(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: LivingEntity
) {
@@ -199,8 +197,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun clampPassengerRotation(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: LivingEntity
) {
@@ -214,8 +212,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun angRollVel(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player,
deltaTime: Double
@@ -224,8 +222,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun rotationOnMouseXY(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player,
mouseY: Double,
@@ -244,8 +242,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun canJump(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player
): Boolean {
@@ -253,8 +251,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun setRideBar(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player
): Float {
@@ -262,8 +260,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun jumpForce(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player,
jumpStrength: Int
@@ -272,8 +270,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun gravity(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
regularGravity: Double
): Double {
@@ -281,8 +279,8 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
}
override fun rideFovMultiplier(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player
): Float {
@@ -292,58 +290,71 @@ class BoatBehaviour : RidingBehaviour<BoatSettings, BoatState> {
return 1.0f
}
override fun useAngVelSmoothing(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Boolean {
override fun useAngVelSmoothing(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
return false
}
override fun useRidingAltPose(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity,
driver: Player
): ResourceLocation {
return cobblemonResource("no_pose")
}
override fun inertia(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Double {
override fun inertia(settings: Settings, state: State, vehicle: PokemonEntity): Double {
return 0.5
}
override fun shouldRoll(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Boolean {
override fun shouldRoll(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
return false
}
override fun turnOffOnGround(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Boolean {
override fun turnOffOnGround(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
return false
}
override fun dismountOnShift(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity): Boolean {
override fun canStandOnFluid(settings: Settings, state: State, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return true
}
override fun dismountOnShift(settings: Settings, state: State, vehicle: PokemonEntity): Boolean {
return false
}
override fun shouldRotatePokemonHead(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity
): Boolean {
return vehicle.runtime.resolveBoolean(settings.rotatePokemonHead)
}
override fun shouldRotatePlayerHead(
settings: BoatSettings,
state: BoatState,
settings: Settings,
state: State,
vehicle: PokemonEntity
): Boolean {
return true
}
override fun maxUpStep(settings: BoatSettings, state: BoatState, vehicle: PokemonEntity) = 0f
override fun maxUpStep(settings: Settings, state: State, vehicle: PokemonEntity) = 0f
}
class BoatBehaviour : BoatLikeBehaviour<BoatSettings, BoatState>() {
override val key: ResourceLocation
get() = KEY
override fun createDefaultState(settings: BoatSettings) = BoatState()
companion object {
val KEY = cobblemonResource("liquid/boat")
}
}
class BoatSettings : RidingBehaviourSettings {
open class BoatSettings : RidingBehaviourSettings {
@Transient
override val key = BoatBehaviour.KEY
var terminalVelocity = "-2.0".asExpression()
@@ -362,7 +373,7 @@ class BoatSettings : RidingBehaviourSettings {
}
}
class BoatState : RidingBehaviourState() {
open class BoatState : RidingBehaviourState() {
val deltaRotation = ridingState(0.0, Side.CLIENT)
val jumpBuffer = ridingState(-1, Side.CLIENT)
val staminaBuffer = ridingState(0, Side.CLIENT)
@@ -23,6 +23,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -202,6 +203,10 @@ class BurstBehaviour : RidingBehaviour<BurstSettings, BurstState> {
return false
}
override fun canStandOnFluid(settings: BurstSettings, state: BurstState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: BurstSettings, state: BurstState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -226,6 +231,7 @@ class BurstBehaviour : RidingBehaviour<BurstSettings, BurstState> {
}
class BurstSettings : RidingBehaviourSettings {
@Transient
override val key = BurstBehaviour.KEY
var dashSpeed = 1F
@@ -23,6 +23,7 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.SmoothDouble
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec2
import net.minecraft.world.phys.Vec3
import net.minecraft.world.phys.shapes.Shapes
@@ -241,6 +242,10 @@ class DolphinBehaviour : RidingBehaviour<DolphinSettings, DolphinState> {
return true
}
override fun canStandOnFluid(settings: DolphinSettings, state: DolphinState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun dismountOnShift(settings: DolphinSettings, state: DolphinState, vehicle: PokemonEntity): Boolean {
return false
}
@@ -266,6 +271,7 @@ class DolphinBehaviour : RidingBehaviour<DolphinSettings, DolphinState> {
}
class DolphinSettings : RidingBehaviourSettings {
@Transient
override val key = DolphinBehaviour.KEY
var canJump = "true".asExpression()
@@ -0,0 +1,84 @@
package com.cobblemon.mod.common.api.riding.behaviour.types.liquid
import com.cobblemon.mod.common.api.riding.RidingStyle
import com.cobblemon.mod.common.api.riding.stats.RidingStat
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.util.*
import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.phys.Vec3
class SubmarineBehaviour : BoatLikeBehaviour<SubmarineSettings, SubmarineState>() {
companion object {
val KEY = cobblemonResource("liquid/submarine")
}
override val key = KEY
override fun velocity(
settings: SubmarineSettings,
state: SubmarineState,
vehicle: PokemonEntity,
driver: Player,
input: Vec3
): Vec3 {
var velocity = super.velocity(settings, state, vehicle, driver, input)
velocity = applyAscendDescend(velocity, vehicle, driver, state)
state.rideVelocity.set(velocity)
return velocity
}
override fun applyJump(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: SubmarineState): Vec3 {
// Disable normal jumping when underwater - use ascend/descend instead
return if (vehicle.isUnderWater) {
velocity
} else {
super.applyJump(velocity, vehicle, driver, state)
}
}
override fun applyGravity(velocity: Vec3, vehicle: PokemonEntity, settings: SubmarineSettings, state: SubmarineState): Vec3 {
return if (vehicle.isUnderWater) {
Vec3(velocity.x, velocity.y, velocity.z)
} else {
super.applyGravity(velocity, vehicle, settings, state)
}
}
private fun applyAscendDescend(velocity: Vec3, vehicle: PokemonEntity, driver: Player, state: SubmarineState): Vec3 {
val verticalSpeed = vehicle.getRideStat(RidingStat.SPEED, RidingStyle.LIQUID, 0.1, 0.5)
var yVelocity = velocity.y
// Ascend with jump key (only when underwater)
if (driver.jumping && hasStamina(state) && vehicle.isUnderWater) {
yVelocity = verticalSpeed
consumeStamina(vehicle, state, 0.005f)
}
// Descend with shift key (works both underwater and on surface)
else if (driver.isShiftKeyDown && hasStamina(state)) {
yVelocity = -verticalSpeed
consumeStamina(vehicle, state, 0.005f)
}
// When underwater and no input, maintain neutral buoyancy (no vertical movement)
else if (vehicle.isUnderWater) {
yVelocity = 0.0
}
return Vec3(velocity.x, yVelocity, velocity.z)
}
override fun canStandOnFluid(settings: SubmarineSettings, state: SubmarineState, vehicle: PokemonEntity, fluidState: FluidState): Boolean {
return false
}
override fun createDefaultState(settings: SubmarineSettings) = SubmarineState()
}
class SubmarineSettings : BoatSettings() {
@Transient
override val key: ResourceLocation = SubmarineBehaviour.KEY
}
typealias SubmarineState = BoatState
@@ -475,9 +475,11 @@ open class PokemonEntity(
}
override fun canStandOnFluid(state: FluidState): Boolean {
// val node = navigation.currentPath?.currentNode
// val targetPos = node?.blockPos
// if (targetPos == null || world.getBlockState(targetPos.up()).isAir) {
val result = ifRidingAvailableSupply(null) { behaviour, settings, ridingState ->
behaviour.canStandOnFluid(settings, ridingState, this, state)
}
if(result != null)
return result
return if (state.`is`(FluidTags.WATER) && !isEyeInFluid(FluidTags.WATER)) {
exposedForm.behaviour.moving.swim.canWalkOnWater || platform != PlatformType.NONE
} else if (state.`is`(FluidTags.LAVA) && !isEyeInFluid(FluidTags.LAVA)) {
@@ -485,9 +487,6 @@ open class PokemonEntity(
} else {
super.canStandOnFluid(state)
}
// }
//
// return super.canWalkOnFluid(state)
}
override fun canSprint() = true
@@ -47,6 +47,7 @@ object RidingBehaviourSettingsAdapter : JsonDeserializer<RidingBehaviourSettings
VehicleBehaviour.KEY to VehicleSettings::class.java,
HoverBehaviour.KEY to HoverSettings::class.java,
CompositeBehaviour.KEY to CompositeSettings::class.java,
SubmarineBehaviour.KEY to SubmarineSettings::class.java,
/*
Strategy registration. if you do not register a strategy here, it will not be deserialized.
@@ -46,6 +46,15 @@
{"origin": [2, 10, -17], "size": [1, 2, 1], "uv": [0, 0]}
]
},
{
"name": "locator_mouth",
"parent": "mouth",
"pivot": [0, 11, -16.5],
"locators": {
"mouth": [0, 11, -16.5],
"special": [0, 11, -16.5]
}
},
{
"name": "upper_lip",
"parent": "mouth",
@@ -74,6 +83,55 @@
{"origin": [-1, 16.25, -21.75], "size": [2, 2, 3], "uv": [80, 67]}
]
},
{
"name": "locator_horn",
"parent": "horn",
"pivot": [0, 17.25, -21],
"locators": {
"horn": [0, 17.25, -21],
"physical": [0, 17.25, -21]
}
},
{
"name": "locator_item_hat",
"parent": "torso",
"pivot": [0, 24.45, -7.25],
"locators": {
"item_hat": [0, 24.45, -7.25]
}
},
{
"name": "locator_seat_1",
"parent": "torso",
"pivot": [0, 20.75, 4.25],
"locators": {
"seat_1": [0, 20.75, 4.25]
}
},
{
"name": "locator_item_face",
"parent": "torso",
"pivot": [0, 14, -16],
"locators": {
"item_face": [0, 14, -16]
}
},
{
"name": "locator_face",
"parent": "torso",
"pivot": [0, 14, -17],
"locators": {
"face": [0, 14, -17]
}
},
{
"name": "locator_head",
"parent": "torso",
"pivot": [0, 21, -12],
"locators": {
"head": [0, 21, -12]
}
},
{
"name": "eyes",
"parent": "torso",
@@ -95,6 +153,14 @@
{"origin": [-8.5, 11.25, -12], "size": [0, 5, 5], "inflate": 0.01, "uv": [0, 7]}
]
},
{
"name": "locator_eye_right",
"parent": "pupil_right",
"pivot": [-8.5, 14.25, -10],
"locators": {
"eye1": [-8.5, 14.25, -10]
}
},
{
"name": "eye_blink_right",
"parent": "eye_right",
@@ -127,6 +193,14 @@
{"origin": [8.5, 11.25, -12], "size": [0, 5, 5], "inflate": 0.01, "uv": [47, 7]}
]
},
{
"name": "locator_eye_left",
"parent": "pupil_left",
"pivot": [8.5, 14.25, -10],
"locators": {
"eye2": [8.5, 14.25, -10]
}
},
{
"name": "eye_blink_left",
"parent": "eye_left",
@@ -159,6 +233,23 @@
{"origin": [-18.5, -3.25, -3.25], "size": [6, 14, 0], "uv": [64, 22]}
]
},
{
"name": "locator_item",
"parent": "fin_right2",
"pivot": [-16, 5, -3.25],
"rotation": [90, 180, 0],
"locators": {
"item": [-16, 5, -3.25]
}
},
{
"name": "locator_hand_primary",
"parent": "fin_right2",
"pivot": [-15.5, 3.75, -3.25],
"locators": {
"hand_primary": [-15.5, 3.75, -3.25]
}
},
{
"name": "fin_left1",
"parent": "torso",
@@ -175,6 +266,14 @@
{"origin": [12.5, -3.25, -3.25], "size": [6, 14, 0], "uv": [76, 22]}
]
},
{
"name": "locator_hand_secondary",
"parent": "fin_left2",
"pivot": [15.5, 3.75, -3.25],
"locators": {
"hand_secondary": [15.5, 3.75, -3.25]
}
},
{
"name": "torso_end",
"parent": "torso",
@@ -251,6 +350,54 @@
"cubes": [
{"origin": [1.5, -6.5, 8], "size": [0, 13, 7], "uv": [88, 28]}
]
},
{
"name": "locator_tail",
"parent": "tail",
"pivot": [0, 15, 19],
"locators": {
"tail": [0, 15, 19]
}
},
{
"name": "locator_tail_tip",
"parent": "tail",
"pivot": [0, 26, 29],
"locators": {
"tail_tip": [0, 26, 29]
}
},
{
"name": "locator_target",
"parent": "body",
"pivot": [0, 10, -19.75],
"locators": {
"target": [0, 10, -19.75]
}
},
{
"name": "locator_middle",
"parent": "body",
"pivot": [0, 11, -1.5],
"locators": {
"middle": [0, 11, -1.5]
}
},
{
"name": "locator_root",
"parent": "seaking_female",
"pivot": [0, 0, 0],
"locators": {
"root": [0, 0, 0]
}
},
{
"name": "locator_top",
"parent": "seaking_female",
"pivot": [0, 22, 0],
"locators": {
"top": [0, 22, 0]
}
}
]
}
@@ -46,6 +46,15 @@
{"origin": [2, 10, -17], "size": [1, 2, 1], "uv": [0, 0]}
]
},
{
"name": "locator_mouth",
"parent": "mouth",
"pivot": [0, 11, -16.5],
"locators": {
"mouth": [0, 11, -16.5],
"special": [0, 11, -16.5]
}
},
{
"name": "upper_lip",
"parent": "mouth",
@@ -74,6 +83,55 @@
{"origin": [-1, 16.25, -23.75], "size": [2, 2, 4], "uv": [79, 66]}
]
},
{
"name": "locator_horn",
"parent": "horn",
"pivot": [0, 17.25, -23],
"locators": {
"horn": [0, 17.25, -23],
"physical": [0, 17.25, -23]
}
},
{
"name": "locator_seat_1",
"parent": "torso",
"pivot": [0, 20.75, 4.25],
"locators": {
"seat_1": [0, 20.75, 4.25]
}
},
{
"name": "locator_head",
"parent": "torso",
"pivot": [0, 21, -12],
"locators": {
"head": [0, 21, -12]
}
},
{
"name": "locator_item_hat",
"parent": "torso",
"pivot": [0, 24.45, -7.25],
"locators": {
"item_hat": [0, 24.45, -7.25]
}
},
{
"name": "locator_face",
"parent": "torso",
"pivot": [0, 14, -17],
"locators": {
"face": [0, 14, -17]
}
},
{
"name": "locator_item_face",
"parent": "torso",
"pivot": [0, 14, -16],
"locators": {
"item_face": [0, 14, -16]
}
},
{
"name": "eyes",
"parent": "torso",
@@ -95,6 +153,14 @@
{"origin": [-8.5, 11.25, -12], "size": [0, 5, 5], "inflate": 0.01, "uv": [0, 7]}
]
},
{
"name": "locator_eye_right",
"parent": "pupil_right",
"pivot": [-8.5, 14.25, -10],
"locators": {
"eye1": [-8.5, 14.25, -10]
}
},
{
"name": "eye_blink_right",
"parent": "eye_right",
@@ -127,6 +193,14 @@
{"origin": [8.5, 11.25, -12], "size": [0, 5, 5], "inflate": 0.01, "uv": [47, 7]}
]
},
{
"name": "locator_eye_left",
"parent": "pupil_left",
"pivot": [8.5, 14.25, -10],
"locators": {
"eye2": [8.5, 14.25, -10]
}
},
{
"name": "eye_blink_left",
"parent": "eye_left",
@@ -159,6 +233,23 @@
{"origin": [-18.5, -3.25, -3.25], "size": [6, 14, 0], "uv": [64, 22]}
]
},
{
"name": "locator_item",
"parent": "fin_right2",
"pivot": [-16, 5, -3.25],
"rotation": [90, 180, 0],
"locators": {
"item": [-16, 5, -3.25]
}
},
{
"name": "locator_hand_primary",
"parent": "fin_right2",
"pivot": [-15.5, 3.75, -3.25],
"locators": {
"hand_primary": [-15.5, 3.75, -3.25]
}
},
{
"name": "fin_left1",
"parent": "torso",
@@ -175,6 +266,14 @@
{"origin": [12.5, -3.25, -3.25], "size": [6, 14, 0], "uv": [76, 22]}
]
},
{
"name": "locator_hand_secondary",
"parent": "fin_left2",
"pivot": [15.5, 3.75, -3.25],
"locators": {
"hand_secondary": [15.5, 3.75, -3.25]
}
},
{
"name": "torso_end",
"parent": "torso",
@@ -251,6 +350,54 @@
"cubes": [
{"origin": [1.5, -6.5, 8], "size": [0, 13, 7], "uv": [88, 28]}
]
},
{
"name": "locator_tail_tip",
"parent": "tail",
"pivot": [0, 26, 29],
"locators": {
"tail_tip": [0, 26, 29]
}
},
{
"name": "locator_tail",
"parent": "tail",
"pivot": [0, 15, 19],
"locators": {
"tail": [0, 15, 19]
}
},
{
"name": "locator_middle",
"parent": "body",
"pivot": [0, 11, -1.5],
"locators": {
"middle": [0, 11, -1.5]
}
},
{
"name": "locator_target",
"parent": "body",
"pivot": [0, 10, -19.75],
"locators": {
"target": [0, 10, -19.75]
}
},
{
"name": "locator_root",
"parent": "seaking_male",
"pivot": [0, 0, 0],
"locators": {
"root": [0, 0, 0]
}
},
{
"name": "locator_top",
"parent": "seaking_male",
"pivot": [0, 22, 0],
"locators": {
"top": [0, 22, 0]
}
}
]
}
@@ -173,6 +173,18 @@
"preEvolution": "goldeen",
"evolutions": [],
"riding": {
"behaviour": {
"key": "cobblemon:liquid/submarine"
},
"seats": [
{
"offset": {
"x": 0.0,
"y": 0.4,
"z": 0.0
}
}
],
"stats": {
"SPEED": {
"ranges": "25-50"
@@ -189,8 +201,6 @@
"STAMINA": {
"ranges": "25-50"
}
},
"seats": [],
"behaviour": null
}
}
}