Class BreakHelper
java.lang.Object
dev.boze.api.utility.interaction.BreakHelper
BreakHelper provides utilities for breaking blocks with packets and rotations.
This is the breaking counterpart to
This is the breaking counterpart to
PlaceHelper. It is intended for anarchy servers:
blocks are broken via packets, and rotations are handled through the Interaction system
so the break is anticheat-compliant when run from an interaction.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbreakBlock(net.minecraft.core.BlockPos pos) Breaks the block at the given position, using the player's block interaction range and requiring line of sight.static booleanbreakBlock(net.minecraft.core.BlockPos pos, double range, boolean throughWalls) Breaks the block at the given position.static booleancanBreak(net.minecraft.core.BlockPos pos) Checks whether a block can be broken (reachable hardness, not air, etc.).static net.minecraft.world.phys.BlockHitResultcast(net.minecraft.core.BlockPos pos) Finds the visible face to break, using the player's block interaction range and requiring line of sight.static net.minecraft.world.phys.BlockHitResultcast(net.minecraft.core.BlockPos pos, double range, boolean throughWalls) Finds the visible face to break.static Interactioninteraction(net.minecraft.core.BlockPos pos, boolean rotate) Builds a ready-to-run breakInteractionthat rotates to the block's visible face and then breaks it.static Interactioninteraction(net.minecraft.core.BlockPos pos, boolean rotate, double range, boolean throughWalls) Builds a ready-to-run breakInteractionthat rotates to the block's visible face and then breaks it.
-
Constructor Details
-
BreakHelper
public BreakHelper()
-
-
Method Details
-
canBreak
public static boolean canBreak(net.minecraft.core.BlockPos pos) Checks whether a block can be broken (reachable hardness, not air, etc.).- Parameters:
pos- The block position- Returns:
- true if the block can be broken
-
cast
public static net.minecraft.world.phys.BlockHitResult cast(net.minecraft.core.BlockPos pos) Finds the visible face to break, using the player's block interaction range and requiring line of sight.- Parameters:
pos- The block position to break- Returns:
- The block hit result on the visible face, or null if the block can't be reached
-
cast
public static net.minecraft.world.phys.BlockHitResult cast(net.minecraft.core.BlockPos pos, double range, boolean throughWalls) Finds the visible face to break.- Parameters:
pos- The block position to breakrange- The maximum reach rangethroughWalls- Whether to allow breaking without line of sight- Returns:
- The block hit result on the chosen face, or null if the block can't be reached
-
breakBlock
public static boolean breakBlock(net.minecraft.core.BlockPos pos) Breaks the block at the given position, using the player's block interaction range and requiring line of sight. Swaps to the best tool automatically.- Parameters:
pos- The block position to break- Returns:
- true if a break was started
-
breakBlock
public static boolean breakBlock(net.minecraft.core.BlockPos pos, double range, boolean throughWalls) Breaks the block at the given position. Swaps to the best tool automatically.- Parameters:
pos- The block position to breakrange- The maximum reach rangethroughWalls- Whether to allow breaking without line of sight- Returns:
- true if a break was started
-
interaction
Builds a ready-to-run breakInteractionthat rotates to the block's visible face and then breaks it. Add the result to anEventInteractso rotations are applied for the active anticheat mode.- Parameters:
pos- The block position to breakrotate- Whether to rotate to the block before breaking- Returns:
- An interaction, or null if the block can't be reached
-
interaction
public static Interaction interaction(net.minecraft.core.BlockPos pos, boolean rotate, double range, boolean throughWalls) Builds a ready-to-run breakInteractionthat rotates to the block's visible face and then breaks it. Add the result to anEventInteractso rotations are applied for the active anticheat mode.- Parameters:
pos- The block position to breakrotate- Whether to rotate to the block before breakingrange- The maximum reach rangethroughWalls- Whether to allow breaking without line of sight- Returns:
- An interaction, or null if the block can't be reached
-