From 4dabe50d4362502f00d3292b7f04e2607f9b3f4b Mon Sep 17 00:00:00 2001 From: Jackson Bowes Date: Thu, 26 Feb 2026 09:29:37 -0600 Subject: [PATCH] UFO Fixes and Improvements --- CHANGELOG.md | 3 ++ .../mod/common/mixin/PlayerMixin.java | 29 +++++++++++++++++++ .../api/riding/behaviour/RidingController.kt | 5 +++- .../behaviour/types/air/HoverBehaviour.kt | 17 +++++++++-- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ead4422580..a9dd943e90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ - Fixed a compatibility issue with World Game Rules which caused some log spam in specific cases. - Fixed improper validation of Pokémon when performing a trade. - Fixed issue where particle like beam can disappear when you don't see the beginning of the beam or you look away + - Fixes https://gitlab.com/cable-mc/cobblemon/-/issues/1943 + - Fix occasional crash on retrieving revived fossils + - [Various UFO Ride Improvements](https://gitlab.com/cable-mc/cobblemon/-/merge_requests/2156) ### Developer diff --git a/common/src/main/java/com/cobblemon/mod/common/mixin/PlayerMixin.java b/common/src/main/java/com/cobblemon/mod/common/mixin/PlayerMixin.java index 434e847509..48e9a188de 100644 --- a/common/src/main/java/com/cobblemon/mod/common/mixin/PlayerMixin.java +++ b/common/src/main/java/com/cobblemon/mod/common/mixin/PlayerMixin.java @@ -15,6 +15,8 @@ import com.cobblemon.mod.common.api.events.CobblemonEvents; import com.cobblemon.mod.common.api.events.item.LeftoversCreatedEvent; import com.cobblemon.mod.common.api.orientation.OrientationController; import com.cobblemon.mod.common.api.pokemon.PokemonSpecies; +import com.cobblemon.mod.common.api.riding.RidingStyle; +import com.cobblemon.mod.common.api.riding.behaviour.types.air.HoverBehaviour; import com.cobblemon.mod.common.api.storage.party.PartyStore; import com.cobblemon.mod.common.api.storage.party.PlayerPartyStore; import com.cobblemon.mod.common.api.tags.CobblemonItemTags; @@ -59,6 +61,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -169,6 +172,32 @@ public abstract class PlayerMixin extends LivingEntity implements ScannableEntit } } + @Redirect( + method = "getDestroySpeed", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Player;onGround()Z" + ) + ) + private boolean cobblemon$considerHoverOnGround(Player player) { + // If riding a Hover Mount, return true to bypass the 5x slowdown + if (player.getVehicle() instanceof PokemonEntity vehicle) { + + var ridingController = vehicle.getRidingController(); + if (ridingController == null) player.onGround(); + + var activeContext = ridingController.getContext(); + if (activeContext == null) player.onGround(); + + if (activeContext.getStyle() == RidingStyle.AIR && + activeContext.getBehaviour().equals(HoverBehaviour.Companion.getKEY())) { + return true; + } + } + // Otherwise, return the actual value + return player.onGround(); + } + @Inject( method = "eat", at = @At( diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/RidingController.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/RidingController.kt index de17f45f03..4088090020 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/RidingController.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/RidingController.kt @@ -119,7 +119,10 @@ class RidingController( private fun canTransitionToLand(): Boolean { if ((entity.isUnderWater)) return false if ((entity.isEyeInFluid(FluidTags.WATER) || entity.isEyeInFluid(FluidTags.LAVA))) return false - return entity.onGround() + // If the currently in the air but has no land style then don't transition and render the ride useless. + // Hover is a good example for this. + val shouldStayInAir = entity.pokemon.riding.behaviours?.get(RidingStyle.LAND) == null && context?.style == RidingStyle.AIR + return entity.onGround() && !shouldStayInAir } private fun canTransitionToLiquid(): Boolean { diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/types/air/HoverBehaviour.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/types/air/HoverBehaviour.kt index 3199b32e36..bc6fa2f614 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/types/air/HoverBehaviour.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/riding/behaviour/types/air/HoverBehaviour.kt @@ -213,10 +213,23 @@ class HoverBehaviour : RidingBehaviour { val accel = topSpeed / (vehicle.runtime.resolveDouble(settings.accelerationExpr ?: globalHover.accelerationExpr!!) * 20.0) var newVelocity = state.rideVelocity.get() + val unrotateVel = vehicle.deltaMovement.yRot(vehicle.yRot) + + val vehicleFrontVec = Vec3(0.0, 0.0, 1.0) + val faceVel = Vec3(vehicle.deltaMovement.x, 0.0, vehicle.deltaMovement.z) + + val d = vehicle.deltaMovement.horizontalDistance() + val v2 = Vec3(faceVel.dot(Vec3(1.0, 0.0, 0.0)) * d, newVelocity.y, faceVel.dot(Vec3(0.0, 0.0, 1.0)) * d) // Check for collisions and if found, update the speed to reflect it - if (vehicle.verticalCollision || vehicle.horizontalCollision) { - state.speed.set(vehicle.deltaMovement.length()) + if (vehicle.horizontalCollision) { + val smackingIntoWallSpeed = max( vehicle.deltaMovement.horizontalDistance(), 0.2) + newVelocity = Vec3(newVelocity.x, 0.0, newVelocity.z).normalize().scale(smackingIntoWallSpeed).add(0.0, newVelocity.y, 0.0) + } + + + if (vehicle.verticalCollision) { + newVelocity = Vec3(newVelocity.x, 0.0, newVelocity.z) } // align the velocity vector to be in local vehicle space