TargetHasEffectCondition class

Пакет: com.hypixel.hytale.server.npc.decisionmaker.core.conditions

Файл: com/hypixel/hytale/server/npc/decisionmaker/core/conditions/TargetHasEffectCondition.java

extends: SimpleCondition

Поля (2)

МодификаторыТипИмя
final BuilderCodec<TargetHasEffectCondition> CODEC
EffectControllerComponent var6

Методы (1)

МодификаторыВозвратСигнатура
if if(var0.entityEffectId != null)

Исходный код

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

class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.server.core.asset.type.entityeffect.config.EntityEffect;
class="kw">import com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.decisionmaker.core.EvaluationContext;
class="kw">import com.hypixel.hytale.server.npc.decisionmaker.core.conditions.base.SimpleCondition;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class TargetHasEffectCondition class="kw">extends SimpleCondition {
   class="kw">public class="kw">static class="kw">final BuilderCodec<TargetHasEffectCondition> CODEC = BuilderCodec.builder(
         TargetHasEffectCondition.class, TargetHasEffectCondition::new, ABSTRACT_CODEC
      )
      .documentation("A simple boolean condition that returns whether the target entity has a specific active entity effect.")
      .<String>appendInherited(
         new KeyedCodec<>("EffectId", Codec.STRING),
         (var0, var1) -> var0.entityEffectId = var1,
         var0 -> var0.entityEffectId,
         (var0, var1) -> var0.entityEffectId = var1.entityEffectId
      )
      .addValidator(EntityEffect.VALIDATOR_CACHE.getValidator())
      .documentation("The entity effect to check for.")
      .add()
      .afterDecode(var0 -> {
         if (var0.entityEffectId != null) {
            var0.entityEffectIndex = EntityEffect.getAssetMap().getIndex(var0.entityEffectId);
         }
      })
      .build();
   @Nullable
   class="kw">private String entityEffectId;
   class="kw">private int entityEffectIndex;

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

   @Override
   class="kw">protected boolean evaluate(
      int var1, ArchetypeChunk<EntityStore> var2, @Nullable Ref<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4, EvaluationContext var5
   ) {
      if (var3 != null && var3.isValid()) {
         EffectControllerComponent var6 = var4.getComponent(var3, EffectControllerComponent.getComponentType());
         class="kw">return var6 == null ? false : var6.hasEffect(this.entityEffectIndex);
      } else {
         class="kw">return false;
      }
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "TargetHasEffectCondition{entityEffectId='" + this.entityEffectId + "'} " + super.toString();
   }
}