Package-level declarations

Types

Link copied to clipboard

Tracks locations of specific states in the world.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class ShortestPath<T>(val nodes: List<T>, val totalCost: Double) : Record
Link copied to clipboard
enum SwingMode : Tagged, Consumer<InteractionHand> , Enum<SwingMode>
Link copied to clipboard
data class WeightedEdge<T>(val node: T, val cost: Double) : Record

Properties

Link copied to clipboard
val AABB.collidingRegion: BoundingBox
Link copied to clipboard
val BlockPos.collisionShape: VoxelShape
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val BlockPos.immutable: BlockPos

Converts this BlockPos to an immutable one if needed.

Link copied to clipboard
val BlockState.isBed: Boolean
Link copied to clipboard
val BlockState?.isInteractable: Boolean
Link copied to clipboard

Some blocks like slabs or stairs must be placed on upper side in order to be placed correctly.

Link copied to clipboard
val BlockPos.outlineBox: AABB

Returns the block box outline of the block at the position. If the block is air, it will return an empty box. Outline Box should be used for rendering purposes only.

Link copied to clipboard
val BlockPos.outlineShape: VoxelShape
Link copied to clipboard
val BlockPos.state: BlockState?
Link copied to clipboard
val BlockPos.stateOrEmpty: BlockState
Link copied to clipboard
val BlockHitResult.targetBlockPos: BlockPos

Functions

Link copied to clipboard
fun BlockState?.anotherBedPartDirection(): Direction?
Link copied to clipboard
fun BlockState?.anotherChestPartDirection(): Direction?
Link copied to clipboard
fun <T> aStarShortestPath(start: T, isGoal: Predicate<T>, neighbors: (T) -> Iterable<WeightedEdge<T>>, heuristic: ToDoubleFunction<T>, maxIterations: Int = Int.MAX_VALUE, maxCost: Double = Double.POSITIVE_INFINITY): ShortestPath<T>?

Finds the shortest path using A* search.

Link copied to clipboard
fun BlockState.canBeReplacedWith(pos: BlockPos, usedStack: ItemStack): Boolean
Link copied to clipboard
fun BlockPos.canStandOn(): Boolean
Link copied to clipboard
inline fun AABB.collideBlockIntersects(checkCollisionShape: Boolean = true, isCorrectBlock: (Block) -> Boolean): Boolean

Check if box intersects with bounding box of specified blocks

Link copied to clipboard
fun <T> dijkstraShortestPath(start: T, isGoal: Predicate<T>, neighbors: (T) -> Iterable<WeightedEdge<T>>, maxIterations: Int = Int.MAX_VALUE, maxCost: Double = Double.POSITIVE_INFINITY): ShortestPath<T>?

Returns the shortest path from start to the first node where isGoal returns true.

Link copied to clipboard
fun doBreak(rayTraceResult: BlockHitResult, immediate: Boolean = false, swingMode: SwingMode = SwingMode.DO_NOT_HIDE)

Breaks the block

Link copied to clipboard
fun doPlacement(hitResult: BlockHitResult, hand: InteractionHand = InteractionHand.MAIN_HAND, onPlacementSuccess: () -> Boolean = { true }, onItemUseSuccess: () -> Boolean = { true }, swingMode: SwingMode = SwingMode.DO_NOT_HIDE)

Simulated net.minecraft.world.phys.HitResult.Type.BLOCK branch in vanilla

Link copied to clipboard
fun BlockPos.getBlock(): Block?
Link copied to clipboard
inline fun BlockPos.getBlockingEntities(include: (Entity) -> Boolean = { true }): List<Entity>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun BedBlock.getPotentialSecondBedBlock(state: BlockState, pos: BlockPos): BlockPos

Returns the second bed block position that might not exist (normally beds are two blocks long tho).

Link copied to clipboard
fun BlockPos.getSortedSphere(radius: Float): Array<BlockPos>
Link copied to clipboard
@JvmName(name = "getState-deprecated")
inline fun BlockPos.getState(): BlockState?
Link copied to clipboard
fun BlockPos.isBlastResistant(): Boolean
Link copied to clipboard
inline fun AABB.isBlockAtPosition(isCorrectBlock: (Block?) -> Boolean): Boolean

Check if box is reaching of specified blocks

Link copied to clipboard
Link copied to clipboard
fun BlockPos.isBlockedByEntitiesReturnCrystal(box: AABB = FULL_BOX, excludeIds: IntArray? = null): BooleanObjectPair<EndCrystal?>

Like isBlockedByEntities but it returns a blocking end crystal if present.

Link copied to clipboard
fun BlockState.isBreakable(pos: BlockPos): Boolean
Link copied to clipboard
fun RespawnAnchorBlock.isCharged(state: BlockState): Boolean
Link copied to clipboard
fun BlockPos?.isFallDamageBlocking(): Boolean
Link copied to clipboard
fun Block?.isInteractable(blockState: BlockState?): Boolean

Checks if the block can be interacted with, null will be returned as not interactable. The blockState is optional but can make the result more accurate, if not provided it will just assume the block is interactable.

Link copied to clipboard
fun BlockState.isNotBreakable(pos: BlockPos): Boolean
Link copied to clipboard
fun BlockState.outlineBox(blockPos: BlockPos): AABB
Link copied to clipboard
fun BlockGetter.raycast(context: ClipContext, exclude: Array<BlockPos>?, include: BlockPos?, maxBlastResistance: Float?): BlockHitResult

Basically BlockGetter.raycast but this method allows us to exclude blocks using exclude.

Link copied to clipboard
fun BlockPos.searchBedLayer(state: BlockState, layers: Int): Sequence<IntLongPair>

Scan blocks outwards from a bed

Link copied to clipboard
fun Vec3.searchBlocksInCuboid(radius: Float): Iterable<BlockPos>

inline fun Vec3.searchBlocksInCuboid(radius: Float, crossinline filter: (BlockPos, BlockState) -> Boolean): Sequence<Pair<BlockPos, BlockState>>

Scan blocks around the position in a cuboid with filtering.

Link copied to clipboard
inline fun Vec3.searchBlocksInRangeSorted(range: Float, shapeGetter: ClipContext.ShapeGetter = ClipContext.Block.OUTLINE, collisionContext: CollisionContext = CollisionContext.of(player), crossinline filter: (BlockPos, BlockState) -> Boolean): List<Pair<BlockPos, BlockState>>

Scan blocks around the position in a cuboid, filtered and sorted by shape distance from this Vec3. Distance calculation is based on outline shape: shapeGetter.get(state, level, pos, collisionContext).move(pos).distanceToSqr(eyesPos).

Link copied to clipboard
fun BlockPos.searchLayer(layers: Int, vararg directions: Direction): Sequence<IntLongPair>

Scan blocks outwards from center along given directions, up to layers

Link copied to clipboard
fun Vec3i.toBlockPos(): BlockPos