Skip to content

[26.4] Remove FluidType and move hooks to Fluid - #3777

Open
XFactHD wants to merge 9 commits into
port/26.4from
port/26.4-fluids
Open

XFactHD wants to merge 9 commits into
port/26.4from
port/26.4-fluids

Conversation

@XFactHD

@XFactHD XFactHD commented Nov 30, 2026

Copy link
Copy Markdown
Member

This PR removes FluidType and moves its hooks to Fluid as the former is no longer needed for its original purpose of combining the still and flowing variants of a given fluid.

The first commit moves over (almost) all extensions and removes FluidType itself. Further work is needed to reimplement the callsites of these hooks.
Additionally a solution is needed for applying non-default values of the "extended properties" to vanilla fluids (see commented-out FluidType registration in NeoForgeMod).

@XFactHD
XFactHD requested a review from pupnewfster November 30, 2026 01:43
@XFactHD XFactHD added area: fluids This request involves the fluid system 26.4 Targeted at Minecraft 26.4 labels Nov 30, 2026
@neoforged-pr-publishing

Copy link
Copy Markdown
  • Publish PR to GitHub Packages

@pupnewfster pupnewfster left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few misc comments, I didn't pay too close attention to the removed rejects to make sure that they are equivalent/have corresponding hooks. But the initial pass seems decent (though there are various methods that we might end up wanting to rename/make closer to mojmap instead of their old naming scheme.

Additionally a solution is needed for applying non-default values of the "extended properties" to vanilla fluids (see commented-out FluidType registration in NeoForgeMod).

I think one potential way to do this would be in FluidPropertiesExtension add a method(s) similar to applyExtendedWaterProperties (or just something that takes an enum of water, lava, empty (assuming we don't default things to being empty at which point we could just have it be a boolean for water or lava), and then have that method handle adding all of the extra states. Then in Fluids we could just patch in two (or three lines if empty is also needed) to call that method at the tail end of property construction. The ones for water and lava wouldn't even need any removal hunks due to how the formatting is.

@XFactHD

XFactHD commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

This is a list of all fluid extensions and fluid-related entity/livingentity extensions we currently have (names and parameters adjusted to take the removal of FluidType into account).
I've added some notes where I think these are pointless or otherwise questionable or problematic.

Fluid extensions:

  • getExplosionResistance(FluidState, BlockGetter, BlockPos, Explosion): overload of Fluid#getExplosionResistance()
    • What's the use case of this?
  • canConvertToSource(FluidState, ServerLevel, BlockPos): overload of FlowingFluid#canConvertToSource(ServerLevel)
    • What's the use case of this? If it's kept it should probably be moved to a FlowingFluid extension
  • canSwim(Entity): "overload" of FluidTags.SWIMMABLE
    • Is this still useful with the SWIMMABLE tag
  • canPushEntity(Entity)
  • canDrownIn(LivingEntity)
    • Can this be replaced with a fluid tag?
  • canRideVehicleUnder(Entity, Entity)
    • Can this be replaced with a fluid tag?
  • supportsBoating(FluidState, AbstractBoat)
    • Can this be replaced with a fluid tag?
  • move(LivingEntity, Vec3, double)
  • setItemMovement(ItemEntity)
  • getLightLevel(), getLightLevel(FluidStack), getLightLevel(FluidState, BlockAndLightGetter, BlockPos)
    • What's the use case of the more specific overloads?
  • getDensity(), getDensity(FluidStack), getDensity(FluidState, BlockAndLightGetter, BlockPos)
    • What's the use case of the more specific overloads?
  • getTemperature(), getTemperature(FluidStack), getTemperature(FluidState, BlockAndLightGetter, BlockPos)
    • What's the use case of the more specific overloads?
  • getViscosity(), getViscosity(FluidStack), getViscosity(FluidState, BlockAndLightGetter, BlockPos)
    • What's the use case of the more specific overloads?
  • isLighterThanAir()
  • getRarity() (stack- and level-sensitive overloads already removed)
  • getFlowScale(Entity): overload of Fluid#getFlowScale(Level)`
    • What's the use case of this?
  • getFallDistanceMultiplier(Entity): overload of Fluid#getFallDistanceMultiplier()`
    • What's the use case of this?
  • isVaporizedOnPlacement(Level, BlockPos, FluidStack)
  • onVaporize(LivingEntity, Level, BlockPos, FluidStack)
  • getDripInfo()
  • handleCauldronDrip(Fluid, Level, BlockPos)
  • getBlockPathType(FluidState, BlockGetter, BlockPos, Mob, boolean)
  • getAdjacentBlockPathType(FluidState, BlockGetter, BlockPos, Mob, PathType)
  • canHydrate(FluidStack), canHydrate(Entity), canHydrate(FluidState, BlockGetter, BlockState, BlockPos)
    • What's the use case of the first one? Can the latter two be replaced by fluid tags
  • canExtinguish(Entity), canExtinguish(FluidState, BlockGetter, BlockPos)
  • Can these be replaced by fluid tags?
  • getBucket(FluidStack) (fluidstack-sensitive overload)
    • What's the use case of this?
  • getBlockForFluidState(BlockAndLightGetter, BlockPos, FluidState): overload of Fluid#createLegacyBlock(FluidState)
    • What's the use case of this?
  • getStateForPlacement(BlockAndLightGetter, BlockPos, FluidStack): overload of Fluid#defaultFluidState()
    • What's the use case of this?
  • canBePlacedInLevel(BlockAndLightGetter, BlockPos, FluidState), canBePlacedInLevel(BlockAndLightGetter, BlockPos, FluidStack)
    • What's the use case of this?
  • appendHoverText(FluidStack, Item.TooltipContext, TooltipDisplay, Consumer, TooltipFlag)
  • getSound(SoundAction), getSound(FluidStack, SoundAction), getSound(Entity, SoundAction), getSound(LivingEntity, BlockGetter, BlockPos, SoundAction)
    • What's the use case of the more specific overloads?
  • getDescription(), getDescription(FluidStack)
  • getDescriptionId(), getDescriptionId(FluidStack)

Entity extensions:

  • canBeRiddenUnderFluid(Fluid, Entity): overload of Entity#dismountsUnderwater(), forwards to Fluid#canRideVehicleUnder(Entity, Entity)
  • getFluidHeight(FluidType)
  • getMaxHeightFluid()
  • isInFluid(FluidState), isInFluid(Fluid), isInFluid(InFluidPredicate)
  • getFirstEyeInFluid()
  • isEyeInFluid(Fluid type)
  • canStartSwimming()
  • getFluidMotionScale(Fluid): fowards to Fluid#getFlowScale(Entity)
  • isPushedByFluid(Fluid): overload of Entity#isPushedByFluid(), fowards to overloaded method and Fluid#canPushEntity(Entity)
    • What's the use case of this?
  • canSwimInFluid(Fluid): forwards to Fluid#canSwim(Entity)
  • canFluidExtinguish(Fluid): forwards to Fluid#canExtinguish(Entity)
  • getFluidFallDistanceModifier(Fluid): forwards to Fluid#getFallDistanceMultiplier(Entity)
  • canHydrateInFluid(Fluid): forwards to Fluid#canHydrate(Entity)
  • getSoundFromFluid(Fluid, SoundAction): forwards to Fluid#getSound(Entity, SoundAction)
    • What's the use case of this?

LivingEntity extensions:

  • canSwimInFluid(Fluid): override with questionable water sensitivity check
  • jumpInFluid(Fluid): overload of LivingEntity#jumpInLiquid(List)
    • Should be removed in favor of the vanilla method
    • Handles application of the swim speed attribute. Not sure what the best way to make this work with the list in the vanilla method is
  • sinkInFluid(Fluid): overload of LivingEntity#goDownInWater()
  • canDrownInFluid(): overload of LivingEntity#canBreatheUnderwater(), forwards to Fluid#canDrownIn(Entity)
  • moveInFluid(Fluid, Vec3, double): forwards to Fluid#move()

@ApexModder

ApexModder commented Dec 3, 2026 •

Copy link
Copy Markdown
Member
  • getBucket(FluidStack) (fluidstack-sensitive overload)
    • What's the use case of this?

I override this to copy across the POTION_COTENTS component needed for my bucket item

@pupnewfster

Copy link
Copy Markdown
Member

For cases you ask if they can be replaced by a fluid tag, do you mean a tag in the neo namespace that has logic attached? If so I think in general they likely can, but we need to keep in mind cases where the checks are on the client as well, and a neo client connects to a vanilla server that doesn't then provide the tag to the client.

Also I feel like a good number of the extensions for Fluid#canDoThing(Entity) don't really make sense to bother having the entity context for.

Fluid extensions:

  • getExplosionResistance(FluidState, BlockGetter, BlockPos, Explosion): overload of Fluid#getExplosionResistance()
    • Can be removed for now imo
  • canConvertToSource(FluidState, ServerLevel, BlockPos): overload of FlowingFluid#canConvertToSource(ServerLevel)
    • Might be worth keeping for if a fluid say can only convert to source when there are more than two blocks trying to convert it
  • canSwim(Entity): "overload" of FluidTags.SWIMMABLE
    • I would be in favor of dropping this for now
  • canPushEntity(Entity)
    • I think this is likely overkill and can just be merged into an override of the fluid applying movement to the entity
  • getLightLevel(), getLightLevel(FluidStack), getLightLevel(FluidState, BlockAndLightGetter, BlockPos)
    • I think the level overload is reasonable, but I think the stack one is overkill. This also should potentially be renamed to match the block method of getLightEmission
  • getDensity(), getTemperature(), getViscosity()
    • I think the level overloads can reasonably stay, but I am in favor of removing the stack variant
  • isLighterThanAir()
    • I think this had to do with whether a fluid should flow upwards into the air (think thermal expansion glowstone fluid or whatever it was in 1.12), though that sort of logic and rendering has never been hooked back up so I don't know how much point this has
  • getFlowScale(Entity): overload of Fluid#getFlowScale(Level)`
    • I think this can reasonably be removed for now
  • getFallDistanceMultiplier(Entity): overload of Fluid#getFallDistanceMultiplier()`
    • I think it is reasonable to remove this for now, and we can always add it back if people have a need
  • canHydrate(FluidStack), canHydrate(Entity), canHydrate(FluidState, BlockGetter, BlockState, BlockPos)
    • I think the stack sensitive one can go away. but having a position sensitive one makes sense
  • getBlockForFluidState(BlockAndLightGetter, BlockPos, FluidState): overload of Fluid#createLegacyBlock(FluidState)
    • I think we can probably remove it for now
  • getStateForPlacement(BlockAndLightGetter, BlockPos, FluidStack): overload of Fluid#defaultFluidState()
    • I think this will be useful for component based fluid stacks that then want to try to expose some of that information via the state?
  • canBePlacedInLevel(BlockAndLightGetter, BlockPos, FluidState), canBePlacedInLevel(BlockAndLightGetter, BlockPos, FluidStack)
    • I suspect these can just go for now and have devs just base it on if the fluid's legacy block is air or not
  • getSound(SoundAction), getSound(FluidStack, SoundAction), getSound(Entity, SoundAction), getSound(LivingEntity, BlockGetter, BlockPos, SoundAction)
    • I think the more specific overloads can probably go for now

LivingEntity extensions:

  • canSwimInFluid(Fluid): override with questionable water sensitivity check
    • I would be in favor of removing this for now given the number of places it would need to hook, and the fact there is a tag for a fluid being swimmable and I don't know if there is a use case for only able to swim in certain swimmable fluids. Though maybe it is to allow swimming in a fluid that is not normally swimmable?
  • jumpInFluid(Fluid): overload of LivingEntity#jumpInLiquid(List)
    • Remove it in favor of vanilla method, and we can add a helper looping them and multiplying a passed in delta addition if the fluid types contains water
  • sinkInFluid(Fluid): overload of LivingEntity#goDownInWater()
    • Rename to sinkInFluid to goDownInLiquid(Fluid) and have it redirect to goDownInWater if the fluid passed is water (and deprecate goDownInWater

@KnightMiner

Copy link
Copy Markdown
Contributor

canDrownIn(LivingEntity)
Can this be replaced with a fluid tag?

I have an entity type sensitive drowning in one of my mods (don't want slimes to drown in liquid slime).

getTemperature(), getTemperature(FluidStack), getTemperature(FluidState, BlockAndLightGetter, BlockPos)
isLighterThanAir()

Temperature and lighter than air both fall into the case of "why does Neo add these properties with no description of what they mean?". They aren't used anywhere in its patches, I think they are legacy stuff from 1.12 if not earlier. Should be removed and people can bring them back via tag or datamap if they need them.

getRarity() (stack- and level-sensitive overloads already removed)

Should likely be a data component on the fluid/fluid stack like how items do it, though I suppose fluids lack a default components map, don't they?

getBucket(FluidStack) (fluidstack-sensitive overload)
What's the use case of this?

Copying components from the fluid stack to the fluid item. For example, we use it to copy from our potion fluid type into a potion bucket.

getStateForPlacement(BlockAndLightGetter, BlockPos, FluidStack): overload of Fluid#defaultFluidState()
What's the use case of this?

Fluid components that change fluid state properties. Though more than likely you will want those components on a block entity instead; are fluid block entities a thing?

@XFactHD

XFactHD commented Dec 4, 2026 •

Copy link
Copy Markdown
Member Author

For cases you ask if they can be replaced by a fluid tag, do you mean a tag in the neo namespace that has logic attached? If so I think in general they likely can, but we need to keep in mind cases where the checks are on the client as well, and a neo client connects to a vanilla server that doesn't then provide the tag to the client.

Yes, they would be a "logic" tag in the Neo namespace. I didn't check yet whether the suggested places are server-only but we definitely need to be careful there.

  • canPushEntity(Entity)
    • I think this is likely overkill and can just be merged into an override of the fluid applying movement to the entity

I don't think this can easily be handled my IFluidExtension#move(). This is called by IEntityExtension#isPushedByFluid(Fluid) (overload of Entity#isPushedByFluid()) to decide whether fluid currents affect the entity and therefore whether EntityFluidInteraction calculates currents for the fluid.

  • getLightLevel(), getLightLevel(FluidStack), getLightLevel(FluidState, BlockAndLightGetter, BlockPos)
    • I think the level overload is reasonable, but I think the stack one is overkill. This also should potentially be renamed to match the block method of getLightEmission
  • getDensity(), getTemperature(), getViscosity()
    • I think the level overloads can reasonably stay, but I am in favor of removing the stack variant

I really don't see the use case of level-sensitive getters for these properties (ignoring that the latter three are pretty much completely useless anyway outside of isLighterThanAir() checking the density).

  • isLighterThanAir()
    • I think this had to do with whether a fluid should flow upwards into the air (think thermal expansion glowstone fluid or whatever it was in 1.12), though that sort of logic and rendering has never been hooked back up so I don't know how much point this has

This is currently defined as a non-positive density and, while the terrain fluid renderer doesn't support it, it's used by various mods to visually flip fluid rendering in containers and tanks or switch their rendering from a height-based to opacity-based (Mekanism does as well).
This could of course be changed to a tag similar to c:gaseous

  • jumpInFluid(Fluid): overload of LivingEntity#jumpInLiquid(List)
    • Remove it in favor of vanilla method, and we can add a helper looping them and multiplying a passed in delta addition if the fluid types contains water

Should we restrict it to water or should the attribute apply to any swimmable fluid?

  • sinkInFluid(Fluid): overload of LivingEntity#goDownInWater()
    • Rename to sinkInFluid to goDownInLiquid(Fluid) and have it redirect to goDownInWater if the fluid passed is water (and deprecate goDownInWater

This also applies the swim speed attribute. How should we treat this, including with respect to the question above?


Temperature and lighter than air both fall into the case of "why does Neo add these properties with no description of what they mean?". They aren't used anywhere in its patches, I think they are legacy stuff from 1.12 if not earlier. Should be removed and people can bring them back via tag or datamap if they need them.

For temperature, viscosity and density I would agree (the first two are basically completely undefined, the last one is only defined by what positive vs. non-positive values mean) and I'm not opposed to remove them, for "lighter than air" I disagree as it's very well defined what this means and, as mentioned above, is widely used.

Should likely be a data component on the fluid/fluid stack like how items do it, though I suppose fluids lack a default components map, don't they?

Fluids don't have a component initializer and adding one is non-trivial as it would require the Fluid.Properties to know the fluid's ID.

Fluid components that change fluid state properties. Though more than likely you will want those components on a block entity instead; are fluid block entities a thing?

I'm not sure how useful this is considering practically nothing actually uses this method instead of Fluid#defaultFluidState().
Fluid BEs are theoretically a thing but I don't think they are something we should be supporting.

@KnightMiner

Copy link
Copy Markdown
Contributor

for "lighter than air" I disagree as it's very well defined what this means and, as mentioned above, is widely used.

Fair. Its perhaps more accurate with that to say its been a bit broken for awhile as the renderer and flow logic doesn't support it. Switching it to a tag is probably fine since I recall that actual reverse gravity fluids were considered out of scope for neo.

@XFactHD

XFactHD commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

It's not necessarily out of scope, the patch surface is just completely absurd. Last time I checked (which, to be fair, was about 3 years ago, sometime during the 1.20s), the renderer patch would have contained practically the entire class. I wouldn't be surprised if patching the propagation logic was nowhere near as bad

@pupnewfster

Copy link
Copy Markdown
Member

Should we restrict it to water or should the attribute apply to any swimmable fluid?

I think we should let it apply to any swimmable fluid.

Entity extensions:

  • canBeRiddenUnderFluid(Fluid, Entity): overload of Entity#dismountsUnderwater(), forwards to Fluid#canRideVehicleUnder(Entity, Entity)
    • I would be in favor of at least changing this to not be inverted compared to vanilla (can be ridden vs dismounts) I also don't know if there is a use case for the fluid extension one, but I suspect the entity extension level one is worth having. Potentially having it just be a tag for fluids that cause dismounting rather than only being water?
  • getFluidHeight(FluidType), getMaxHeightFluid(), isInFluid(FluidState), isInFluid(Fluid), isInFluid(InFluidPredicate), getFirstEyeInFluid(), isEyeInFluid(Fluid type)
    • I think these can be decided on a case by case basis depending on what checks vanilla still has/needs. I think they mostly existed to expand checks vanilla tends to do for water to be able to check similar things for other fluids.
  • isPushedByFluid(Fluid): overload of Entity#isPushedByFluid(), fowards to overloaded method and Fluid#canPushEntity(Entity)
    • What's the use case of this?
  • canStartSwimming()
  • canSwimInFluid(Fluid): forwards to Fluid#canSwim(Entity)
    • I would be in favor for merging canStartSwimming and canSwimInFluid (if it isn't just they are going away due to the swimmable tag existing)
  • getSoundFromFluid(Fluid, SoundAction): forwards to Fluid#getSound(Entity, SoundAction)
    • I think the entity extension method can honestly just be removed. And people can directly call the getSound method on the fluid extension (which to be honest I don't really know if it needs an entity context...)

@XFactHD

XFactHD commented Dec 4, 2026

Copy link
Copy Markdown
Member Author
  • isPushedByFluid(Fluid): overload of Entity#isPushedByFluid(), fowards to overloaded method and Fluid#canPushEntity(Entity)
    • What's the use case of this?

It allows a fluid to opt out of pushing the entity in its flow direction (i.e. an entity standing in a low-density gas probably shouldn't be affected by the fluid)

@XFactHD

XFactHD commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

I have taken the executive decision to make "is lighter than air" a c tag, mirroring c:gaseous, and remove the density, temperature and viscosity properties.


The remaining rejects as well as me not wanting to re-introduce the absurdly broad "is water-like" flag bring up a few remaining questions about what to base these on instead of exact water checks:

  • Opt-in/out to water-like movement (can't be a custom tag as it's used on both sides)
  • Opt-in/out to zombie->drowned conversion (could be a custom tag as it's server-only)
  • Opt-in/out to mining speed reduction (can't be a custom tag as it's used on both sides)
  • Entity#isInShallowWater(): should this check the swimmable or floatable tag?
  • Entity#isUnderWater()/Player#updateIsUnderwater(): primarily used for sounds and rendering (SkeletonHorse#getAmbientSound() should use the same check)
  • Any further callsites of "is water in some way" getters which either weren't patched at all or relied on the "water-like" flag

@XFactHD
XFactHD requested a review from pupnewfster December 5, 2026 01:18
@pupnewfster

Copy link
Copy Markdown
Member

I make use of the temperature properties of fluids in Mekanism. I don't necessarily need the per position variant to remain, but ideally this is something that will keep being exposed.

@KnightMiner

Copy link
Copy Markdown
Contributor

In my experience, no one is providing a useful value for temperature as no one knows what it's meant to do. Tinkers uses temperature but almost exclusively it's set via JSON instead of grabbing it from the fluid instance so modpacks can set it to useful values.

If you need temperature, I'd recommend a data map for it. Neo could provide that datamaps, but IMO it slmore logical to tie the datamaps to the application of temperature as it's weird that tinkers melting and casting is tied to the same thing as whatever mechanism uses temperature for, seems like those should be separate.

@pupnewfster

Copy link
Copy Markdown
Member

I am not opposed to a datamap for temperature, but it is relatively defined if it is for real world substances as it is the temperature in kelvin which is what it says. Yes it might not be well defined for arbitrary made up substances, but it still is decent for getting a general sense of temperature

+ if (this.mob.getFluidInteraction().isEyeInFluidMatching(this.mob, (_, type, _) -> type.getIsWaterLike())) {
this.mob.setDeltaMovement(this.mob.getDeltaMovement().add(0.0, 0.005, 0.0));
+ // Neo: allow movement in any floatable fluid
+ if (this.mob.isEyeInFluid(FluidTags.ENTITY_FLOATABLE)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch feels logically wrong... Especially without a corresponding mojira issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thought process was that other swimming entities check this tag via the Swim goal (fish use the PathType instead). I can change it to a custom tag, though I also wouldn't be opposed to reverting it for now considering fish can only spawn in water-tagged fluids.

FluidState fluidState = this.level().getFluidState(pos);
- if (fluidState.is(FluidTags.WATER)) {
+ if (this.canBoatInFluid(fluidState)) {
+ if (this.canBoatInFluid(fluidState.typeHolder())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just provide the entire fluid state (or TypedInstance<Fluid> to canBoatInFluid rather than having to call typeHolder in all these places?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate in AbstractBoat#canAddPassenger() does not have access to the full FluidState

boolean colliding = !this.level().noCollision(this.getBoundingBox());
- if (this.isEyeInFluid(FluidTags.WATER)) {
+ // Neo: allow movement in any floatable fluid
+ if (this.isEyeInFluid(FluidTags.ENTITY_FLOATABLE)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels off similar to the change to fish, we can have our own tag potentially, that includes water by default, but this is a logical change to vanilla behavior for if lava gets added to the floatable tag

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar thought process to the fish patch, though this one can't use a custom tag because it runs on both sides.

@KnightMiner

KnightMiner commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

I'd argue even things with an real world temperature don't consistently get that set. I'm just not convinced Neo can get modders to set a useful value without info on how it's used. But I suppose if it's a datamap then at least you can fix mods that don't set it well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

26.4 Targeted at Minecraft 26.4 area: fluids This request involves the fluid system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants