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 interfacestatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMinecraftGraph(net.minecraft.world.level.BlockGetter blockAccessor, ProjectedInventory inventory, PathConstraint pathConstraint) Creates an instance of aMinecraftGraphrecord class. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.level.BlockGetterReturns the value of theblockAccessorrecord component.booleandisallowedToBreakBlock(SFVec3i position) booleandisallowedToBreakBlock(net.minecraft.world.level.block.Block blockType) booleandisallowedToPlaceBlock(SFVec3i position) booleanfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.voidinsertActions(SFVec3i node, @Nullable ActionDirection fromDirection, Consumer<GraphInstructions> callback) Returns the value of theinventoryrecord component.Returns the value of thepathConstraintrecord component.final StringtoString()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 aMinecraftGraphrecord class.- Parameters:
blockAccessor- the value for theblockAccessorrecord componentinventory- the value for theinventoryrecord componentpathConstraint- the value for thepathConstraintrecord 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
-
hashCode
-
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 theblockAccessorrecord component.- Returns:
- the value of the
blockAccessorrecord component
-
inventory
-
pathConstraint
Returns the value of thepathConstraintrecord component.- Returns:
- the value of the
pathConstraintrecord component
-