SelfHasEffectCondition class
Пакет: com.hypixel.hytale.server.npc.decisionmaker.core.conditions
Файл: com/hypixel/hytale/server/npc/decisionmaker/core/conditions/SelfHasEffectCondition.java
extends: SimpleCondition
Поля (3)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<SelfHasEffectCondition> |
CODEC |
|
Ref |
var6 |
|
EffectControllerComponent |
var7 |
Методы (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 SelfHasEffectCondition class="kw">extends SimpleCondition {
class="kw">public class="kw">static class="kw">final BuilderCodec<SelfHasEffectCondition> CODEC = BuilderCodec.builder(
SelfHasEffectCondition.class, SelfHasEffectCondition::new, ABSTRACT_CODEC
)
.documentation("A simple boolean condition that returns whether the NPC 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 SelfHasEffectCondition() {
}
@Override
class="kw">protected boolean evaluate(
int var1, @Nonnull ArchetypeChunk<EntityStore> var2, Ref<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4, EvaluationContext var5
) {
Ref var6 = var2.getReferenceTo(var1);
EffectControllerComponent var7 = var4.getComponent(var6, EffectControllerComponent.getComponentType());
class="kw">return var7 == null ? false : var7.hasEffect(this.entityEffectIndex);
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "SelfHasEffectCondition{entityEffectId='" + this.entityEffectId + "'} " + super.toString();
}
}