From 10f8cfdeaa961f52f3229e07c5fc9aa0fb15e734 Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 9 Mar 2026 17:26:55 -0400 Subject: [PATCH] Add Absorbing Radius to Barriers --- .../npcs/api/entity/IEnergyBarrier.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/java/noppes/npcs/api/entity/IEnergyBarrier.java b/java/noppes/npcs/api/entity/IEnergyBarrier.java index 724364d..243ca1c 100644 --- a/java/noppes/npcs/api/entity/IEnergyBarrier.java +++ b/java/noppes/npcs/api/entity/IEnergyBarrier.java @@ -57,10 +57,72 @@ public interface IEnergyBarrier extends IEnergyAbility { void setKnockbackStrength(float strength); + /** + * Returns whether this barrier absorbs damage on behalf of its owner. + * When absorbing is enabled, incoming damage to the barrier's owner is redirected + * to the barrier instead, subject to the absorb radius check. + * + * @return {@code true} if the barrier absorbs the owner's incoming damage + * @see #getAbsorbRadius() + */ boolean isAbsorbing(); + /** + * Sets whether this barrier absorbs damage on behalf of its owner. + * When absorbing is enabled, incoming damage to the barrier's owner is redirected + * to the barrier instead, subject to the absorb radius check. + * + * @param absorbing {@code true} to enable damage absorption for the owner + * @see #setAbsorbRadius(float) + */ void setAbsorbing(boolean absorbing); + /** + * Gets the absorb radius for this barrier. + * The absorb radius determines the maximum distance from the barrier's current + * position at which the owner's incoming damage will still be redirected to the barrier. + * This check uses the barrier entity's live position, so it works correctly with + * moving barriers (following domes, moving walls, shields, etc.). + * + *
    + *
  • {@code -1} = No distance limit. Damage is always absorbed regardless of distance.
  • + *
  • {@code 0} = Uses the barrier's own geometric extent as the effective radius. + *
      + *
    • Domes: the dome radius (sphere radius in blocks).
    • + *
    • Panels: {@code (max(width, height) * 0.5 + 1.0) * 3} + * (i.e. {@code max(width, height) * 1.5 + 3.0} blocks).
    • + *
    + *
  • + *
  • Positive values = The owner must be within this many blocks of the barrier entity.
  • + *
+ * + * @return the absorb radius in blocks, or {@code -1} for unlimited, or {@code 0} for barrier extent + */ + float getAbsorbRadius(); + + /** + * Sets the absorb radius for this barrier. + * The absorb radius determines the maximum distance from the barrier's current + * position at which the owner's incoming damage will still be redirected to the barrier. + * This check uses the barrier entity's live position, so it works correctly with + * moving barriers (following domes, moving walls, shields, etc.). + * + *
    + *
  • {@code -1} = No distance limit. Damage is always absorbed regardless of distance.
  • + *
  • {@code 0} = Uses the barrier's own geometric extent as the effective radius. + *
      + *
    • Domes: the dome radius (sphere radius in blocks).
    • + *
    • Panels: {@code (max(width, height) * 0.5 + 1.0) * 3} + * (i.e. {@code max(width, height) * 1.5 + 3.0} blocks).
    • + *
    + *
  • + *
  • Positive values = The owner must be within this many blocks of the barrier entity.
  • + *
+ * + * @param radius the absorb radius in blocks, or {@code -1} for unlimited, or {@code 0} for barrier extent + */ + void setAbsorbRadius(float radius); + /** * Returns the barrier type: 0=Dome, 1=Panel * @return the barrier type ordinal