java.lang.Object
com.minecolonies.core.entity.pathfinding.MNode
All Implemented Interfaces:
Comparable<MNode>

public class MNode extends Object implements Comparable<MNode>
Nodes used in pathfinding.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    @Nullable MNode
    The parent of the node (Node preceding this node).
    final @org.jetbrains.annotations.NotNull int
    The position of the node.
    final int
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MNode(@Nullable MNode parent, @org.jetbrains.annotations.NotNull int posX, int posY, int posZ, double cost, double heuristic)
    Create a Node that inherits from a parent, and has a Cost and Heuristic estimate.
    MNode(net.minecraft.network.RegistryFriendlyByteBuf byteBuf)
    Create an MNode from a bytebuf.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(@NotNull MNode o)
     
    static int
    computeNodeKey(int x, int y, int z)
    Generate a pseudo-unique key for identifying a given node by it's coordinates Encodes the lowest 12 bits of x,z and all useful bits of y.
    boolean
    equals(@Nullable Object o)
     
    double
    Getter of the cost of the node.
    int
    Get the added index
    int
    Getter of the added counter.
    double
    Getter of the heuristic.
    double
    Getter of the score of the node.
    int
    Get the visited count
    int
     
    void
    Sets the node as closed.
    boolean
    Whether the node is reached by a worker
    boolean
    Checks if node is on a ladder.
    boolean
    Check if is on rails.
    boolean
    Whether the node is reached by a worker
    boolean
    Checks if node is in water.
    boolean
    Checks if node is closed.
    void
    serializeToBuf(net.minecraft.network.RegistryFriendlyByteBuf byteBuf)
    Serialize the Node to buf.
    void
    setCornerNode(boolean isCornerNode)
    Marks the node as reached by the worker
    void
    setCost(double cost)
    Sets the node cost.
    void
    setCounterAdded(int counterAdded)
    Sets the added counter.
    void
    setHeuristic(double heuristic)
    Sets the node heuristic.
    void
    Sets the node as a ladder node.
    void
    setOnRails(boolean isOnRails)
    Setup rails params.
    void
    setReachedByWorker(boolean reached)
    Marks the node as reached by the worker
    void
    Sets the node as a swimming node.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      @NotNull public final @org.jetbrains.annotations.NotNull int x
      The position of the node.
    • y

      public final int y
    • z

      public final int z
    • parent

      @Nullable public @Nullable MNode parent
      The parent of the node (Node preceding this node).
  • Constructor Details

    • MNode

      public MNode(@Nullable @Nullable MNode parent, @NotNull @org.jetbrains.annotations.NotNull int posX, int posY, int posZ, double cost, double heuristic)
      Create a Node that inherits from a parent, and has a Cost and Heuristic estimate.
      Parameters:
      parent - parent node arrives from.
      cost - node cost.
      heuristic - heuristic estimate.
    • MNode

      public MNode(net.minecraft.network.RegistryFriendlyByteBuf byteBuf)
      Create an MNode from a bytebuf.
      Parameters:
      byteBuf - the buffer to load it from.
  • Method Details

    • serializeToBuf

      public void serializeToBuf(net.minecraft.network.RegistryFriendlyByteBuf byteBuf)
      Serialize the Node to buf.
      Parameters:
      byteBuf -
    • compareTo

      public int compareTo(@NotNull @NotNull MNode o)
      Specified by:
      compareTo in interface Comparable<MNode>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable @Nullable Object o)
      Overrides:
      equals in class Object
    • isVisited

      public boolean isVisited()
      Checks if node is closed.
      Returns:
      true if so.
    • getVisitedCount

      public int getVisitedCount()
      Get the visited count
      Returns:
    • isLadder

      public boolean isLadder()
      Checks if node is on a ladder.
      Returns:
      true if so.
    • isSwimming

      public boolean isSwimming()
      Checks if node is in water.
      Returns:
      true if so.
    • increaseVisited

      public void increaseVisited()
      Sets the node as closed.
    • getScore

      public double getScore()
      Getter of the score of the node.
      Returns:
      the score.
    • getCost

      public double getCost()
      Getter of the cost of the node.
      Returns:
      the cost.
    • setCost

      public void setCost(double cost)
      Sets the node cost.
      Parameters:
      cost - the cost.
    • setLadder

      public void setLadder()
      Sets the node as a ladder node.
    • setSwimming

      public void setSwimming()
      Sets the node as a swimming node.
    • getHeuristic

      public double getHeuristic()
      Getter of the heuristic.
      Returns:
      the heuristic.
    • setHeuristic

      public void setHeuristic(double heuristic)
      Sets the node heuristic.
      Parameters:
      heuristic - the heuristic.
    • getDebugAddedIndex

      public int getDebugAddedIndex()
      Getter of the added counter.
      Returns:
      the amount.
    • setCounterAdded

      public void setCounterAdded(int counterAdded)
      Sets the added counter.
      Parameters:
      counterAdded - amount to set.
    • setOnRails

      public void setOnRails(boolean isOnRails)
      Setup rails params.
      Parameters:
      isOnRails - if on rails.
    • isOnRails

      public boolean isOnRails()
      Check if is on rails.
      Returns:
      true if so.
    • setReachedByWorker

      public void setReachedByWorker(boolean reached)
      Marks the node as reached by the worker
      Parameters:
      reached - if reached or reset.
    • isReachedByWorker

      public boolean isReachedByWorker()
      Whether the node is reached by a worker
      Returns:
      reached
    • setCornerNode

      public void setCornerNode(boolean isCornerNode)
      Marks the node as reached by the worker
    • isCornerNode

      public boolean isCornerNode()
      Whether the node is reached by a worker
      Returns:
      reached
    • getCounterAdded

      public int getCounterAdded()
      Get the added index
      Returns:
    • computeNodeKey

      public static int computeNodeKey(int x, int y, int z)
      Generate a pseudo-unique key for identifying a given node by it's coordinates Encodes the lowest 12 bits of x,z and all useful bits of y. This creates unique keys for all blocks within a 4096x256x4096 cube, which is FAR bigger volume than one should attempt to pathfind within
      Returns:
      key for node in map
    • toString

      public String toString()
      Overrides:
      toString in class Object