Class ClientCooldownManager

java.lang.Object
dev.bouncingelf10.timelesslib.api.cooldown.ClientCooldownManager

public final class ClientCooldownManager extends Object
Tracks cooldowns for the local client, keyed by a namespaced key.
Obtain the shared instance through TimelessLibClient.cooldowns() - this class cannot be constructed by other mods.
See Also:
  • AbstractCooldownManager
  • Constructor Details

  • Method Details

    • normalizeOwner

      protected UUID normalizeOwner(UUID owner)
    • newCooldown

      protected Cooldown newCooldown(Duration duration, Duration tickInterval, TimeSource timeSource, Runnable onFinishCleanup)
      Constructs the underlying countdown-backed cooldown. Implementations must invoke onFinishCleanup exactly once, whether the cooldown expires naturally or Cooldown.reset() is called early - this is what keeps the owner/key bookkeeping in sync (see reset(UUID, Identifier)).
    • start

      public Cooldown start(net.minecraft.resources.Identifier key, Duration duration)
    • startRealtime

      public Cooldown startRealtime(net.minecraft.resources.Identifier key, Duration duration)
    • startIfAbsent

      public Cooldown startIfAbsent(net.minecraft.resources.Identifier key, Duration duration, TimeSource timeSource)
    • isReady

      public boolean isReady(net.minecraft.resources.Identifier key)
    • remaining

      public Duration remaining(net.minecraft.resources.Identifier key)
    • reset

      public void reset(net.minecraft.resources.Identifier key)
    • resetAll

      public void resetAll()
    • getLocalClient

      public UUID getLocalClient()
    • start

      public Cooldown start(UUID owner, net.minecraft.resources.Identifier key, Duration duration)
      Starts a cooldown for the given owner.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      Returns:
      Cooldown
      See Also:
    • startRealtime

      public Cooldown startRealtime(UUID owner, net.minecraft.resources.Identifier key, Duration duration)
      Starts a realtime cooldown for the given owner.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      Returns:
      Cooldown
      See Also:
    • startIfAbsent

      public Cooldown startIfAbsent(UUID owner, net.minecraft.resources.Identifier key, Duration duration, TimeSource timeSource)
      Starts a cooldown for the given owner if it does not exist yet. If it does exist, it is returned instead.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      timeSource - Time source to use for the cooldown.
      Returns:
      Cooldown
      See Also:
    • isReady

      public boolean isReady(UUID owner, net.minecraft.resources.Identifier key)
      Checks if a cooldown is ready for the given owner and key.
      Note: "Ready" means that the cooldown has finished (or was never started).
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      Returns:
      true if the cooldown is ready, false otherwise.
    • remaining

      public Duration remaining(UUID owner, net.minecraft.resources.Identifier key)
    • reset

      public void reset(UUID owner, net.minecraft.resources.Identifier key)
      Cancels the cooldown for the given owner and key, making it immediately ready.
      This is the one true cancellation path - it always keeps the owner/key bookkeeping in sync, whether called directly or via Cooldown.reset().
    • resetAll

      public void resetAll(UUID owner)
      You should probably use reset(UUID, Identifier) instead. Especially if you're NOT using a custom key scheme.