Class LandPathNodeTypesRegistry
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A functional interface that provides thePathNodeType
, given the block state world and position.static interface
Generic provider, this is a marker interface.static interface
A functional interface that provides thePathNodeType
, given the block state. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable PathNodeType
getPathNodeType
(BlockState state, BlockView world, BlockPos pos, boolean neighbor) Gets thePathNodeType
from the provider registered for the specified block state at the specified position.static @Nullable LandPathNodeTypesRegistry.PathNodeTypeProvider
getPathNodeTypeProvider
(Block block) Gets the rawLandPathNodeTypesRegistry.PathNodeTypeProvider
registered for the specified block.static void
register
(Block block, @Nullable PathNodeType nodeType, @Nullable PathNodeType nodeTypeIfNeighbor) Registers aPathNodeType
for the specified block, overriding the default block behavior.static void
register
(Block block, LandPathNodeTypesRegistry.StaticPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.StaticPathNodeTypeProvider
for the specified block overriding the default block behavior.static void
registerDynamic
(Block block, LandPathNodeTypesRegistry.DynamicPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.DynamicPathNodeTypeProvider
for the specified block, overriding the default block behavior.
-
Method Details
-
register
public static void register(Block block, @Nullable @Nullable PathNodeType nodeType, @Nullable @Nullable PathNodeType nodeTypeIfNeighbor) Registers aPathNodeType
for the specified block, overriding the default block behavior.- Parameters:
block
- Block to register.nodeType
-PathNodeType
to associate with the block if it is a direct target in an entity path. (Passnull
to not specify a node type and use the default behavior)nodeTypeIfNeighbor
-PathNodeType
to associate with the block, if it is in a direct neighbor position to an entity path that is directly next to a block that the entity will pass through or above. (Passnull
to not specify a node type and use the default behavior)
-
register
public static void register(Block block, LandPathNodeTypesRegistry.StaticPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.StaticPathNodeTypeProvider
for the specified block overriding the default block behavior.A static provider provides the node type basing on the block state.
- Parameters:
block
- Block to register.provider
-LandPathNodeTypesRegistry.StaticPathNodeTypeProvider
to associate with the block.
-
registerDynamic
public static void registerDynamic(Block block, LandPathNodeTypesRegistry.DynamicPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.DynamicPathNodeTypeProvider
for the specified block, overriding the default block behavior.A dynamic provider provides the node type basing on the block state, world and position. This is more difficult to handle, must be used only if you want to change the node type basing on the position of the block in the world, and may degrade the game performances because cannot be optimized but must be recalculated at every tick for every entity.
- Parameters:
block
- Block to register.provider
-LandPathNodeTypesRegistry.DynamicPathNodeTypeProvider
to associate with the block.
-
getPathNodeType
@Nullable public static @Nullable PathNodeType getPathNodeType(BlockState state, BlockView world, BlockPos pos, boolean neighbor) Gets thePathNodeType
from the provider registered for the specified block state at the specified position.If no valid
PathNodeType
provider is registered for the block, it returnsnull
. You cannot use this method to retrieve vanilla block node types.- Parameters:
state
- Current block state.world
- Current world.pos
- Current position.neighbor
- Specifies if the block is not a directly targeted block, but a neighbor block in the path.- Returns:
- the custom
PathNodeType
from the provider registered for the specified block, passing the block state, the world, and the position to the provider, ornull
if no valid provider is registered for the block.
-
getPathNodeTypeProvider
@Nullable public static @Nullable LandPathNodeTypesRegistry.PathNodeTypeProvider getPathNodeTypeProvider(Block block) Gets the rawLandPathNodeTypesRegistry.PathNodeTypeProvider
registered for the specified block.If no
LandPathNodeTypesRegistry.PathNodeTypeProvider
is registered for the block, it returnsnull
.Note 1:
LandPathNodeTypesRegistry.PathNodeTypeProvider
is a marker interface with no methods, so you need to cast the result to a subtype, in order to get something from it. Currently, if non-null, the result can be ofLandPathNodeTypesRegistry.StaticPathNodeTypeProvider
orLandPathNodeTypesRegistry.DynamicPathNodeTypeProvider
. Note that more kinds of providers might be added if the API is expanded in the future, so make sure not to fail if another type of object is returned.Note 2: This method is intended to be used in any cases in which you need to get the raw provider for the block, if you need the
PathNodeType
for the block state instead, you can simply usegetPathNodeType(net.minecraft.block.BlockState, net.minecraft.world.BlockView, net.minecraft.util.math.BlockPos, boolean)
.- Parameters:
block
- Current block.- Returns:
- the
LandPathNodeTypesRegistry.PathNodeTypeProvider
registered for the specified block, ornull
if no provider is registered for the block.
-