Class MiningManager

java.lang.Object
me.hackware.api.mining.MiningManager

public final class MiningManager extends Object
The plugin-facing mining API: a stable facade over SilentMine's two-slot pipeline (see MinePhase for the slot model).

Requests. breakAt(MineRequest) asks for a break right now and reports whether the pipeline took it; queue(MineRequest) guarantees eventual mining by parking the block in this manager's own queue, which feeds the pipeline as slots free up. This queue is independent of SilentMine's user-facing Queue setting group: it works with that toggle off, and it deliberately ignores the user's block whitelist/blacklist — if a plugin says mine this block, we mine it. The SilentMine module itself must still be enabled for any packets to go out; while it is off (or mining is paused) the queue simply holds.

Ownership. Tag requests with MineRequest.owner(String) (normally the plugin id): cancelAllFrom(String) then drops every claim in one call — active slots, pending selects, and queued blocks — which plugins should do on unload.

Events. The pipeline posts MineStartEvent, MineBreakEvent and RebreakArmedEvent on the EventBus as blocks move through it.

All methods must be called from the client main thread, except the pause family, which is safe from any thread.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    abortRebreakAt(net.minecraft.core.BlockPos pos)
    Drops the rebreak slot if it is claimed at pos.
    boolean
    Requests an immediate break.
    boolean
    breakAt(net.minecraft.core.BlockPos pos)
    breakAt(MineRequest) with defaults: auto face, NORMAL priority, no owner.
    boolean
    canBreakAt(net.minecraft.core.BlockPos pos)
    True when a break request for pos could be attempted right now: module enabled, not paused, block breakable and in range.
    boolean
    cancel(net.minecraft.core.BlockPos pos)
    Cancels whatever the pipeline holds at pos — active slot, pending select, or queued block (both this manager's queue and SilentMine's own).
    void
    Cancels everything: both slots, pending selects, and all queues.
    void
    Cancels every claim tagged with owner — active slots, pending selects, queued blocks — and releases the owner's pause token.
    void
    Drops the armed rebreak / double-mine block unconditionally.
    boolean
    canInstaBreak(net.minecraft.core.BlockPos pos)
    True when pos breaks in a single action with the best hotbar tool right now.
    void
    Empties this manager's queue.
    void
    Removes every queued block tagged with owner.
    The block in the active/secondary slot, pre-break.
    double
    The double-mine threshold setting (0.0–1.0) — the progress at which the active block is finished.
    get()
     
    Ordered snapshot of this manager's queue (feed order: priority desc, then FIFO).
    void
    Register event handlers.
    int
    instaMineBatch(List<net.minecraft.core.BlockPos> positions, int limit)
    Bulk fast path: breaks up to limit insta-breakable blocks with self-contained packet bursts, without occupying the mining slots.
    boolean
    True when the SilentMine module is enabled and the player is in a world.
    boolean
    True if the pipeline is mining or tracking any block.
    boolean
    isMining(net.minecraft.core.BlockPos pos)
    True if the pipeline is mining or tracking the given position.
    boolean
    True while any pause token is held.
    boolean
    isQueued(net.minecraft.core.BlockPos pos)
    True if pos waits in this manager's queue.
    boolean
    isRebreak(net.minecraft.core.BlockPos pos)
    True if pos is the armed rebreak target.
    boolean
    True when mining needs ownership of the held slot for a tool swap.
    void
    pause(String token)
    Pauses all mining under the given token: no dig packets go out, no new blocks are claimed, and break requests are refused until every token is released.
    The block in the primary slot.
    double
    progressAt(net.minecraft.core.BlockPos pos)
    Break progress (0.0–1.0) of whichever slot tracks pos, or -1 when no slot holds it.
    boolean
    queue(MineRequest request)
    Adds the block to this manager's queue; it feeds into the pipeline as slots free up, highest priority first, FIFO among equals.
    boolean
    queue(net.minecraft.core.BlockPos pos)
    queue(MineRequest) with defaults: auto face, NORMAL priority, no owner.
    void
    queueAll(Collection<net.minecraft.core.BlockPos> positions, BreakPriority priority, String owner)
    Adds every position to the queue with the given request template applied per block.
    int
    The number of blocks waiting in this manager's queue.
    double
    The configured mining range in blocks.
    void
    unpause(String token)
    Releases the given pause token.
    boolean
    unqueue(net.minecraft.core.BlockPos pos)
    Removes pos from this manager's queue (does not touch active slots — see cancel(net.minecraft.core.BlockPos)).
    boolean
    wouldInstaBreakOnGround(net.minecraft.core.BlockPos pos)
    True when pos would insta-break once grounded, regardless of the current airborne state.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static MiningManager get()
    • init

      public void init()
      Register event handlers. Call once during mod init.
    • pause

      public void pause(String token)
      Pauses all mining under the given token: no dig packets go out, no new blocks are claimed, and break requests are refused until every token is released. Tokens from different callers stack, so two plugins pausing don't fight over one flag. Queue contents survive a pause. Server-side break timers keep aging regardless — blocks mid-mine resume at least as far along as they left off.
      Parameters:
      token - pause identity, normally the plugin id; releasing requires the same token
    • unpause

      public void unpause(String token)
      Releases the given pause token. Mining resumes once no tokens remain.
    • isPaused

      public boolean isPaused()
      True while any pause token is held.
    • breakAt

      public boolean breakAt(net.minecraft.core.BlockPos pos)
      breakAt(MineRequest) with defaults: auto face, NORMAL priority, no owner.
    • breakAt

      public boolean breakAt(MineRequest request)
      Requests an immediate break. The pipeline may refuse — both slots busy, out of range, paused, module disabled — in which case nothing is scheduled and false is returned; use queue(MineRequest) when the block must eventually be mined.
      Returns:
      true when the pipeline took the request (block is now mining, pending selection, or was insta-broken)
    • canBreakAt

      public boolean canBreakAt(net.minecraft.core.BlockPos pos)
      True when a break request for pos could be attempted right now: module enabled, not paused, block breakable and in range.
    • canInstaBreak

      public boolean canInstaBreak(net.minecraft.core.BlockPos pos)
      True when pos breaks in a single action with the best hotbar tool right now.
    • wouldInstaBreakOnGround

      public boolean wouldInstaBreakOnGround(net.minecraft.core.BlockPos pos)
      True when pos would insta-break once grounded, regardless of the current airborne state.
    • instaMineBatch

      public int instaMineBatch(List<net.minecraft.core.BlockPos> positions, int limit)
      Bulk fast path: breaks up to limit insta-breakable blocks with self-contained packet bursts, without occupying the mining slots. Returns the number of blocks broken this call — callers re-feed remaining positions each tick.
    • isAvailable

      public boolean isAvailable()
      True when the SilentMine module is enabled and the player is in a world.
    • isMining

      public boolean isMining()
      True if the pipeline is mining or tracking any block.
    • isMining

      public boolean isMining(net.minecraft.core.BlockPos pos)
      True if the pipeline is mining or tracking the given position.
    • primary

      public Optional<MineTargetView> primary()
      The block in the primary slot.
    • doubleMine

      public Optional<MineTargetView> doubleMine()
      The block in the active/secondary slot, pre-break.
    • rebreak

      public Optional<MineTargetView> rebreak()
    • isRebreak

      public boolean isRebreak(net.minecraft.core.BlockPos pos)
      True if pos is the armed rebreak target. Placers must not place here without abortRebreakAt(net.minecraft.core.BlockPos).
    • progressAt

      public double progressAt(net.minecraft.core.BlockPos pos)
      Break progress (0.0–1.0) of whichever slot tracks pos, or -1 when no slot holds it. An armed rebreak reports 1.0.
    • range

      public double range()
      The configured mining range in blocks.
    • doubleMineThreshold

      public double doubleMineThreshold()
      The double-mine threshold setting (0.0–1.0) — the progress at which the active block is finished.
    • needsToolSwap

      public boolean needsToolSwap()
      True when mining needs ownership of the held slot for a tool swap. The SERVER holds the tool during that window, so raw-packet attackers must hold their swing or the hit lands with the tool.
    • cancel

      public boolean cancel(net.minecraft.core.BlockPos pos)
      Cancels whatever the pipeline holds at pos — active slot, pending select, or queued block (both this manager's queue and SilentMine's own).
      Returns:
      true when anything was cancelled
    • cancelRebreak

      public void cancelRebreak()
      Drops the armed rebreak / double-mine block unconditionally.
    • abortRebreakAt

      public boolean abortRebreakAt(net.minecraft.core.BlockPos pos)
      Drops the rebreak slot if it is claimed at pos. Call before placing a block there, or the placement is instantly rebroken out from under you.
      Returns:
      true if a rebreak claim was dropped
    • cancelAll

      public void cancelAll()
      Cancels everything: both slots, pending selects, and all queues.
    • cancelAllFrom

      public void cancelAllFrom(String owner)
      Cancels every claim tagged with owner — active slots, pending selects, queued blocks — and releases the owner's pause token. Plugins should call this on unload.
    • queue

      public boolean queue(net.minecraft.core.BlockPos pos)
      queue(MineRequest) with defaults: auto face, NORMAL priority, no owner.
    • queue

      public boolean queue(MineRequest request)
      Adds the block to this manager's queue; it feeds into the pipeline as slots free up, highest priority first, FIFO among equals. Unlike breakAt(net.minecraft.core.BlockPos), queued blocks survive busy slots, pauses, and the module being toggled — they hold until minable. Out-of-range blocks stay queued until the player walks into range; only broken or unbreakable blocks are pruned. Re-queueing a queued position refreshes its priority (upward only) and keeps its place in line.
      Returns:
      true when the block is now queued (or already actively mining)
    • queueAll

      public void queueAll(Collection<net.minecraft.core.BlockPos> positions, BreakPriority priority, String owner)
      Adds every position to the queue with the given request template applied per block.
    • unqueue

      public boolean unqueue(net.minecraft.core.BlockPos pos)
      Removes pos from this manager's queue (does not touch active slots — see cancel(net.minecraft.core.BlockPos)).
    • isQueued

      public boolean isQueued(net.minecraft.core.BlockPos pos)
      True if pos waits in this manager's queue.
    • queueSize

      public int queueSize()
      The number of blocks waiting in this manager's queue.
    • clearQueue

      public void clearQueue()
      Empties this manager's queue. Active slots are untouched.
    • clearQueue

      public void clearQueue(String owner)
      Removes every queued block tagged with owner.
    • getQueue

      public List<MineTargetView> getQueue()
      Ordered snapshot of this manager's queue (feed order: priority desc, then FIFO).