Interface FluidFlowEvents.Allow
- Enclosing class:
FluidFlowEvents
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback for when any fluid tries to flow or has a neighbor update.
The default behavior is to return true, which means that the fluid is allowed to flow.
By returning false, you are saying that you are preventing the fluid from flowing, canceling all further callbacks.
Note: Not updating the block state at the fluid position and returning false will likely cause unintended behavior, as fluids that could flow won't.
FluidFlowEvents.ALLOW.register((fluid, level, fluidPosition) -> {
// For example, check if this is a specific fluid
if (!fluid.is(Tags.MY_FLUID)) return true;
// For example, check if the block below matches some tag
if (!level.getBlockState(fluidPosition.below()).is(Tags.MY_BLOCK)) return true;
// Perform some logic for fluid interaction ...
return false;
});
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallowFlow(net.minecraft.world.level.material.FluidState fluid, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos fluidPosition) Called when a fluid flows.
-
Method Details
-
allowFlow
boolean allowFlow(net.minecraft.world.level.material.FluidState fluid, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos fluidPosition) Called when a fluid flows.- Parameters:
fluid- The fluid state of the flowing fluid.level- The level the event took place in.fluidPosition- The position in the level that the fluid flowed into.- Returns:
trueif the fluid is allowed to flow into the position.falseif the fluid is not allowed to flow, such as a block was created.
-