EffectControllerComponent class

Пакет: com.hypixel.hytale.server.core.entity.effect

Файл: com/hypixel/hytale/server/core/entity/effect/EffectControllerComponent.java

implements: Component<EntityStore>

Поля (36)

МодификаторыТипИмя
break
return
boolean var1
EntityEffectUpdate[] var1
ActiveEntityEffect[] var1
ActiveEntityEffect[] var2
int var2
int var2
int var2
IntSet var3
ObjectIterator var3
int var4
PlayerSkinComponent var4
EntityEffect var4
IntIterator var4
Entry var4
ActiveEntityEffect var4
boolean var5
ActiveEntityEffect var5
var5
ModelComponent var5
ActiveEntityEffect var5
int var5
ActiveEntityEffect var5
float var6
int var6
EntityStatMap var6
ModelAsset var6
int var6
EntityStatMap var6
OverlapBehavior var7
ActiveEntityEffect var7
Model var7
EntityStatMap var7
ActiveEntityEffect var8
EntityStatMap var9

Методы (39)

МодификаторыВозвратСигнатура
public void addActiveEntityEffectsvoid addActiveEntityEffects(@Nonnull ActiveEntityEffect[] var1)
private void addChangevoid addChange(@Nonnull EntityEffectUpdate var1)
public boolean addEffectboolean addEffect(@Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, @Nonnull ComponentAccessor<EntityStore> var3)
public boolean addEffectboolean addEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull EntityEffect var3, @Nonnull ComponentAccessor<EntityStore> var4)
public boolean addEffectboolean addEffect(@Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, float var3, @Nonnull OverlapBehavior var4, @Nonnull ComponentAccessor<EntityStore> var5)
public boolean addEffectboolean addEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull EntityEffect var3, float var4, @Nonnull OverlapBehavior var5, @Nonnull ComponentAccessor<EntityStore> var6)
public boolean addInfiniteEffectboolean addInfiniteEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull EntityEffect var3, @Nonnull ComponentAccessor<EntityStore> var4)
public void clearChangesvoid clearChanges()
public void clearEffectsvoid clearEffects(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
public boolean consumeNetworkOutdatedboolean consumeNetworkOutdated()
for for(ActiveEntityEffect var5 : var1)
public int[] getActiveEffectIndexesint[] getActiveEffectIndexes()
public boolean hasEffectboolean hasEffect(@Nullable EntityEffect var1)
public boolean hasEffectboolean hasEffect(int var1)
if if(var2 != null)
if if(var7 != null)
if if(var9 != null)
if if(var5 == null)
if if(var6 != null)
if if(this.originalModel == null)
if if(this.originalModel != null && this.activeModelChangeEntityEffectIndex == var2)
if if(var4 != null)
if if(var1.length != 0)
if if(var6 != Integer.MIN_VALUE)
if if(var4 == null)
if if(var5 != null)
if if(var7 != null)
if if(var6 != null)
if if(this.originalModel != null)
if if(this.cachedActiveEffectIndexes == null)
if if(var1 == null)
public void invalidateCachevoid invalidateCache()
public boolean isInvulnerableboolean isInvulnerable()
public void removeEffectvoid removeEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull ComponentAccessor<EntityStore> var3)
public void removeEffectvoid removeEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull RemovalBehavior var3, @Nonnull ComponentAccessor<EntityStore> var4)
public void setInvulnerablevoid setInvulnerable(boolean var1)
public void setModelChangevoid setModelChange(@Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, int var3, @Nonnull ComponentAccessor<EntityStore> var4)
switch switch(var3)
public void tryResetModelChangevoid tryResetModelChange(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull ComponentAccessor<EntityStore> var3)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.entity.effect;

class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.EffectOp;
class="kw">import com.hypixel.hytale.protocol.EntityEffectUpdate;
class="kw">import com.hypixel.hytale.server.core.asset.type.entityeffect.config.EntityEffect;
class="kw">import com.hypixel.hytale.server.core.asset.type.entityeffect.config.OverlapBehavior;
class="kw">import com.hypixel.hytale.server.core.asset.type.entityeffect.config.RemovalBehavior;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.livingentity.LivingEntityEffectSystem;
class="kw">import com.hypixel.hytale.server.core.modules.entity.player.PlayerSkinComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.ints.IntArraySet;
class="kw">import it.unimi.dsi.fastutil.ints.IntIterator;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectIterator;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectList;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class EffectControllerComponent class="kw">implements Component<EntityStore> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<EffectControllerComponent> CODEC = BuilderCodec.builder(EffectControllerComponent.class, EffectControllerComponent::new)
      .append(
         new KeyedCodec<>("ActiveEntityEffects", new ArrayCodec<>(ActiveEntityEffect.CODEC, ActiveEntityEffect[]::new)),
         EffectControllerComponent::addActiveEntityEffects,
         EffectControllerComponent::getAllActiveEntityEffects
      )
      .add()
      .build();
   @Nonnull
   class="kw">protected class="kw">final Int2ObjectMap<ActiveEntityEffect> activeEffects = new Int2ObjectOpenHashMap();
   @Nullable
   class="kw">protected int[] cachedActiveEffectIndexes;
   @Nonnull
   class="kw">protected ObjectList<EntityEffectUpdate> changes = new ObjectArrayList();
   class="kw">protected boolean isNetworkOutdated;
   @Nullable
   class="kw">protected Model originalModel = null;
   class="kw">protected int activeModelChangeEntityEffectIndex;
   class="kw">protected boolean isInvulnerable;

   @Nonnull
   class="kw">public class="kw">static ComponentType<EntityStore, EffectControllerComponent> getComponentType() {
      class="kw">return EntityModule.get().getEffectControllerComponentType();
   }

   class="kw">public EffectControllerComponent() {
   }

   class="kw">public EffectControllerComponent(@Nonnull EffectControllerComponent var1) {
      this.originalModel = var1.originalModel;
      this.activeModelChangeEntityEffectIndex = var1.activeModelChangeEntityEffectIndex;
      this.changes.addAll(var1.changes);
      ActiveEntityEffect[] var2 = var1.getAllActiveEntityEffects();
      if (var2 != null) {
         this.addActiveEntityEffects(var2);
      }
   }

   class="kw">public boolean isInvulnerable() {
      class="kw">return this.isInvulnerable;
   }

   class="kw">public void setInvulnerable(boolean var1) {
      this.isInvulnerable = var1;
   }

   class="kw">public boolean addEffect(@Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      int var4 = EntityEffect.getAssetMap().getIndex(var2.getId());
      class="kw">return var4 == Integer.MIN_VALUE ? false : this.addEffect(var1, var4, var2, var3);
   }

   class="kw">public boolean addEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull EntityEffect var3, @Nonnull ComponentAccessor<EntityStore> var4) {
      boolean var5 = var3.isInfinite();
      float var6 = var3.getDuration();
      OverlapBehavior var7 = var3.getOverlapBehavior();
      class="kw">return var5 ? this.addInfiniteEffect(var1, var2, var3, var4) : this.addEffect(var1, var2, var3, var6, var7, var4);
   }

   class="kw">public boolean addEffect(
      @Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, float var3, @Nonnull OverlapBehavior var4, @Nonnull ComponentAccessor<EntityStore> var5
   ) {
      int var6 = EntityEffect.getAssetMap().getIndex(var2.getId());
      class="kw">return var6 == Integer.MIN_VALUE ? false : this.addEffect(var1, var6, var2, var3, var4, var5);
   }

   class="kw">public boolean addEffect(
      @Nonnull Ref<EntityStore> var1,
      int var2,
      @Nonnull EntityEffect var3,
      float var4,
      @Nonnull OverlapBehavior var5,
      @Nonnull ComponentAccessor<EntityStore> var6
   ) {
      if (!LivingEntityEffectSystem.canApplyEffect(var1, var3, var6)) {
         class="kw">return false;
      }

      ActiveEntityEffect var7 = (ActiveEntityEffect)this.activeEffects.get(var2);
      if (var7 != null) {
         if (var7.isInfinite()) {
            class="kw">return true;
         } else if (var5 != OverlapBehavior.IGNORE) {
            var7.remainingDuration = var5 == OverlapBehavior.EXTEND ? var7.remainingDuration + var4 : var4;
            this.addChange(new EntityEffectUpdate(EffectOp.Add, var2, var7.remainingDuration, false, var7.debuff, var7.statusEffectIcon));
            class="kw">return true;
         } else {
            class="kw">return true;
         }
      } else {
         ActiveEntityEffect var8 = new ActiveEntityEffect(var3.getId(), var2, var4, var3.isDebuff(), var3.getStatusEffectIcon(), var3.isInvulnerable());
         this.activeEffects.put(var2, var8);
         EntityStatMap var9 = var6.getComponent(var1, EntityStatMap.getComponentType());
         if (var9 != null) {
            var9.getStatModifiersManager().scheduleRecalculate();
         }

         this.setModelChange(var1, var3, var2, var6);
         this.addChange(new EntityEffectUpdate(EffectOp.Add, var2, var8.remainingDuration, false, var8.debuff, var8.statusEffectIcon));
         this.invalidateCache();
         class="kw">return true;
      }
   }

   class="kw">public boolean addInfiniteEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull EntityEffect var3, @Nonnull ComponentAccessor<EntityStore> var4) {
      if (!LivingEntityEffectSystem.canApplyEffect(var1, var3, var4)) {
         class="kw">return false;
      }

      ActiveEntityEffect var5 = (ActiveEntityEffect)this.activeEffects.get(var2);
      if (var5 == null) {
         var5 = new ActiveEntityEffect(var3.getId(), var2, true, var3.isInvulnerable());
         this.activeEffects.put(var2, var5);
         EntityStatMap var6 = var4.getComponent(var1, EntityStatMap.getComponentType());
         if (var6 != null) {
            var6.getStatModifiersManager().scheduleRecalculate();
         }

         this.invalidateCache();
      } else if (!var5.isInfinite()) {
         var5.infinite = true;
      }

      this.setModelChange(var1, var3, var2, var4);
      this.addChange(new EntityEffectUpdate(EffectOp.Add, var2, var5.remainingDuration, true, var5.debuff, var5.statusEffectIcon));
      class="kw">return true;
   }

   class="kw">public void setModelChange(@Nonnull Ref<EntityStore> var1, @Nonnull EntityEffect var2, int var3, @Nonnull ComponentAccessor<EntityStore> var4) {
      if (this.originalModel == null) {
         if (var2.getModelChange() != null) {
            ModelComponent var5 = var4.getComponent(var1, ModelComponent.getComponentType());
            assert var5 != null;
            this.originalModel = var5.getModel();
            this.activeModelChangeEntityEffectIndex = var3;
            ModelAsset var6 = ModelAsset.getAssetMap().getAsset(var2.getModelChange());
            Model var7 = Model.createRandomScaleModel(var6);
            var4.putComponent(var1, ModelComponent.getComponentType(), new ModelComponent(var7));
         }
      }
   }

   class="kw">public void tryResetModelChange(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      if (this.originalModel != null && this.activeModelChangeEntityEffectIndex == var2) {
         var3.putComponent(var1, ModelComponent.getComponentType(), new ModelComponent(this.originalModel));
         PlayerSkinComponent var4 = var3.getComponent(var1, PlayerSkinComponent.getComponentType());
         if (var4 != null) {
            var4.setNetworkOutdated();
         }

         this.originalModel = null;
      }
   }

   class="kw">public void addActiveEntityEffects(@Nonnull ActiveEntityEffect[] var1) {
      if (var1.length != 0) {
         for (ActiveEntityEffect var5 : var1) {
            int var6 = EntityEffect.getAssetMap().getIndex(var5.entityEffectId);
            if (var6 != Integer.MIN_VALUE) {
               var5.entityEffectIndex = var6;
               this.activeEffects.put(var6, var5);
               this.addChange(new EntityEffectUpdate(EffectOp.Add, var6, var5.remainingDuration, var5.infinite, var5.debuff, var5.statusEffectIcon));
            }
         }

         this.invalidateCache();
      }
   }

   class="kw">public void removeEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      EntityEffect var4 = EntityEffect.getAssetMap().getAsset(var2);
      if (var4 == null) {
         throw new IllegalArgumentException(String.format("Unknown EntityEffect with index \"%s\"", var2));
      }

      this.removeEffect(var1, var2, var4.getRemovalBehavior(), var3);
   }

   class="kw">public void removeEffect(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull RemovalBehavior var3, @Nonnull ComponentAccessor<EntityStore> var4) {
      ActiveEntityEffect var5 = (ActiveEntityEffect)this.activeEffects.get(var2);
      if (var5 != null) {
         this.tryResetModelChange(var1, var5.getEntityEffectIndex(), var4);
         class="kw">switch (var3) {
            case COMPLETE:
               this.activeEffects.remove(var2);
               EntityStatMap var7 = var4.getComponent(var1, EntityStatMap.getComponentType());
               if (var7 != null) {
                  var7.getStatModifiersManager().scheduleRecalculate();
               }

               this.addChange(new EntityEffectUpdate(EffectOp.Remove, var2, 0.0F, false, false, ""));
               this.invalidateCache();
               class="kw">return;
            case INFINITE:
               var5.infinite = false;
               break;
            case DURATION:
               var5.remainingDuration = 0.0F;
         }

         EntityStatMap var6 = var4.getComponent(var1, EntityStatMap.getComponentType());
         if (var6 != null) {
            var6.getStatModifiersManager().scheduleRecalculate();
         }

         this.addChange(new EntityEffectUpdate(EffectOp.Remove, var2, var5.remainingDuration, var5.infinite, var5.debuff, var5.statusEffectIcon));
      }
   }

   class="kw">private void addChange(@Nonnull EntityEffectUpdate var1) {
      this.isNetworkOutdated = true;
      this.changes.add(var1);
   }

   class="kw">public void clearEffects(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      IntSet var3 = new IntArraySet(this.activeEffects.keySet());
      IntIterator var4 = var3.iterator();

      while (var4.hasNext()) {
         int var5 = (Integer)var4.next();
         this.removeEffect(var1, var5, var2);
      }

      this.invalidateCache();
      if (this.originalModel != null) {
         var2.putComponent(var1, ModelComponent.getComponentType(), new ModelComponent(this.originalModel));
         this.originalModel = null;
      }
   }

   class="kw">public void invalidateCache() {
      this.cachedActiveEffectIndexes = null;
   }

   @Nonnull
   class="kw">public Int2ObjectMap<ActiveEntityEffect> getActiveEffects() {
      class="kw">return this.activeEffects;
   }

   class="kw">public int[] getActiveEffectIndexes() {
      if (this.cachedActiveEffectIndexes == null) {
         if (this.activeEffects.isEmpty()) {
            this.cachedActiveEffectIndexes = ArrayUtil.EMPTY_INT_ARRAY;
         } else {
            this.cachedActiveEffectIndexes = this.activeEffects.keySet().toIntArray();
         }
      }

      class="kw">return this.cachedActiveEffectIndexes;
   }

   class="kw">public boolean consumeNetworkOutdated() {
      boolean var1 = this.isNetworkOutdated;
      this.isNetworkOutdated = false;
      class="kw">return var1;
   }

   @Nonnull
   class="kw">public EntityEffectUpdate[] consumeChanges() {
      class="kw">return (EntityEffectUpdate[])this.changes.toArray(EntityEffectUpdate[]::new);
   }

   class="kw">public void clearChanges() {
      this.changes.clear();
   }

   @Nonnull
   class="kw">public EntityEffectUpdate[] createInitUpdates() {
      EntityEffectUpdate[] var1 = new EntityEffectUpdate[this.activeEffects.size()];
      int var2 = 0;
      ObjectIterator var3 = Int2ObjectMaps.fastIterator(this.activeEffects);

      while (var3.hasNext()) {
         Entry var4 = (Entry<ActiveEntityEffect>)var3.next();
         ActiveEntityEffect var5 = (ActiveEntityEffect)var4.getValue();
         var1[var2++] = new EntityEffectUpdate(EffectOp.Add, var4.getIntKey(), var5.remainingDuration, var5.infinite, var5.debuff, var5.statusEffectIcon);
      }

      class="kw">return var1;
   }

   @Nullable
   class="kw">public ActiveEntityEffect[] getAllActiveEntityEffects() {
      if (this.activeEffects.isEmpty()) {
         class="kw">return null;
      }

      ActiveEntityEffect[] var1 = new ActiveEntityEffect[this.activeEffects.size()];
      int var2 = 0;

      for (ObjectIterator var3 = this.activeEffects.values().iterator(); var3.hasNext(); var2++) {
         ActiveEntityEffect var4 = (ActiveEntityEffect)var3.next();
         var1[var2] = var4;
      }

      class="kw">return var1;
   }

   class="kw">public boolean hasEffect(@Nullable EntityEffect var1) {
      if (var1 == null) {
         class="kw">return false;
      }

      int var2 = EntityEffect.getAssetMap().getIndex(var1.getId());
      class="kw">return var2 == Integer.MIN_VALUE ? false : this.activeEffects.containsKey(var2);
   }

   class="kw">public boolean hasEffect(int var1) {
      class="kw">return this.activeEffects.containsKey(var1);
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "EntityEffectController{activeEffects=" + this.activeEffects + "}";
   }

   @Nonnull
   class="kw">public EffectControllerComponent clone() {
      class="kw">return new EffectControllerComponent(this);
   }
}