Class LandPathNodeTypesRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA functional interface that provides thePathNodeType, given the block state world and position.static interfaceGeneric provider, this is a marker interface.static interfaceA functional interface that provides thePathNodeType, given the block state. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable PathNodeTypegetPathNodeType(BlockState state, BlockView world, BlockPos pos, boolean neighbor) Gets thePathNodeTypefrom the provider registered for the specified block state at the specified position.static @Nullable LandPathNodeTypesRegistry.PathNodeTypeProvidergetPathNodeTypeProvider(Block block) Gets the rawLandPathNodeTypesRegistry.PathNodeTypeProviderregistered for the specified block.static voidregister(Block block, LandPathNodeTypesRegistry.StaticPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.StaticPathNodeTypeProviderfor the specified block overriding the default block behavior.static voidregister(Block block, @Nullable PathNodeType nodeType, @Nullable PathNodeType nodeTypeIfNeighbor) Registers aPathNodeTypefor the specified block, overriding the default block behavior.static voidregisterDynamic(Block block, LandPathNodeTypesRegistry.DynamicPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.DynamicPathNodeTypeProviderfor 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 aPathNodeTypefor the specified block, overriding the default block behavior.- Parameters:
block- Block to register.nodeType-PathNodeTypeto associate with the block if it is a direct target in an entity path. (Passnullto not specify a node type and use the default behavior)nodeTypeIfNeighbor-PathNodeTypeto 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. (Passnullto not specify a node type and use the default behavior)
-
register
public static void register(Block block, LandPathNodeTypesRegistry.StaticPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.StaticPathNodeTypeProviderfor 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.StaticPathNodeTypeProviderto associate with the block.
-
registerDynamic
public static void registerDynamic(Block block, LandPathNodeTypesRegistry.DynamicPathNodeTypeProvider provider) Registers aLandPathNodeTypesRegistry.DynamicPathNodeTypeProviderfor 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.DynamicPathNodeTypeProviderto associate with the block.
-
getPathNodeType
@Nullable public static @Nullable PathNodeType getPathNodeType(BlockState state, BlockView world, BlockPos pos, boolean neighbor) Gets thePathNodeTypefrom the provider registered for the specified block state at the specified position.If no valid
PathNodeTypeprovider 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
PathNodeTypefrom the provider registered for the specified block, passing the block state, the world, and the position to the provider, ornullif no valid provider is registered for the block.
-
getPathNodeTypeProvider
@Nullable public static @Nullable LandPathNodeTypesRegistry.PathNodeTypeProvider getPathNodeTypeProvider(Block block) Gets the rawLandPathNodeTypesRegistry.PathNodeTypeProviderregistered for the specified block.If no
LandPathNodeTypesRegistry.PathNodeTypeProvideris registered for the block, it returnsnull.Note 1:
LandPathNodeTypesRegistry.PathNodeTypeProvideris 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.StaticPathNodeTypeProviderorLandPathNodeTypesRegistry.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
PathNodeTypefor 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.PathNodeTypeProviderregistered for the specified block, ornullif no provider is registered for the block.
-