Class EffectControllerComponent

java.lang.Object
com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class EffectControllerComponent extends Object implements Component<EntityStore>
A component that lives on an entity for updating, adding and removing entity effects.
  • Field Details

  • Constructor Details

  • Method Details

    • getComponentType

      @Nonnull public static ComponentType<EntityStore, EffectControllerComponent> getComponentType()
      Returns:
      the component type for the EffectControllerComponent component.
    • isInvulnerable

      public boolean isInvulnerable()
      Returns:
      true if any of the active effects provide invulnerability, false otherwise.
    • setInvulnerable

      public void setInvulnerable(boolean invulnerable)
      Sets whether any of the active effects provide invulnerability.
      Parameters:
      invulnerable - Whether any of the active effects provide invulnerability.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, @Nonnull EntityEffect entityEffect, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to add an entity effect to this entity effect controller.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffect - The EntityEffect instance to add.
      componentAccessor - The component accessor for the component access.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, @Nonnull EntityEffect entityEffect, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nullable Ref<EntityStore> owner)
      Called to add an entity effect to this entity effect controller with its configured duration and overlap behavior, attributed to the entity that applied it. Owner attribution is not tracked for infinite effects.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffect - The EntityEffect instance to add.
      componentAccessor - The component accessor for component access.
      owner - The entity that owns the effect (the one that applied it), or null when unknown.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull EntityEffect entityEffect, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to add an entity effect to this entity effect controller.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect asset.
      entityEffect - The EntityEffect instance to add.
      componentAccessor - The component accessor for component access.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, @Nonnull EntityEffect entityEffect, float duration, @Nonnull OverlapBehavior overlapBehavior, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to add an entity effect to this entity effect controller.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffect - The EntityEffect instance to add.
      duration - The duration, in seconds, of the entity effect.
      overlapBehavior - The overlap behaviour applied by the effect.
      componentAccessor - The component accessor for component access.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, @Nonnull EntityEffect entityEffect, float duration, @Nonnull OverlapBehavior overlapBehavior, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nullable Ref<EntityStore> owner)
      Called to add an entity effect to this entity effect controller, attributed to the entity that applied it. Damage ticks from the effect credit the owner (combat text, kill credit) instead of the effect itself.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffect - The EntityEffect instance to add.
      duration - The duration, in seconds, of the entity effect.
      overlapBehavior - The overlap behaviour applied by the effect.
      componentAccessor - The component accessor for component access.
      owner - The entity that owns the effect (the one that applied it), or null when unknown.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull EntityEffect entityEffect, float duration, @Nonnull OverlapBehavior overlapBehavior, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to add an entity effect to this entity effect controller.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect asset.
      entityEffect - The EntityEffect instance to add.
      duration - The duration, in seconds, of the entity effect.
      overlapBehavior - The overlap behaviour applied by the effect.
      componentAccessor - The component accessor for component access.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addEffect

      public boolean addEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull EntityEffect entityEffect, float duration, @Nonnull OverlapBehavior overlapBehavior, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nullable Ref<EntityStore> owner)
      Called to add an entity effect to this entity effect controller, attributed to the entity that applied it.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect asset.
      entityEffect - The EntityEffect instance to add.
      duration - The duration, in seconds, of the entity effect.
      overlapBehavior - The overlap behaviour applied by the effect.
      componentAccessor - The component accessor for component access.
      owner - The entity that owns the effect (the one that applied it), or null when unknown.
      Returns:
      true if the effect was added successfully, false otherwise.
    • addInfiniteEffect

      public boolean addInfiniteEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull EntityEffect entityEffect, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to add an entity effect for an infinite amount of time.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect asset.
      entityEffect - The EntityEffect instance to be added.
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
      Returns:
      true if the effect was added successfully, false otherwise.
    • setModelChange

      public void setModelChange(@Nonnull Ref<EntityStore> ownerRef, @Nonnull EntityEffect entityEffect, int entityEffectIndex, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Sets model change from an entity effect, if present.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffect - the entity effect being applied.
      entityEffectIndex - the index of the entity effect being applied.
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
    • tryResetModelChange

      public void tryResetModelChange(@Nonnull Ref<EntityStore> ownerRef, int activeEffectIndex, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Resets model change applied to the owner, if it was applied by this entity effect.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      activeEffectIndex - The index of the entity effect being removed.
      componentAccessor - The component accessor for component access.
    • addActiveEntityEffects

      public void addActiveEntityEffects(@Nonnull ActiveEntityEffect[] activeEntityEffects)
      Called to add all active entity effects from the given array.
      Parameters:
      activeEntityEffects - The array of active entity effects to include.
    • removeEffect

      public void removeEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to remove an entity effect with the given index.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect to be removed.
      componentAccessor - The component accessor for component access.
    • removeEffect

      public void removeEffect(@Nonnull Ref<EntityStore> ownerRef, int entityEffectIndex, @Nonnull RemovalBehavior removalBehavior, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to remove an entity effect with the given index.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      entityEffectIndex - The index of the entity effect to be removed.
      removalBehavior - Determines the removal behaviour.
      componentAccessor - The component accessor for component access.
    • clearEffects

      public void clearEffects(@Nonnull Ref<EntityStore> ownerRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to clear all active entity effects from this controller.
      Parameters:
      ownerRef - The entity reference of the owner entity.
      componentAccessor - The component accessor for component access.
    • invalidateCache

      public void invalidateCache()
      Called to invalidate the cache of this controller.
    • getActiveEffects

      @Nonnull public it.unimi.dsi.fastutil.ints.Int2ObjectMap<ActiveEntityEffect> getActiveEffects()
      Called to fetch an unmodifiable map of all active entity effects.
      Returns:
      the unmodifiable map of all active entity effects.
    • getActiveEffectIndexes

      public int[] getActiveEffectIndexes()
      Called to fetch an array of all active entity effect indexes.
      Returns:
      an array of indexes for all active entity effects.
    • consumeNetworkOutdated

      public boolean consumeNetworkOutdated()
      Checks and consumes whether the network is outdated.
      Returns:
      true if the network is outdated, false otherwise.
    • consumeChanges

      @Nonnull public EntityEffectUpdate[] consumeChanges()
      Fetches all entity effect updates as a single array.
      Returns:
      an array of entity effect updates.
    • clearChanges

      public void clearChanges()
      Called to clear all entity effect changes
    • createInitUpdates

      @Nonnull public EntityEffectUpdate[] createInitUpdates()
      Returns:
      an array of entity effect updates based on the current active effects.
    • getAllActiveEntityEffects

      @Nullable public ActiveEntityEffect[] getAllActiveEntityEffects()
      Called to fetch all active entity effect instances for this controller.
      Returns:
      an array of active entity effect instances.
    • hasEffect

      public boolean hasEffect(@Nullable EntityEffect entityEffect)
      Checks whether this controller has an active effect matching the given entity effect.
      Parameters:
      entityEffect - The entity effect to check for.
      Returns:
      true if this controller has an active effect matching the given entity effect, false otherwise.
    • hasEffect

      public boolean hasEffect(int effectIndex)
      Checks whether this controller has an active effect matching the given entity effect index.
      Parameters:
      effectIndex - The entity effect asset index to check for.
      Returns:
      true if this controller has an active effect matching the given entity effect, false otherwise.
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • clone

      @Nonnull public EffectControllerComponent clone()
      Specified by:
      clone in interface Component<EntityStore>
      Returns:
      a clone instance of the original component instance.