Class PathJobFindTree

java.lang.Object
com.minecolonies.core.entity.pathfinding.pathjobs.AbstractPathJob
com.minecolonies.core.entity.pathfinding.pathjobs.PathJobFindTree
All Implemented Interfaces:
IPathJob, ISearchPathJob, Callable<net.minecraft.world.level.pathfinder.Path>

public class PathJobFindTree extends AbstractPathJob implements ISearchPathJob
Find and return a path to the nearest tree. Created: May 21, 2015
  • Constructor Details

    • PathJobFindTree

      public PathJobFindTree(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos home, int range, List<ItemStorage> treesToCut, int dyntreesize, IColony colony, net.minecraft.world.entity.Mob entity)
      AbstractPathJob constructor.
      Parameters:
      world - the world within which to path.
      start - the start position from which to path from.
      home - the position of the worker hut.
      range - maximum path range.
      treesToCut - the trees the lj is supposed to cut.
      entity - the entity.
      dyntreesize - the radius a dynamic tree must have
      colony - the colony.
    • PathJobFindTree

      public PathJobFindTree(net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos startRestriction, net.minecraft.core.BlockPos endRestriction, net.minecraft.core.BlockPos furthestRestriction, List<ItemStorage> excludedTrees, int dyntreesize, IColony colony, net.minecraft.world.entity.Mob entity)
      AbstractPathJob constructor.
      Parameters:
      world - the world within which to path.
      start - the start position from which to path from.
      startRestriction - start of the restricted area.
      endRestriction - end of the restricted area.
      excludedTrees - the trees the lj is not supposed to cut.
      dyntreesize - the radius a dynamic tree must have
      entity - the entity.
      colony - the colony.
  • Method Details

    • getResult

      @NotNull public @NotNull TreePathResult getResult()
      Description copied from interface: IPathJob
      Get the path result holder for this job
      Specified by:
      getResult in interface IPathJob
      Overrides:
      getResult in class AbstractPathJob
      Returns:
    • computeHeuristic

      protected double computeHeuristic(int x, int y, int z)
      Description copied from class: AbstractPathJob
      Compute the heuristic cost ('h' value) of a given position x,y,z.

      Returning a value of 0 performs a breadth-first search. Returning a value less than actual possible cost to goal guarantees shortest path, but at computational expense. Returning a value exactly equal to the cost to the goal guarantees shortest path and least expense (but generally. only works when path is straight and unblocked). Returning a value greater than the actual cost to goal produces good, but not perfect paths, and is fast. Returning a very high value (such that 'h' is very high relative to 'g') then only 'h' (the heuristic) matters as the search will be a very fast greedy best-first-search, ignoring cost weighting and distance.

      Specified by:
      computeHeuristic in class AbstractPathJob
      Returns:
      the heuristic.
    • isAtDestination

      protected boolean isAtDestination(@NotNull @NotNull MNode n)
      Description copied from class: AbstractPathJob
      Return true if the given node is a viable final destination, and the path should generate to here.
      Specified by:
      isAtDestination in class AbstractPathJob
      Parameters:
      n - Node to test.
      Returns:
      true if the node is a viable destination.
    • getEndNodeScore

      public double getEndNodeScore(MNode n)
      Description copied from class: AbstractPathJob
      Calculates a score for potential points where the path may end given no destination By default the heuristic for the closest node is used
      Specified by:
      getEndNodeScore in interface ISearchPathJob
      Overrides:
      getEndNodeScore in class AbstractPathJob
      Parameters:
      n - Node to test.
      Returns:
      score for the node, lower is better
    • isPassable

      protected boolean isPassable(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState block, int x, int y, int z, MNode parent, boolean head)
      Description copied from class: AbstractPathJob
      Is the space passable.
      Overrides:
      isPassable in class AbstractPathJob
      Parameters:
      block - the block we are checking.
      parent - the parent node.
      head - the head position.
      Returns:
      true if the block does not block movement.
    • modifyCost

      protected double modifyCost(double cost, MNode parent, boolean swimstart, boolean swimming, int x, int y, int z, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.state.BlockState below)
      Description copied from class: AbstractPathJob
      Modifies costs if needed for a node
      Overrides:
      modifyCost in class AbstractPathJob
      Returns: