Class BreakHelper

java.lang.Object
dev.boze.api.utility.interaction.BreakHelper

public class BreakHelper extends Object
BreakHelper provides utilities for breaking blocks with packets and rotations.
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static boolean
    breakBlock(net.minecraft.core.BlockPos pos, double range, boolean throughWalls)
    Breaks the block at the given position.
    static boolean
    canBreak(net.minecraft.core.BlockPos pos)
    Checks whether a block can be broken (reachable hardness, not air, etc.).
    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.
    static net.minecraft.world.phys.BlockHitResult
    cast(net.minecraft.core.BlockPos pos, double range, boolean throughWalls)
    Finds the visible face to break.
    interaction(net.minecraft.core.BlockPos pos, boolean rotate)
    Builds a ready-to-run break Interaction that rotates to the block's visible face and then breaks it.
    interaction(net.minecraft.core.BlockPos pos, boolean rotate, double range, boolean throughWalls)
    Builds a ready-to-run break Interaction that rotates to the block's visible face and then breaks it.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 break
      range - The maximum reach range
      throughWalls - 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 break
      range - The maximum reach range
      throughWalls - Whether to allow breaking without line of sight
      Returns:
      true if a break was started
    • interaction

      public static Interaction interaction(net.minecraft.core.BlockPos pos, boolean rotate)
      Builds a ready-to-run break Interaction that rotates to the block's visible face and then breaks it. Add the result to an EventInteract so rotations are applied for the active anticheat mode.
      Parameters:
      pos - The block position to break
      rotate - 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 break Interaction that rotates to the block's visible face and then breaks it. Add the result to an EventInteract so rotations are applied for the active anticheat mode.
      Parameters:
      pos - The block position to break
      rotate - Whether to rotate to the block before breaking
      range - The maximum reach range
      throughWalls - Whether to allow breaking without line of sight
      Returns:
      An interaction, or null if the block can't be reached