Record Class MinecraftGraph
java.lang.Object
java.lang.Record
com.soulfiremc.server.pathfinding.graph.MinecraftGraph
- Record Components:
blockAccessor
- The block accessorinventory
- The inventory of the botpathConstraint
- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static enum
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMinecraftGraph
(net.minecraft.world.level.BlockGetter blockAccessor, ProjectedInventory inventory, PathConstraint pathConstraint) Creates an instance of aMinecraftGraph
record class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.level.BlockGetter
Returns the value of theblockAccessor
record component.boolean
disallowedToBreakBlock
(SFVec3i position) boolean
disallowedToBreakBlock
(net.minecraft.world.level.block.Block blockType) boolean
disallowedToPlaceBlock
(SFVec3i position) boolean
final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.void
insertActions
(SFVec3i node, @Nullable ActionDirection fromDirection, Consumer<GraphInstructions> callback) Returns the value of theinventory
record component.Returns the value of thepathConstraint
record component.final String
toString()
Returns a string representation of this record class.
-
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 aMinecraftGraph
record class.- Parameters:
blockAccessor
- the value for theblockAccessor
record componentinventory
- the value for theinventory
record componentpathConstraint
- the value for thepathConstraint
record component
-
-
Method Details
-
doUsableBlocksDecreaseWhenPlaced
public boolean doUsableBlocksDecreaseWhenPlaced() -
disallowedToPlaceBlock
-
disallowedToBreakBlock
-
disallowedToBreakBlock
public boolean disallowedToBreakBlock(net.minecraft.world.level.block.Block blockType) -
insertActions
public void insertActions(SFVec3i node, @Nullable ActionDirection fromDirection, Consumer<GraphInstructions> callback) -
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
blockAccessor
public net.minecraft.world.level.BlockGetter blockAccessor()Returns the value of theblockAccessor
record component.- Returns:
- the value of the
blockAccessor
record component
-
inventory
Returns the value of theinventory
record component.- Returns:
- the value of the
inventory
record component
-
pathConstraint
Returns the value of thepathConstraint
record component.- Returns:
- the value of the
pathConstraint
record component
-