Class LandPathTypeRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA functional interface that provides thePathType, given the block state level and position.static interfaceGeneric provider, this is a marker interface.static interfaceA functional interface that provides thePathType, given the block state. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable net.minecraft.world.level.pathfinder.PathTypegetPathType(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, boolean neighbor) Gets thePathTypefrom the provider registered for the specified block state at the specified position.static @Nullable LandPathTypeRegistry.PathTypeProvidergetPathTypeProvider(net.minecraft.world.level.block.Block block) Gets the rawLandPathTypeRegistry.PathTypeProviderregistered for the specified block.static voidregister(net.minecraft.world.level.block.Block block, LandPathTypeRegistry.StaticPathTypeProvider provider) Registers aLandPathTypeRegistry.StaticPathTypeProviderfor the specified block overriding the default block behavior.static voidregister(net.minecraft.world.level.block.Block block, @Nullable net.minecraft.world.level.pathfinder.PathType pathType, @Nullable net.minecraft.world.level.pathfinder.PathType pathTypeIfNeighbor) Registers aPathTypefor the specified block, overriding the default block behavior.static voidregisterDynamic(net.minecraft.world.level.block.Block block, LandPathTypeRegistry.DynamicPathTypeProvider provider) Registers aLandPathTypeRegistry.DynamicPathTypeProviderfor the specified block, overriding the default block behavior.
-
Method Details
-
register
public static void register(net.minecraft.world.level.block.Block block, @Nullable net.minecraft.world.level.pathfinder.PathType pathType, @Nullable net.minecraft.world.level.pathfinder.PathType pathTypeIfNeighbor) Registers aPathTypefor the specified block, overriding the default block behavior.- Parameters:
block- Block to register.pathType-PathTypeto associate with the block if it is a direct target in an entity path. (Passnullto not specify a path type and use the default behavior)pathTypeIfNeighbor-PathTypeto 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 path type and use the default behavior)
-
register
public static void register(net.minecraft.world.level.block.Block block, LandPathTypeRegistry.StaticPathTypeProvider provider) Registers aLandPathTypeRegistry.StaticPathTypeProviderfor the specified block overriding the default block behavior.A static provider provides the path type basing on the block state.
- Parameters:
block- Block to register.provider-LandPathTypeRegistry.StaticPathTypeProviderto associate with the block.
-
registerDynamic
public static void registerDynamic(net.minecraft.world.level.block.Block block, LandPathTypeRegistry.DynamicPathTypeProvider provider) Registers aLandPathTypeRegistry.DynamicPathTypeProviderfor the specified block, overriding the default block behavior.A dynamic provider provides the path type basing on the block state, level and position. This is more difficult to handle, must be used only if you want to change the path 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-LandPathTypeRegistry.DynamicPathTypeProviderto associate with the block.
-
getPathType
public static @Nullable net.minecraft.world.level.pathfinder.PathType getPathType(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, boolean neighbor) Gets thePathTypefrom the provider registered for the specified block state at the specified position.If no valid
PathTypeprovider is registered for the block, it returnsnull. You cannot use this method to retrieve vanilla block path types.- Parameters:
state- Current block state.level- Current level.pos- Current position.neighbor- Specifies if the block is not a directly targeted block, but a neighbor block in the path.- Returns:
- the custom
PathTypefrom the provider registered for the specified block, passing the block state, the level, and the position to the provider, ornullif no valid provider is registered for the block.
-
getPathTypeProvider
public static @Nullable LandPathTypeRegistry.PathTypeProvider getPathTypeProvider(net.minecraft.world.level.block.Block block) Gets the rawLandPathTypeRegistry.PathTypeProviderregistered for the specified block.If no
LandPathTypeRegistry.PathTypeProvideris registered for the block, it returnsnull.Note 1:
LandPathTypeRegistry.PathTypeProvideris 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 ofLandPathTypeRegistry.StaticPathTypeProviderorLandPathTypeRegistry.DynamicPathTypeProvider. 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
PathTypefor the block state instead, you can simply usegetPathType(BlockState, BlockGetter, BlockPos, boolean).- Parameters:
block- Current block.- Returns:
- the
LandPathTypeRegistry.PathTypeProviderregistered for the specified block, ornullif no provider is registered for the block.
-