Class NodeManager

java.lang.Object
com.chiefminingdad.autoplayer.node.NodeManager

public class NodeManager extends Object
Stores Information about "Nodes" accessible by other sections of the mod.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The List containing all the Nodes which store their relation to each-other.
    Hashtable<net.minecraft.core.Vec3i, Integer>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addNode(@NonNull Node newNode)
    Adds a new node to the system in the next available slot.
    net.minecraft.core.Vec3i[]
    Gets all surrounding nodes, adds all previously unused locations to the List and HashTable
    boolean
    containsVector(net.minecraft.core.Vec3i vector)
     
    static double
    getDistanceWeight(@NonNull net.minecraft.core.Vec3i CurrentNode, net.minecraft.core.Vec3i FinalNode)
    A function that will be used for the heuristic required for the A* pathfinding algorithm.
    getNode(int index)
     
    getNode(net.minecraft.core.Vec3i vector)
     
    int
    getNodeIndex(net.minecraft.core.Vec3i vector)
     
    static net.minecraft.core.Vec3i[]
    getSurrounding(net.minecraft.core.Vec3i centre)
     
    void
    Used when the pathfinding needs to start from a new location as all previous data is useless.
    void
    setNode(net.minecraft.core.Vec3i vector, Node newNode)
     
    void
    Used in case a node is removed from the list and the dictionary needs to be updated.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ReferenceTable

      public Hashtable<net.minecraft.core.Vec3i, Integer> ReferenceTable
    • NodeList

      public ArrayList<Node> NodeList
      The List containing all the Nodes which store their relation to each-other.
  • Constructor Details

    • NodeManager

      public NodeManager(Node first)
  • Method Details

    • resetStartNode

      public void resetStartNode(Node first)
      Used when the pathfinding needs to start from a new location as all previous data is useless.
      Parameters:
      first - Which node is going to be the starting node.
    • addNode

      public void addNode(@NonNull Node newNode)
      Adds a new node to the system in the next available slot.
      Parameters:
      newNode - The node to be added
    • updateIndexes

      public void updateIndexes()
      Used in case a node is removed from the list and the dictionary needs to be updated.
    • getNodeIndex

      public int getNodeIndex(net.minecraft.core.Vec3i vector)
      Parameters:
      vector - The position of the requested Node in the world.
      Returns:
      The index of the node with the specified coordinate in the list.
    • getNode

      public Node getNode(net.minecraft.core.Vec3i vector)
      Parameters:
      vector - The location of the node to get.
      Returns:
      The Node at the location given.
    • getNode

      public Node getNode(int index)
      Parameters:
      index - The index in NodeList to get.
      Returns:
      The Node at the given index.
    • setNode

      public void setNode(net.minecraft.core.Vec3i vector, Node newNode)
      Parameters:
      vector - The location of the Node that is being set/replaced.
      newNode - The Node that will replace the current stored Node
    • containsVector

      public boolean containsVector(net.minecraft.core.Vec3i vector)
      Parameters:
      vector - The vector to check whether is stored.
      Returns:
      Whether there is a Vector of the same value stored.
    • getDistanceWeight

      public static double getDistanceWeight(@NonNull net.minecraft.core.Vec3i CurrentNode, net.minecraft.core.Vec3i FinalNode)
      A function that will be used for the heuristic required for the A* pathfinding algorithm.
      Returns:
      The distance weight from the given node to the given end node.
    • addSurroundingNodes

      public net.minecraft.core.Vec3i[] addSurroundingNodes(Node centre)
      Gets all surrounding nodes, adds all previously unused locations to the List and HashTable
      Parameters:
      centre - The position for all the new vectors to come from.
      Returns:
      Vec3i[] The array of all locations that had a duplicate already stored.
    • getSurrounding

      public static net.minecraft.core.Vec3i[] getSurrounding(net.minecraft.core.Vec3i centre)
      Parameters:
      centre - The location at which to return the surrounding vectors from.
      Returns:
      An array of all the vectors adjacent to the centre.