Share the player's water and lava tags with dropped items

The item's fluid world had its own copy of the FluidTags.WATER/LAVA
membership the player's immersion uses; motion now exports that one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-26 01:04:20 +01:00
parent 2d088739e5
commit 7dfd4c6280
3 changed files with 9 additions and 18 deletions
+2 -12
View File
@@ -1,7 +1,7 @@
//! Dropped-item immersion and currents through the shared vanilla fluid helpers.
use super::ItemEntity;
use crate::{
motion::{FluidResources, LAVA, WATER},
motion::{FluidResources, FluidTags, LAVA, WATER},
world::World,
};
use horizon_core::{
@@ -49,19 +49,9 @@ impl ItemEntity {
(water_height, lava_height)
}
}
struct Tags;
impl FluidMembership for Tags {
fn fluid_in_tag(&self, kind: FluidKind, tag: FluidTagId) -> bool {
if tag == WATER {
matches!(kind, FluidKind::Water | FluidKind::FlowingWater)
} else {
matches!(kind, FluidKind::Lava | FluidKind::FlowingLava)
}
}
}
impl FluidMembership for ItemFluidWorld<'_> {
fn fluid_in_tag(&self, kind: FluidKind, tag: FluidTagId) -> bool {
Tags.fluid_in_tag(kind, tag)
FluidTags.fluid_in_tag(kind, tag)
}
}
impl CurrentTarget for ItemFluidWorld<'_> {
+1 -1
View File
@@ -44,7 +44,7 @@ use std::{
pub(crate) mod environment;
mod fluids;
pub use fluids::{FluidResources, LAVA, PlayerFluids, WATER};
pub use fluids::{FluidResources, FluidTags, LAVA, PlayerFluids, WATER};
pub struct MotionResources {
pub attributes: Arc<Catalog>,
+6 -5
View File
@@ -103,10 +103,10 @@ fn is_tagged(kind: FluidKind, tag: FluidTagId) -> bool {
}
impl PlayerMotion {
pub fn fluid_height(&self, tag: FluidTagId) -> f64 {
self.fluids.interaction.fluid_height(&Membership, tag)
self.fluids.interaction.fluid_height(&FluidTags, tag)
}
pub fn is_eye_in_fluid(&self, tag: FluidTagId) -> bool {
self.fluids.interaction.is_eye_in_fluid(&Membership, tag)
self.fluids.interaction.is_eye_in_fluid(&FluidTags, tag)
}
/// `LocalPlayer.isUnderWater`: `wasUnderwater`, the eye sample `Player.tick`
/// takes before the base tick (`Entity.isUnderWater` also needs the body
@@ -116,11 +116,12 @@ impl PlayerMotion {
}
/// `Entity.isInLava`.
pub fn is_in_lava(&self) -> bool {
!self.fluids.first_tick && self.fluids.interaction.is_in_fluid(&Membership, LAVA)
!self.fluids.first_tick && self.fluids.interaction.is_in_fluid(&FluidTags, LAVA)
}
}
struct Membership;
impl FluidMembership for Membership {
/// Which fluids `FluidTags.WATER` and `FluidTags.LAVA` hold.
pub struct FluidTags;
impl FluidMembership for FluidTags {
fn fluid_in_tag(&self, kind: FluidKind, tag: FluidTagId) -> bool {
is_tagged(kind, tag)
}