Class ShieldSpellEffect
ShieldSpellEffect provides a protective barrier that blocks spell projectiles from hitting the protected player. The shield operates within a specified radius around the player and prevents spells based on a spell level comparison: the shield can only block spells up to one level higher than the shield spell itself. For example, a shield at level OWL can block spells up to level NEWT (one level higher), but cannot block level EXPERT spells.
Protection Mechanics:
- Radius: The shield protects in a sphere of radius around the player
- Spell Level Check: Incoming spell level must be ≤ (shield level + 1) to be blocked
- Entity Targeting: Prevents enemies from targeting the protected player via entity targeting events
- Self Exemption: Does not block spells cast by the protected player themselves
Visual Effects:
Subclasses can configure two types of visual particle effects:- Pulse Flair: A periodic visual effect displayed every 10 ticks (flairPulse, pulseFlairParticle)
- Impact Flair: A visual effect displayed when a spell hits the shield boundary (flairOnSpellImpact, impactFlairParticle)
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionShieldSpellEffect(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a spell shield effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck the effect each game tick and apply visual effects.voiddoRemove()Perform cleanup when this shield effect is removed.intGet the radius for this shield spell effect.Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill, setPermanent
-
Constructor Details
-
ShieldSpellEffect
public ShieldSpellEffect(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a spell shield effect.Creates a protective shield around the target player. This constructor attempts to look up the player entity and kills the effect if the player is not found online. Subclasses should set shield configuration fields (radius, flairPulse, flairOnSpellImpact, particles) during initialization.
- Parameters:
plugin- a callback to the MC pluginduration- the duration of the shield in game ticksisPermanent- is this effect permanent (does not age)pid- the unique ID of the player to protect
-
-
Method Details
-
checkEffect
public void checkEffect()Check the effect each game tick and apply visual effects.This method executes once per tick and performs the following:
- Ages the effect by 1 tick (for non-permanent effects)
- Returns early if the effect has been killed
- If flairPulse is enabled and the duration is divisible by 10 (every 10 ticks / 0.5 seconds), displays the pulse flair particle effect
- Specified by:
checkEffectin classO2Effect
-
doRemove
public void doRemove()Perform cleanup when this shield effect is removed.This method is called when the shield expires or is explicitly removed. The default implementation does nothing, as shields do not require special cleanup (particles and targeting restrictions are automatically handled). Subclasses can override to perform additional cleanup if needed.
-
getRadius
public int getRadius()Get the radius for this shield spell effect.- Returns:
- the radius for this shield spell effect.
-