Interface BlockUtil.SurfaceCriteria
- Enclosing class:
- BlockUtil
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
SurfaceCriteria object is used to define a 'surface', a boundary between two blocks which differ in
some way, for use in BlockUtil.getNearestSurface(Level, BlockPos, Direction, int, boolean, SurfaceCriteria).
This provides a more flexible replacement for the old getNearestFloorLevel methods.
In the context of this class, 'outside' refers to the side of the surface that is in the supplied direction,
and 'inside' refers to the side which is in the opposite direction. For example, if the direction is UP,
the inside of the surface is defined as below it, and the outside is defined as above it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BlockUtil.SurfaceCriteriaSurface criterion which defines a surface as the boundary between a block that is solid on the required side and a block that is replaceable.static final BlockUtil.SurfaceCriteriaSurface criterion which defines a surface as the boundary between a block that cannot be moved through and a block that can be moved through.static final BlockUtil.SurfaceCriteriaSurface criterion which defines a surface as the boundary between any non-air block and an air block.static final BlockUtil.SurfaceCriteriaSurface criterion which defines a surface as the boundary between a block that is solid on the required side or a liquid, and an air block. -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockUtil.SurfaceCriteriabasedOn(BiPredicate<net.minecraft.world.level.Level, net.minecraft.core.BlockPos> condition) Returns aSurfaceCriteriabased on the given condition, where the inside of the surface satisfies the condition and the outside does not.static BlockUtil.SurfaceCriteriaReturns aSurfaceCriteriabased on the given condition, where the inside of the surface satisfies the condition and the outside does not.default BlockUtil.SurfaceCriteriaflip()Returns aSurfaceCriteriawith the opposite arrangement to this one.booleantest(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Tests whether the inputs define a valid surface according to this set of criteria.
-
Field Details
-
COLLIDABLE
Surface criterion which defines a surface as the boundary between a block that cannot be moved through and a block that can be moved through. This means the surface can be stood on. -
BUILDABLE
Surface criterion which defines a surface as the boundary between a block that is solid on the required side and a block that is replaceable. This means the surface can be built on. -
SOLID_LIQUID_TO_AIR
Surface criterion which defines a surface as the boundary between a block that is solid on the required side or a liquid, and an air block. Used for freezing water and placing snow. -
NOT_AIR_TO_AIR
Surface criterion which defines a surface as the boundary between any non-air block and an air block. Used for particles, and is also good for placing fire.
-
-
Method Details
-
basedOn
static BlockUtil.SurfaceCriteria basedOn(BiPredicate<net.minecraft.world.level.Level, net.minecraft.core.BlockPos> condition) Returns aSurfaceCriteriabased on the given condition, where the inside of the surface satisfies the condition and the outside does not. -
basedOn
static BlockUtil.SurfaceCriteria basedOn(Predicate<net.minecraft.world.level.block.state.BlockState> condition) Returns aSurfaceCriteriabased on the given condition, where the inside of the surface satisfies the condition and the outside does not. -
test
boolean test(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Tests whether the inputs define a valid surface according to this set of criteria.- Parameters:
world- The world in which the surface is to be tested.pos- The block coordinates of the inside ('solid' part) of the surface.side- The direction in which the surface must face.- Returns:
- True if the side
sideof the block atposinworldis a valid surface according to this set of criteria, false otherwise.
-
flip
Returns aSurfaceCriteriawith the opposite arrangement to this one.
-