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.

@FunctionalInterface public static interface BlockUtil.SurfaceCriteria
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

    Fields
    Modifier and Type
    Field
    Description
    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.
    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.
    Surface criterion which defines a surface as the boundary between any non-air block and an air block.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    basedOn(BiPredicate<net.minecraft.world.level.Level,net.minecraft.core.BlockPos> condition)
    Returns a SurfaceCriteria based on the given condition, where the inside of the surface satisfies the condition and the outside does not.
    basedOn(Predicate<net.minecraft.world.level.block.state.BlockState> condition)
    Returns a SurfaceCriteria based on the given condition, where the inside of the surface satisfies the condition and the outside does not.
    Returns a SurfaceCriteria with the opposite arrangement to this one.
    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.
  • Field Details

    • COLLIDABLE

      static final BlockUtil.SurfaceCriteria 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

      static final BlockUtil.SurfaceCriteria 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

      static final BlockUtil.SurfaceCriteria 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

      static final BlockUtil.SurfaceCriteria 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 a SurfaceCriteria based 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 a SurfaceCriteria based 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 side of the block at pos in world is a valid surface according to this set of criteria, false otherwise.
    • flip

      default BlockUtil.SurfaceCriteria flip()
      Returns a SurfaceCriteria with the opposite arrangement to this one.