Record Class RaidShieldState
java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.battles.raids.RaidShieldState
- Record Components:
active- Whether the boss currently has an active shield.activated- Whether the shield has already been activated during the raid.shieldsRaised- The visible shield segments or discrete shield charges currently shown. Dynamax shields use this as their mechanical charge count.health- The underlying barrier durability currently remaining. For Dynamax this is normally the same value asshieldsRaised; Tera shields can use this as a continuous durability value while deriving visible segments from it.maxHealth- The maximum barrier durability for this phase. This is used by shields with continuous durability to calculate their visible segment count.shieldStrength- The generated strength used when raising a new shield phase.remainingUses- The number of shield phases still available after the current phase.lastHitter- The last Pokemon to damage the shield this turn, used to avoid multi-hit moves removing multiple shield charges.
public record RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth, int shieldStrength, int remainingUses, Optional<UUID> lastHitter)
extends Record
Immutable runtime state for a raid boss shield.
The shield state is stored on battle context so raid strategies can share shield progress without depending on a specific raid implementation. A shield may be inactive, active, or previously activated and broken/cleared.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<RaidShieldState> static final RaidShieldState -
Constructor Summary
ConstructorsConstructorDescriptionRaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth) RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth, int shieldStrength, int remainingUses, Optional<UUID> lastHitter) Creates an instance of aRaidShieldStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theactivatedrecord component.booleanactive()Returns the value of theactiverecord component.broken()Creates a copy of this shield state marked as broken for the current phase.floatGets the current underlying barrier durability.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanChecks whether any Pokemon has damaged this shield during the current turn.floathealth()Returns the value of thehealthrecord component.static RaidShieldStateinactive(int shieldStrength, int remainingUses) Creates an inactive state for a raid that can still raise shields later.Returns the value of thelastHitterrecord component.floatGets the maximum underlying barrier durability.floatReturns the value of themaxHealthrecord component.static RaidShieldStateraised(int shieldsRaised, float health, float maxHealth) Creates an active continuous-durability shield phase.static RaidShieldStateraised(int shieldStrength, int remainingUses) Creates an active discrete shield phase.intReturns the value of theremainingUsesrecord component.intReturns the value of theshieldsRaisedrecord component.intReturns the value of theshieldStrengthrecord component.final StringtoString()Returns a string representation of this record class.intGets the visible shield segment count.booleanwasLastHitBy(UUID pokemon) Checks whether a Pokemon has already damaged this shield during the current turn.withActivated(boolean activated) Creates a copy of this shield state with a different activation flag.withActive(boolean active) Creates a copy of this shield state with a different active flag.withDiscreteShields(int shieldsRaised) Creates a copy of this shield state with discrete shield charges.withDurability(float health, int shieldsRaised) Creates a copy of this shield state with continuous durability and visible segments.withHealth(float health, int shieldsRaised) Creates a copy of this shield state with continuous durability and visible segments.withLastHitter(UUID lastHitter) Creates a copy of this shield state with a different last hitter value.Creates a copy of this shield state with an empty last hitter value.withRemainingUses(int remainingUses) Creates a copy of this shield state with a different remaining-use count.withShieldStrength(int shieldStrength) Creates a copy of this shield state with a different shield strength.
-
Field Details
-
CODEC
-
EMPTY
-
-
Constructor Details
-
RaidShieldState
public RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth) -
RaidShieldState
public RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth, int shieldStrength, int remainingUses, Optional<UUID> lastHitter) Creates an instance of aRaidShieldStaterecord class.- Parameters:
active- the value for theactiverecord componentactivated- the value for theactivatedrecord componentshieldsRaised- the value for theshieldsRaisedrecord componenthealth- the value for thehealthrecord componentmaxHealth- the value for themaxHealthrecord componentshieldStrength- the value for theshieldStrengthrecord componentremainingUses- the value for theremainingUsesrecord componentlastHitter- the value for thelastHitterrecord component
-
-
Method Details
-
inactive
Creates an inactive state for a raid that can still raise shields later.- Parameters:
shieldStrength- The generated strength for future shield phases.remainingUses- The number of shield phases still available.- Returns:
- An inactive shield state with the supplied future shield values.
-
raised
Creates an active discrete shield phase.This is the usual shape for Dynamax shields, where the visible shield count and mechanical durability are the same value.
- Parameters:
shieldStrength- The number of shield charges to raise.remainingUses- The number of shield phases available after this phase is raised.- Returns:
- An active shield state.
-
raised
Creates an active continuous-durability shield phase.This is the usual shape for Tera shields, where visible shield segments and mechanical durability are intentionally separate values.
- Parameters:
shieldsRaised- The visible shield segment count.health- The current barrier durability.maxHealth- The maximum barrier durability.- Returns:
- An active shield state.
-
visibleSegments
public int visibleSegments()Gets the visible shield segment count.- Returns:
- The shield value that should be shown to clients.
-
durability
public float durability()Gets the current underlying barrier durability.- Returns:
- The mechanical durability remaining for this shield phase.
-
maxDurability
public float maxDurability()Gets the maximum underlying barrier durability.- Returns:
- The maximum durability for this shield phase.
-
wasLastHitBy
Checks whether a Pokemon has already damaged this shield during the current turn.- Parameters:
pokemon- The Pokemon UUID to check.- Returns:
- Whether this Pokemon is the last shield hitter.
-
hasLastHitter
public boolean hasLastHitter()Checks whether any Pokemon has damaged this shield during the current turn.- Returns:
- Whether a last shield hitter is stored.
-
withActivated
Creates a copy of this shield state with a different activation flag.- Parameters:
activated- Whether the shield phase should be marked as activated.- Returns:
- A copy of this state with the supplied activation value.
-
withActive
Creates a copy of this shield state with a different active flag.- Parameters:
active- Whether the shield is currently active.- Returns:
- A copy of this state with the supplied active value.
-
withRemainingUses
Creates a copy of this shield state with a different remaining-use count.- Parameters:
remainingUses- The number of shield phases still available.- Returns:
- A copy of this state with the supplied remaining-use count.
-
withShieldStrength
Creates a copy of this shield state with a different shield strength.- Parameters:
shieldStrength- The generated strength used by future shield phases.- Returns:
- A copy of this state with the supplied shield strength.
-
withDiscreteShields
Creates a copy of this shield state with discrete shield charges.This updates both the visible shield segments and durability to the same value.
- Parameters:
shieldsRaised- The visible shield segment and durability value.- Returns:
- A copy of this state with the supplied discrete shield value.
-
withDurability
Creates a copy of this shield state with continuous durability and visible segments.- Parameters:
health- The remaining barrier durability.shieldsRaised- The visible shield segment count.- Returns:
- A copy of this state with the supplied durability and visible segment count.
-
withHealth
Creates a copy of this shield state with continuous durability and visible segments.- Parameters:
health- The remaining barrier durability.shieldsRaised- The visible shield segment count.- Returns:
- A copy of this state with the supplied durability and visible segment count.
-
broken
Creates a copy of this shield state marked as broken for the current phase.- Returns:
- A copy of this state with no active shield or visible segments.
-
withLastHitter
Creates a copy of this shield state with a different last hitter value.- Parameters:
lastHitter- The UUID of the last Pokemon to hit the shield, or empty if no Pokemon has hit the shield this turn.- Returns:
- A copy of this state with the supplied last hitter value.
-
withNoLastHitter
Creates a copy of this shield state with an empty last hitter value.- Returns:
- A copy of this state with an empty last hitter value.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
active
public boolean active()Returns the value of theactiverecord component.- Returns:
- the value of the
activerecord component
-
activated
public boolean activated()Returns the value of theactivatedrecord component.- Returns:
- the value of the
activatedrecord component
-
shieldsRaised
public int shieldsRaised()Returns the value of theshieldsRaisedrecord component.- Returns:
- the value of the
shieldsRaisedrecord component
-
health
public float health()Returns the value of thehealthrecord component.- Returns:
- the value of the
healthrecord component
-
maxHealth
public float maxHealth()Returns the value of themaxHealthrecord component.- Returns:
- the value of the
maxHealthrecord component
-
shieldStrength
public int shieldStrength()Returns the value of theshieldStrengthrecord component.- Returns:
- the value of the
shieldStrengthrecord component
-
remainingUses
public int remainingUses()Returns the value of theremainingUsesrecord component.- Returns:
- the value of the
remainingUsesrecord component
-
lastHitter
Returns the value of thelastHitterrecord component.- Returns:
- the value of the
lastHitterrecord component
-