Class ElementComponentImpl
java.lang.Object
io.github.xrickastley.sevenelements.component.ElementComponentImpl
- All Implemented Interfaces:
ElementComponent,org.ladysnake.cca.api.v3.component.Component,org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent,org.ladysnake.cca.api.v3.component.sync.ComponentPacketWriter,org.ladysnake.cca.api.v3.component.sync.PlayerSyncPredicate,org.ladysnake.cca.api.v3.component.tick.ClientTickingComponent,org.ladysnake.cca.api.v3.component.tick.CommonTickingComponent,org.ladysnake.cca.api.v3.component.tick.ServerTickingComponent
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate @Nullable LivingEntityprivate int(package private) static final Map<TagKey<DamageType>, Element> (package private) static final Set<Class<LivingEntity>> private longprivate @Nullable LivingEntityprivate final Map<Element, ElementHolder> (package private) static final Map<TagKey<EntityType<?>>, Element> private final ElementComponentImpl.FreezeDecayHandlerprivate Pair<ElementalReaction, Long> private final LivingEntityFields inherited from interface io.github.xrickastley.sevenelements.component.ElementComponent
KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddElementalApplication(ElementalApplication application, InternalCooldownContext icdContext) Applies anElementalDamageSourceto this entity, possibly triggering multipleElementalReactions.private booleanattemptReapply(ElementalApplication application) Attempts to reapply anElemental Application.booleancanApplyElement(Element element, InternalCooldownContext icdContext, boolean handleICD) Checks if the element can be applied.static <T extends LivingEntity>
booleancanApplyElement(Class<T> entityClass) Gets all currently applied elements as aArray.@Nullable LivingEntityGets the current Crystallize Shield of this entity.@Nullable LivingEntitygetElementHolder(Element element) doubleGets the current decay time modifier for the Freeze aura.Gets the lowestpriorityvalue from the currently applied Elements as anOptional.getOwner()Gets all currently prioritized applied elements as anArray.private Stream<ElementalReaction> getTriggerableReactions(int priority, ElementalApplication triggeringElement) booleanbooleanvoidfloatreduceCrystallizeShield(DamageSource source, float amount) Reduces the Crystallize shield and returns the effective amount of DMG reduced.booleanReturns whether the Crystallize Shield has been reduced in the current tick.private voidvoidvoidvoidsetBurningOrigin(@Nullable LivingEntity origin) voidsetCrystallizeShield(Element element, double amount) Grants this entity a Crystallize shield.voidsetElectroChargedOrigin(@Nullable LivingEntity origin) voidsetLastReaction(Pair<ElementalReaction, Long> lastReaction) voidtick()private Set<ElementalReaction> triggerReactions(ElementalApplication application, @Nullable LivingEntity origin) Triggers all possible Elemental Reactions.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent
applySyncPacket, shouldSyncWith, writeSyncPacketMethods inherited from interface org.ladysnake.cca.api.v3.component.tick.CommonTickingComponent
clientTick, serverTickMethods inherited from interface io.github.xrickastley.sevenelements.component.ElementComponent
addElementalApplication, addElementalApplication, canApplyElement, getElementalApplication, hasElementalApplication, hasLastReaction, hasValidLastReaction, reduceElementalApplication, setOrRetainBurningOrigin, setOrRetainElectroChargedOriginMethods inherited from interface org.ladysnake.cca.api.v3.component.sync.PlayerSyncPredicate
isRequiredOnClient
-
Field Details
-
DENIED_ENTITIES
-
ENTITY_TYPE_ELEMENT_MAP
-
DAMAGE_TYPE_ELEMENT_MAP
-
owner
-
elementHolders
-
freezeDecayHandler
-
lastReaction
-
electroChargedCooldown
private long electroChargedCooldown -
electroChargedOrigin
-
burningCooldown
private long burningCooldown -
burningOrigin
-
crystallizeShield
-
crystallizeShieldReducedAt
private int crystallizeShieldReducedAt
-
-
Constructor Details
-
ElementComponentImpl
-
-
Method Details
-
canApplyElement
-
isElectroChargedOnCD
public boolean isElectroChargedOnCD()- Specified by:
isElectroChargedOnCDin interfaceElementComponent
-
isBurningOnCD
public boolean isBurningOnCD()- Specified by:
isBurningOnCDin interfaceElementComponent
-
resetElectroChargedCD
public void resetElectroChargedCD()- Specified by:
resetElectroChargedCDin interfaceElementComponent
-
resetBurningCD
public void resetBurningCD()- Specified by:
resetBurningCDin interfaceElementComponent
-
setElectroChargedOrigin
- Specified by:
setElectroChargedOriginin interfaceElementComponent
-
setBurningOrigin
- Specified by:
setBurningOriginin interfaceElementComponent
-
getElectroChargedOrigin
- Specified by:
getElectroChargedOriginin interfaceElementComponent
-
getBurningOrigin
- Specified by:
getBurningOriginin interfaceElementComponent
-
getFreezeDecayTimeModifier
public double getFreezeDecayTimeModifier()Description copied from interface:ElementComponentGets the current decay time modifier for the Freeze aura.
Freeze is a special element: its decay is unique.- Freeze's gauge decay starts with the standard rate: 0.4 GU/s
- For every second the entity is frozen, the gauge decay increases by 0.1 GU/s, hence 0.1 GU/s² acceleration
- When the entity is unfrozen, the gauge decay decreases by 0.2 GU/s until it is back at 0.4 GU/s, hence 0.2 GU/s² deceleration
sum(max(0, t_frozen_i - 2 t_unfrozen_i))
iis a Frozen and unfrozen instance, and since we reset only when it is 0 due to being negative, we could drop thesum()function, as this behaves exactly like the mathematical model, given that we update the frozenTime and unfrozenTime accordingly.
Retrieved from: https://library.keqingmains.com/combat-mechanics/elemental-effects/transformative-reactions#frozen.- Specified by:
getFreezeDecayTimeModifierin interfaceElementComponent
-
setCrystallizeShield
Description copied from interface:ElementComponentGrants this entity a Crystallize shield.- Specified by:
setCrystallizeShieldin interfaceElementComponent- Parameters:
element- The element of this Crystallize shield.amount- The amount of HP this shield has.
-
getCrystallizeShield
Description copied from interface:ElementComponentGets the current Crystallize Shield of this entity.- Specified by:
getCrystallizeShieldin interfaceElementComponent
-
reduceCrystallizeShield
Description copied from interface:ElementComponentReduces the Crystallize shield and returns the effective amount of DMG reduced.- Specified by:
reduceCrystallizeShieldin interfaceElementComponent- Parameters:
source- TheDamageSource. If this isn't an instance ofElementalDamageSource,0is returned.amount- The amount of damage to be dealt to the entity.
-
reducedCrystallizeShield
public boolean reducedCrystallizeShield()Description copied from interface:ElementComponentReturns whether the Crystallize Shield has been reduced in the current tick.- Specified by:
reducedCrystallizeShieldin interfaceElementComponent
-
getOwner
- Specified by:
getOwnerin interfaceElementComponent
-
getElementHolder
- Specified by:
getElementHolderin interfaceElementComponent
-
getLastReaction
- Specified by:
getLastReactionin interfaceElementComponent
-
setLastReaction
-
canApplyElement
public boolean canApplyElement(Element element, InternalCooldownContext icdContext, boolean handleICD) Description copied from interface:ElementComponentChecks if the element can be applied.- Specified by:
canApplyElementin interfaceElementComponent- Parameters:
element- The element to check.icdContext- TheInternalCooldownContextof the Element to be applied.handleICD- Whether the ICD should be handled. This will register a "hit" to the gauge sequence.
-
addElementalApplication
public List<ElementalReaction> addElementalApplication(ElementalApplication application, InternalCooldownContext icdContext) - Specified by:
addElementalApplicationin interfaceElementComponent
-
getAppliedElements
Description copied from interface:ElementComponentGets all currently applied elements as aArray.- Specified by:
getAppliedElementsin interfaceElementComponent
-
applyFromDamageSource
Description copied from interface:ElementComponentApplies anElementalDamageSourceto this entity, possibly triggering multipleElementalReactions. If no reactions were triggered, the list will be empty.- Specified by:
applyFromDamageSourcein interfaceElementComponent- Parameters:
source- TheElementalDamageSourceto apply to this entity.- Returns:
- The triggered
ElementalReactions.
-
writeData
- Specified by:
writeDatain interfaceorg.ladysnake.cca.api.v3.component.Component
-
readData
- Specified by:
readDatain interfaceorg.ladysnake.cca.api.v3.component.Component
-
tick
public void tick()- Specified by:
tickin interfaceorg.ladysnake.cca.api.v3.component.tick.CommonTickingComponent
-
removeConsumedElements
private void removeConsumedElements() -
getHighestElementPriority
Description copied from interface:ElementComponentGets the lowestpriorityvalue from the currently applied Elements as anOptional.
If theOptionalhas no value, this means that there are no Elements currently applied.- Specified by:
getHighestElementPriorityin interfaceElementComponent
-
getPrioritizedElements
Description copied from interface:ElementComponentGets all currently prioritized applied elements as anArray.
If there are applied Elements with multiple priority values, the most prioritized one has to be consumed first before the others can be consumed.
Say that Element A has a priority of1, while Element B has a priority of2. Element A's application must be consumed entirely before Element B could be reacted with or reapplied.- Specified by:
getPrioritizedElementsin interfaceElementComponent
-
getTriggerableReactions
private Stream<ElementalReaction> getTriggerableReactions(int priority, ElementalApplication triggeringElement) -
attemptReapply
Attempts to reapply anElemental Application.
This method returns whether the provided Elemental Application was "reapplied" in some way, wheretruemeans that the element has been "reapplied" and cannot be used in an Elemental Reaction andfalsemeans that the element has not been "reapplied" and can be used in an Elemental Reaction.
This method also does not guarantee that all Elemental Applications provided are indeed reapplied to their respective Elements, as they can be discarded due to the current Element priority.
Elements will only be reapplied if the Element in question has the same priority as the current "highest element priority".- Parameters:
application- TheElementalApplicationto reapply.- Returns:
trueif the Elemental Application was "reapplied",falseotherwise.
-
triggerReactions
private Set<ElementalReaction> triggerReactions(ElementalApplication application, @Nullable @Nullable LivingEntity origin) Triggers all possible Elemental Reactions.
Elemental Reactions adhere to the rules of Element priority, where only triggerable reactions containing elements with the highest priority are considered.
Triggering a Reaction
When an element is already applied to this entity and another element is applied, an Elemental Reaction may be triggered.
Each registered Elemental Reaction is filtered based on the priorities of the elements participating in that reaction, where reactions only containing elements with the same priority are considered.
After that, the candidate reactions are once again sorted based on the currently applied element's priority. The reaction with the highest priority for the currently applied element will be the triggered reaction.Triggering Multiple Reactions
After a reaction is triggered, so long as the currently applied element still contains leftover Gauge Units, an attempt to find another reaction that can be triggered is made. If a reaction is found, it is then triggered and the cycle repeats.
Priority Upgrade
If no reactions can be triggered, an attempt to upgrade the priority is made first, so long as the previous reaction allows it, where the newer priority must be greater than the previous one.
Once the priority upgrade succeeds, an attempt is made again to find a triggerable reaction. If a reaction is found, it is then triggered and the cycle repeats with the higher priority. Otherwise, no more attempts are made to trigger reactions afterward.Applying as an Aura Element
Normally, the triggering element is removed when at least one reaction has been triggered. However, the triggering element can be applied as an aura element afterward if all participating reactions haveElementalReaction#shouldApplyResultAsAuraenabled.
Do note that onlyGAUGE_UNITElemental Applications are subject to removal.DURATIONElemental Applications are not removed or accounted for by this method.- Parameters:
application- TheElementalApplicationto apply to this entity.origin- The origin of theElementalApplication.
-