Make boats solid to players

Boats join happy ghasts in the player's entity collision list, so a
player can't walk through a boat and steps up onto it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
levzzz
2026-10-24 15:56:12 +05:00
parent ebd25abd0e
commit e2dd6b67df
4 changed files with 15 additions and 8 deletions
+2 -2
View File
@@ -4102,7 +4102,7 @@ impl Game<'_> {
self.tick_riding(keys)?;
}
let riding = self.riding.is_some();
let ghast_collisions = self.happy_ghast_player_collisions();
let entity_collisions = self.player_entity_collisions();
let spin_targets = self.spin_targets();
self.sync_player_body();
let Some(player) = self.player.as_mut() else {
@@ -4149,7 +4149,7 @@ impl Game<'_> {
);
if !riding {
MotionWorld {
entities: &ghast_collisions,
entities: &entity_collisions,
player,
scene: &mut self.world,
assets: &self.pack.assets,
+1 -1
View File
@@ -128,7 +128,7 @@ impl Game<'_> {
if self.state_in_tag(avoid, ground) {
return false;
}
let entities = self.happy_ghast_player_collisions();
let entities = self.player_entity_collisions();
let Some(player) = self.player.as_mut() else {
return false;
};
+10 -3
View File
@@ -10,9 +10,10 @@ use horizon_core::geometry::{Aabb, Vec3};
use horizon_world::registry::BlockStateId;
impl Game<'_> {
/// Client `EntityGetter.getEntityCollisions`: only solid happy ghasts,
/// excluding the player's own vehicle.
pub(super) fn happy_ghast_player_collisions(&self) -> Vec<Aabb> {
/// Client `EntityGetter.getEntityCollisions` for the player: the
/// entities that `canBeCollidedWith` it, solid happy ghasts and boats
/// (`AbstractBoat.canBeCollidedWith`), except the player's own vehicle.
pub(super) fn player_entity_collisions(&self) -> Vec<Aabb> {
let Some(p) = &self.player else {
return Vec::new();
};
@@ -24,6 +25,12 @@ impl Game<'_> {
&& happy_ghast::collides_with_player(m, p.position.y)
})
.map(|m| m.bounds())
.chain(
self.boats
.iter()
.filter(|b| Some(b.id) != self.riding)
.map(super::boats::Boat::bounds),
)
.collect()
}
/// `HappyGhast.mobInteract`. Returns whether the click was used.
+2 -2
View File
@@ -3072,7 +3072,7 @@ impl Game<'_> {
self.sleep_timer = super::tick_sleep_timer(self.sleep_timer, self.sleeping.is_some());
// Gui.tick: the titles, the action bar and the held item's name.
self.tick_hud();
let ghast_collisions = self.happy_ghast_player_collisions();
let entity_collisions = self.player_entity_collisions();
let pushed = self.remote_pushes();
let Some(player) = self.player.as_mut() else {
return Ok(());
@@ -3156,7 +3156,7 @@ impl Game<'_> {
} else if !dead && !riding {
player.velocity = player.velocity.add_vector(pushed);
MotionWorld {
entities: &ghast_collisions,
entities: &entity_collisions,
player,
scene: &mut self.world,
assets: &self.pack.assets,