Class PathfindingUtils
java.lang.Object
com.minecolonies.core.entity.pathfinding.PathfindingUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap for tracking specific path types, type to player uuidWhich citizens are being tracked by which players. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasAnyCollisionAlong(int startX, int startY, int startZ, int endX, int endY, int endZ, CachingBlockLookup blockLookup) Checks for collisions along a line between two given positionsstatic booleanisDangerous(net.minecraft.world.level.block.state.BlockState blockState) Is the surface inherently dangerous to stand on/in (i.e.static booleanisLadder(net.minecraft.world.level.block.state.BlockState blockState, @Nullable PathingOptions options) Checks if the given state is a ladder, or if pathing options allow a different type of climbablestatic booleanisLadder(net.minecraft.world.level.block.state.BlockState state, PathingOptions options, int nextX, int nextY, int nextZ, CachingBlockLookup cachedBlockLookup) static booleanisLava(@NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.level.block.state.BlockState pState, @Nullable net.minecraft.world.level.material.FluidState pFluidState) Check if the block at this position is lava.static booleanisLiquid(net.minecraft.world.level.block.state.BlockState state) Check if this is a liquid state for swimming.static booleanisWater(@NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos) Check if the block at this position is actually some kind of waterly fluid.static booleanisWater(@NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.level.block.state.BlockState pState, @Nullable net.minecraft.world.level.material.FluidState pFluidState) Check if the block at this position is actually some kind of waterly fluid.static net.minecraft.core.BlockPosprepareStart(@NotNull net.minecraft.world.entity.LivingEntity entity) Generates a good path starting location for the entity to path from, correcting for the following conditions.static voidsetLadderFacing(@NotNull net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, @NotNull PathPointExtended p) Sets the direction where the ladder is facing.static voidsyncDebugReachedPositions(HashSet<net.minecraft.core.BlockPos> reached, List<net.minecraft.server.level.ServerPlayer> players) Set the set of reached blocks to the client.
-
Field Details
-
trackingMap
Which citizens are being tracked by which players. Player to entity uuid -
trackByType
Map for tracking specific path types, type to player uuid
-
-
Constructor Details
-
PathfindingUtils
public PathfindingUtils()
-
-
Method Details
-
syncDebugReachedPositions
public static void syncDebugReachedPositions(HashSet<net.minecraft.core.BlockPos> reached, List<net.minecraft.server.level.ServerPlayer> players) Set the set of reached blocks to the client.- Parameters:
reached- the reached blocks.players- the tracking players.
-
prepareStart
public static net.minecraft.core.BlockPos prepareStart(@NotNull @NotNull net.minecraft.world.entity.LivingEntity entity) Generates a good path starting location for the entity to path from, correcting for the following conditions. - Being in water: pathfinding in water occurs along the surface; adjusts position to surface. - Being in a fence space: finds correct adjacent position which is not a fence space, to prevent starting path. from within the fence block.- Parameters:
entity- Entity for the pathfinding operation.- Returns:
- ChunkCoordinates for starting location.
-
setLadderFacing
public static void setLadderFacing(@NotNull @NotNull net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, @NotNull @NotNull PathPointExtended p) Sets the direction where the ladder is facing.- Parameters:
world- the world in.pos- the position.p- the path.
-
isLiquid
public static boolean isLiquid(net.minecraft.world.level.block.state.BlockState state) Check if this is a liquid state for swimming.- Parameters:
state- the state to check.- Returns:
- true if so.
-
isWater
public static boolean isWater(@NotNull @NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos) Check if the block at this position is actually some kind of waterly fluid.- Parameters:
pos- the pos in the world.- Returns:
- true if so.
-
isWater
public static boolean isWater(@NotNull @NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.level.block.state.BlockState pState, @Nullable @Nullable net.minecraft.world.level.material.FluidState pFluidState) Check if the block at this position is actually some kind of waterly fluid.- Parameters:
pos- the pos in the world.pState- existing blockstate or nullpFluidState- existing fluidstate or null- Returns:
- true if so.
-
isLava
public static boolean isLava(@NotNull @NotNull net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.world.level.block.state.BlockState pState, @Nullable @Nullable net.minecraft.world.level.material.FluidState pFluidState) Check if the block at this position is lava.- Parameters:
pos- the pos in the world.pState- existing blockstate or nullpFluidState- existing fluidstate or null- Returns:
- true if so.
-
isLadder
public static boolean isLadder(net.minecraft.world.level.block.state.BlockState blockState, @Nullable @Nullable PathingOptions options) Checks if the given state is a ladder, or if pathing options allow a different type of climbable- Parameters:
blockState-options-- Returns:
-
isLadder
public static boolean isLadder(net.minecraft.world.level.block.state.BlockState state, PathingOptions options, int nextX, int nextY, int nextZ, CachingBlockLookup cachedBlockLookup) -
isDangerous
public static boolean isDangerous(net.minecraft.world.level.block.state.BlockState blockState) Is the surface inherently dangerous to stand on/in (i.e. causes damage).- Parameters:
blockState- block to check.- Returns:
- true if dangerous.
-
hasAnyCollisionAlong
public static boolean hasAnyCollisionAlong(int startX, int startY, int startZ, int endX, int endY, int endZ, CachingBlockLookup blockLookup) Checks for collisions along a line between two given positions- Parameters:
startX-startY-startZ-endX-endY-endZ-blockLookup-- Returns:
-