EntityEffect class

Пакет: com.hypixel.hytale.server.core.asset.type.entityeffect.config

Файл: com/hypixel/hytale/server/core/asset/type/entityeffect/config/EntityEffect.java

implements: JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, EntityEffect>>, NetworkSerializable<com.hypixel.hytale.protocol.EntityEffect>

Поля (3)

МодификаторыТипИмя
STORE
com.hypixel.hytale.protocol.EntityEffect var1
com.hypixel.hytale.protocol.EntityEffect var2

Методы (13)

МодификаторыВозвратСигнатура
public float getDamageCalculatorCooldownfloat getDamageCalculatorCooldown()
public String getDeathMessageKeyString getDeathMessageKey()
public float getDurationfloat getDuration()
public String getIdString getId()
if if(var0.worldRemovalSoundEventId != null)
if if(var0.localRemovalSoundEventId != null)
if if(STORE == null)
if if(var1 != null)
if if(this.applicationEffects != null)
if if(this.modelOverride != null)
public boolean isDebuffboolean isDebuff()
public boolean isInfiniteboolean isInfinite()
public boolean isInvulnerableboolean isInvulnerable()

Исходный код

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

class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.codec.ContainedAssetCodec;
class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.MapCodec;
class="kw">import com.hypixel.hytale.codec.codecs.map.Object2FloatMapCodec;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.protocol.ValueType;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.ItemArmor;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.ModelAsset;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import com.hypixel.hytale.server.core.modules.entity.condition.Condition;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DamageCause;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.ResistanceModifier;
class="kw">import com.hypixel.hytale.server.core.modules.entitystats.EntityStatsModule;
class="kw">import com.hypixel.hytale.server.core.modules.entitystats.asset.EntityStatType;
class="kw">import com.hypixel.hytale.server.core.modules.entitystats.modifier.StaticModifier;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.combat.DamageCalculator;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.combat.DamageEffects;
class="kw">import it.unimi.dsi.fastutil.ints.Int2FloatMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.objects.Object2FloatMap;
class="kw">import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
class="kw">import java.lang.ref.SoftReference;
class="kw">import java.util.HashMap;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class EntityEffect
   class="kw">implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, EntityEffect>>,
   NetworkSerializable<com.hypixel.hytale.protocol.EntityEffect> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, EntityEffect> CODEC = AssetBuilderCodec.builder(
         EntityEffect.class,
         EntityEffect::new,
         Codec.STRING,
         (var0, var1) -> var0.id = var1,
         var0 -> var0.id,
         (var0, var1) -> var0.data = var1,
         var0 -> var0.data
      )
      .appendInherited(new KeyedCodec<>("Name", Codec.STRING), (var0, var1) -> var0.name = var1, var0 -> var0.name, (var0, var1) -> var0.name = var1.name)
      .documentation("The name of this entity effect that will be displayed in the UI. This must be a localization key.")
      .add()
      .appendInherited(
         new KeyedCodec<>("ApplicationEffects", ApplicationEffects.CODEC),
         (var0, var1) -> var0.applicationEffects = var1,
         var0 -> var0.applicationEffects,
         (var0, var1) -> var0.applicationEffects = var1.applicationEffects
      )
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("WorldRemovalSoundEventId", Codec.STRING),
         (var0, var1) -> var0.worldRemovalSoundEventId = var1,
         var0 -> var0.worldRemovalSoundEventId,
         (var0, var1) -> var0.worldRemovalSoundEventId = var1.worldRemovalSoundEventId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("LocalRemovalSoundEventId", Codec.STRING),
         (var0, var1) -> var0.localRemovalSoundEventId = var1,
         var0 -> var0.localRemovalSoundEventId,
         (var0, var1) -> var0.localRemovalSoundEventId = var1.localRemovalSoundEventId
      )
      .addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
      .add()
      .appendInherited(
         new KeyedCodec<>("DamageCalculator", DamageCalculator.CODEC),
         (var0, var1) -> var0.damageCalculator = var1,
         var0 -> var0.damageCalculator,
         (var0, var1) -> var0.damageCalculator = var1.damageCalculator
      )
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("DamageCalculatorCooldown", Codec.FLOAT),
         (var0, var1) -> var0.damageCalculatorCooldown = var1,
         var0 -> var0.damageCalculatorCooldown,
         (var0, var1) -> var0.damageCalculatorCooldown = var1.damageCalculatorCooldown
      )
      .addValidator(Validators.greaterThanOrEqual(0.0F))
      .add()
      .appendInherited(
         new KeyedCodec<>("DamageEffects", DamageEffects.CODEC),
         (var0, var1) -> var0.damageEffects = var1,
         var0 -> var0.damageEffects,
         (var0, var1) -> var0.damageEffects = var1.damageEffects
      )
      .add()
      .<DamageEffects>appendInherited(
         new KeyedCodec<>("StatModifierEffects", DamageEffects.CODEC),
         (var0, var1) -> var0.statModifierEffects = var1,
         var0 -> var0.statModifierEffects,
         (var0, var1) -> var0.statModifierEffects = var1.statModifierEffects
      )
      .documentation("Effects to play when stat modifiers are applied and updated.")
      .add()
      .appendInherited(
         new KeyedCodec<>("ModelOverride", ModelOverride.CODEC),
         (var0, var1) -> var0.modelOverride = var1,
         var0 -> var0.modelOverride,
         (var0, var1) -> var0.modelOverride = var1.modelOverride
      )
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("ModelChange", Codec.STRING),
         (var0, var1) -> var0.modelChange = var1,
         var0 -> var0.modelChange,
         (var0, var1) -> var0.modelChange = var1.modelChange
      )
      .addValidator(ModelAsset.VALIDATOR_CACHE.getValidator())
      .documentation("A model to change the affected entity's appearance to.")
      .add()
      .<Map>append(
         new KeyedCodec<>("RawStatModifiers", new MapCodec<>(new ArrayCodec<>(StaticModifier.CODEC, StaticModifier[]::new), HashMap::new)),
         (var0, var1) -> var0.rawStatModifiers = var1,
         var0 -> var0.rawStatModifiers
      )
      .addValidator(EntityStatType.VALIDATOR_CACHE.getMapKeyValidator().late())
      .add()
      .<Object2FloatMap<String>>appendInherited(
         new KeyedCodec<>("StatModifiers", new Object2FloatMapCodec<>(Codec.STRING, Object2FloatOpenHashMap::new)),
         (var0, var1) -> var0.unknownEntityStats = var1,
         var0 -> var0.unknownEntityStats,
         (var0, var1) -> var0.unknownEntityStats = var1.unknownEntityStats
      )
      .addValidator(EntityStatType.VALIDATOR_CACHE.getMapKeyValidator())
      .documentation("Modifiers to apply to EntityStats.")
      .add()
      .<ValueType>appendInherited(
         new KeyedCodec<>("ValueType", new EnumCodec<>(ValueType.class)),
         (var0, var1) -> var0.valueType = var1,
         var0 -> var0.valueType,
         (var0, var1) -> var0.valueType = var1.valueType
      )
      .documentation(
         "Enum to specify if the StatModifiers must be considered as absolute values or percent. Default value is Absolute. When using ValueType.Absolute, '100' matches the max value."
      )
      .addValidator(Validators.nonNull())
      .add()
      .<Float>appendInherited(
         new KeyedCodec<>("Duration", Codec.FLOAT), (var0, var1) -> var0.duration = var1, var0 -> var0.duration, (var0, var1) -> var0.duration = var1.duration
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<OverlapBehavior>appendInherited(
         new KeyedCodec<>("OverlapBehavior", OverlapBehavior.CODEC),
         (var0, var1) -> var0.overlapBehavior = var1,
         var0 -> var0.overlapBehavior,
         (var0, var1) -> var0.overlapBehavior = var1.overlapBehavior
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("Infinite", Codec.BOOLEAN),
         (var0, var1) -> var0.infinite = var1,
         var0 -> var0.infinite,
         (var0, var1) -> var0.infinite = var1.infinite
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("Debuff", Codec.BOOLEAN), (var0, var1) -> var0.debuff = var1, var0 -> var0.debuff, (var0, var1) -> var0.debuff = var1.debuff
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("Locale", Codec.STRING), (var0, var1) -> var0.locale = var1, var0 -> var0.locale, (var0, var1) -> var0.locale = var1.locale
      )
      .documentation("[Deprecated - DeathMessageKey instead] Use An optional translation key, used to display the damage cause upon death.")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("StatusEffectIcon", Codec.STRING),
         (var0, var1) -> var0.statusEffectIcon = var1,
         var0 -> var0.statusEffectIcon,
         (var0, var1) -> var0.statusEffectIcon = var1.statusEffectIcon
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<RemovalBehavior>appendInherited(
         new KeyedCodec<>("RemovalBehavior", RemovalBehavior.CODEC),
         (var0, var1) -> var0.removalBehavior = var1,
         var0 -> var0.removalBehavior,
         (var0, var1) -> var0.removalBehavior = var1.removalBehavior
      )
      .documentation("Value used by class="kw">default unless specified otherwise in the method's call.")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("Invulnerable", Codec.BOOLEAN),
         (var0, var1) -> var0.invulnerable = var1,
         var0 -> var0.invulnerable,
         (var0, var1) -> var0.invulnerable = var1.invulnerable
      )
      .documentation("Determines whether this effect applies the invulnerable component to the entity whilst active.")
      .add()
      .<Map>appendInherited(
         new KeyedCodec<>("DamageResistance", new MapCodec<>(new ArrayCodec<>(ResistanceModifier.CODEC, ResistanceModifier[]::new), HashMap::new)),
         (var0, var1) -> var0.damageResistanceValuesRaw = var1,
         var0 -> var0.damageResistanceValuesRaw,
         (var0, var1) -> var0.damageResistanceValuesRaw = var1.damageResistanceValuesRaw
      )
      .addValidator(DamageCause.VALIDATOR_CACHE.getMapKeyValidator())
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("DeathMessageKey", Codec.STRING),
         (var0, var1) -> var0.deathMessageKey = var1,
         var0 -> var0.deathMessageKey,
         (var0, var1) -> var0.deathMessageKey = var1.deathMessageKey
      )
      .documentation("Localization key used on the death screen when this EntityEffect kills a player.")
      .add()
      .<Condition[]>appendInherited(
         new KeyedCodec<>("ApplyConditions", new ArrayCodec<>(Condition.CODEC, Condition[]::new)),
         (var0, var1) -> var0.applyConditions = var1,
         var0 -> var0.applyConditions,
         (var0, var1) -> var0.applyConditions = var1.applyConditions
      )
      .documentation("Conditions that must ALL be true for this effect to remain active. If any condition fails, the effect is removed.")
      .add()
      .afterDecode(var0 -> {
         var0.entityStats = EntityStatsModule.resolveEntityStats(var0.unknownEntityStats);
         var0.statModifiers = EntityStatsModule.resolveEntityStats(var0.rawStatModifiers);
         if (var0.damageResistanceValuesRaw != null && !var0.damageResistanceValuesRaw.isEmpty()) {
            var0.damageResistanceValues = ItemArmor.convertStringKeyToDamageCause(var0.damageResistanceValuesRaw);
         }

         if (var0.worldRemovalSoundEventId != null) {
            var0.worldRemovalSoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.worldRemovalSoundEventId);
         }

         if (var0.localRemovalSoundEventId != null) {
            var0.localRemovalSoundEventIndex = SoundEvent.getAssetMap().getIndex(var0.localRemovalSoundEventId);
         }
      })
      .build();
   class="kw">public class="kw">static class="kw">final Codec<String> CHILD_ASSET_CODEC = new ContainedAssetCodec<>(EntityEffect.class, CODEC);
   class="kw">public class="kw">static class="kw">final Codec<String[]> CHILD_ASSET_CODEC_ARRAY = new ArrayCodec<>(CHILD_ASSET_CODEC, String[]::new);
   @Nullable
   class="kw">private class="kw">static AssetStore<String, EntityEffect, IndexedLookupTableAssetMap<String, EntityEffect>> STORE;
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(EntityEffect::getAssetStore));
   class="kw">protected AssetExtraInfo.Data data;
   class="kw">protected String id;
   @Nullable
   class="kw">protected String name;
   @Nullable
   class="kw">protected ApplicationEffects applicationEffects;
   @Nullable
   class="kw">protected String worldRemovalSoundEventId;
   class="kw">protected class="kw">transient int worldRemovalSoundEventIndex = 0;
   @Nullable
   class="kw">protected String localRemovalSoundEventId;
   class="kw">protected class="kw">transient int localRemovalSoundEventIndex = 0;
   @Nullable
   class="kw">protected DamageCalculator damageCalculator;
   class="kw">protected float damageCalculatorCooldown;
   @Nullable
   class="kw">protected DamageEffects damageEffects;
   @Nullable
   class="kw">protected DamageEffects statModifierEffects;
   @Nullable
   class="kw">protected ModelOverride modelOverride;
   @Nullable
   class="kw">protected String modelChange;
   @Nullable
   class="kw">protected Object2FloatMap<String> unknownEntityStats;
   @Nullable
   class="kw">protected Int2FloatMap entityStats;
   @Nonnull
   class="kw">protected ValueType valueType = ValueType.Absolute;
   class="kw">protected float duration = 0.0F;
   @Nonnull
   class="kw">protected OverlapBehavior overlapBehavior = OverlapBehavior.IGNORE;
   @Nonnull
   class="kw">protected RemovalBehavior removalBehavior = RemovalBehavior.COMPLETE;
   class="kw">protected boolean infinite;
   class="kw">protected boolean debuff;
   @Nullable
   class="kw">protected String statusEffectIcon;
   @Nullable
   class="kw">protected String locale;
   class="kw">protected boolean invulnerable = false;
   class="kw">protected String deathMessageKey;
   @Nullable
   class="kw">protected Condition[] applyConditions;
   @Nullable
   class="kw">protected Map<String, StaticModifier[]> rawStatModifiers;
   @Nullable
   class="kw">protected Int2ObjectMap<StaticModifier[]> statModifiers;
   @Nullable
   class="kw">protected Map<String, ResistanceModifier[]> damageResistanceValuesRaw;
   @Nullable
   class="kw">protected Map<DamageCause, ResistanceModifier[]> damageResistanceValues;
   @Nullable
   class="kw">private SoftReference<com.hypixel.hytale.protocol.EntityEffect> cachedPacket;

   @Nonnull
   class="kw">public class="kw">static AssetStore<String, EntityEffect, IndexedLookupTableAssetMap<String, EntityEffect>> getAssetStore() {
      if (STORE == null) {
         STORE = AssetRegistry.getAssetStore(EntityEffect.class);
      }

      class="kw">return STORE;
   }

   @Nonnull
   class="kw">public class="kw">static IndexedLookupTableAssetMap<String, EntityEffect> getAssetMap() {
      class="kw">return (IndexedLookupTableAssetMap<String, EntityEffect>)getAssetStore().getAssetMap();
   }

   class="kw">public EntityEffect(@Nonnull String var1) {
      this.id = var1;
   }

   class="kw">protected EntityEffect() {
   }

   @Nullable
   class="kw">public String getName() {
      class="kw">return this.name;
   }

   @Nullable
   class="kw">public Int2ObjectMap<StaticModifier[]> getStatModifiers() {
      class="kw">return this.statModifiers;
   }

   class="kw">public String getId() {
      class="kw">return this.id;
   }

   @Nullable
   class="kw">public ApplicationEffects getApplicationEffects() {
      class="kw">return this.applicationEffects;
   }

   @Nullable
   class="kw">public DamageCalculator getDamageCalculator() {
      class="kw">return this.damageCalculator;
   }

   class="kw">public float getDamageCalculatorCooldown() {
      class="kw">return this.damageCalculatorCooldown;
   }

   @Nullable
   class="kw">public DamageEffects getDamageEffects() {
      class="kw">return this.damageEffects;
   }

   @Nullable
   class="kw">public DamageEffects getStatModifierEffects() {
      class="kw">return this.statModifierEffects;
   }

   @Nullable
   class="kw">public ModelOverride getModelOverride() {
      class="kw">return this.modelOverride;
   }

   @Nullable
   class="kw">public String getModelChange() {
      class="kw">return this.modelChange;
   }

   @Nullable
   class="kw">public Int2FloatMap getEntityStats() {
      class="kw">return this.entityStats;
   }

   class="kw">public float getDuration() {
      class="kw">return this.duration;
   }

   @Nonnull
   class="kw">public OverlapBehavior getOverlapBehavior() {
      class="kw">return this.overlapBehavior;
   }

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

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

   @Nullable
   class="kw">public String getStatusEffectIcon() {
      class="kw">return this.statusEffectIcon;
   }

   @Nullable
   class="kw">public String getLocale() {
      class="kw">return this.locale;
   }

   @Nonnull
   class="kw">public RemovalBehavior getRemovalBehavior() {
      class="kw">return this.removalBehavior;
   }

   @Nonnull
   class="kw">public ValueType getValueType() {
      class="kw">return this.valueType;
   }

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

   @Nullable
   class="kw">public Map<DamageCause, ResistanceModifier[]> getDamageResistanceValues() {
      class="kw">return this.damageResistanceValues;
   }

   class="kw">public String getDeathMessageKey() {
      class="kw">return this.deathMessageKey;
   }

   @Nullable
   class="kw">public Condition[] getApplyConditions() {
      class="kw">return this.applyConditions;
   }

   @Nonnull
   class="kw">public com.hypixel.hytale.protocol.EntityEffect toPacket() {
      com.hypixel.hytale.protocol.EntityEffect var1 = this.cachedPacket == null ? null : this.cachedPacket.get();
      if (var1 != null) {
         class="kw">return var1;
      }

      com.hypixel.hytale.protocol.EntityEffect var2 = new com.hypixel.hytale.protocol.EntityEffect();
      var2.id = this.id;
      var2.name = this.name;
      if (this.applicationEffects != null) {
         var2.applicationEffects = this.applicationEffects.toPacket();
      }

      var2.worldRemovalSoundEventIndex = this.worldRemovalSoundEventIndex;
      var2.localRemovalSoundEventIndex = this.localRemovalSoundEventIndex != 0 ? this.localRemovalSoundEventIndex : this.worldRemovalSoundEventIndex;
      if (this.modelOverride != null) {
         var2.modelOverride = this.modelOverride.toPacket();
      }

      var2.duration = this.duration;
      var2.infinite = this.infinite;
      var2.debuff = this.debuff;
      var2.statusEffectIcon = this.statusEffectIcon;

      var2.overlapBehavior = class="kw">switch (this.overlapBehavior) {
         case EXTEND -> com.hypixel.hytale.protocol.OverlapBehavior.Extend;
         case OVERWRITE -> com.hypixel.hytale.protocol.OverlapBehavior.Overwrite;
         case IGNORE -> com.hypixel.hytale.protocol.OverlapBehavior.Ignore;
      };
      var2.damageCalculatorCooldown = this.damageCalculatorCooldown;
      var2.statModifiers = this.entityStats;
      var2.valueType = this.valueType;
      this.cachedPacket = new SoftReference<>(var2);
      class="kw">return var2;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "EntityEffect{id='"
         + this.id
         + "', name="
         + this.name
         + ", applicationEffects="
         + this.applicationEffects
         + ", damageCalculator="
         + this.damageCalculator
         + ", damageCalculatorCooldown="
         + this.damageCalculatorCooldown
         + ", damageEffects="
         + this.damageEffects
         + ", modelOverride="
         + this.modelOverride
         + ", modelChange='"
         + this.modelChange
         + "', unknownEntityStats="
         + this.unknownEntityStats
         + ", entityStats="
         + this.entityStats
         + ", valueType="
         + this.valueType
         + ", duration="
         + this.duration
         + ", overlapBehavior="
         + this.overlapBehavior
         + ", infinite="
         + this.infinite
         + ", debuff="
         + this.debuff
         + ", statusEffectIcon="
         + this.statusEffectIcon
         + ", locale="
         + this.locale
         + ", removalBehavior="
         + this.removalBehavior
         + ", invulnerable="
         + this.invulnerable
         + ", damageResistanceValues="
         + this.damageResistanceValues
         + "}";
   }
}