Record Class MinecraftGraph

java.lang.Object
java.lang.Record
com.soulfiremc.server.pathfinding.graph.MinecraftGraph
Record Components:
blockAccessor - The block accessor
inventory - The inventory of the bot
pathConstraint - The path constraint

public record MinecraftGraph(net.minecraft.world.level.BlockGetter blockAccessor, ProjectedInventory inventory, PathConstraint pathConstraint) extends Record
Minecraft world, but observed as a graph of actions between blocks. A node would be a block and the edges would be the actions that can be performed on that block. An action MUST lead to another block in the "graph". If you know graph theory this may sound familiar. All checks are predefined "subscriptions" of a block relative to the foot position of a bot. This way we can most efficiently calculate the actions that can be performed on a blocks by immediately running multiple actions per block. Traditionally an action would dynamically check if it is possible and a block would be considered multiple times across multiple actions. However, with subscriptions multiple actions can "opt-in" to a block and perform their checks on a block a single time.
  • Field Details

    • ACTIONS_SIZE

      public static final int ACTIONS_SIZE
  • Constructor Details

    • MinecraftGraph

      public MinecraftGraph(net.minecraft.world.level.BlockGetter blockAccessor, ProjectedInventory inventory, PathConstraint pathConstraint)
      Creates an instance of a MinecraftGraph record class.
      Parameters:
      blockAccessor - the value for the blockAccessor record component
      inventory - the value for the inventory record component
      pathConstraint - the value for the pathConstraint record component
  • Method Details

    • doUsableBlocksDecreaseWhenPlaced

      public boolean doUsableBlocksDecreaseWhenPlaced()
    • disallowedToPlaceBlock

      public boolean disallowedToPlaceBlock(SFVec3i position)
    • disallowedToBreakBlock

      public boolean disallowedToBreakBlock(SFVec3i position)
    • disallowedToBreakBlock

      public boolean disallowedToBreakBlock(net.minecraft.world.level.block.Block blockType)
    • insertActions

      public void insertActions(SFVec3i node, @Nullable ActionDirection fromDirection, Consumer<GraphInstructions> callback)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • blockAccessor

      public net.minecraft.world.level.BlockGetter blockAccessor()
      Returns the value of the blockAccessor record component.
      Returns:
      the value of the blockAccessor record component
    • inventory

      public ProjectedInventory inventory()
      Returns the value of the inventory record component.
      Returns:
      the value of the inventory record component
    • pathConstraint

      public PathConstraint pathConstraint()
      Returns the value of the pathConstraint record component.
      Returns:
      the value of the pathConstraint record component