cn.nukkit.entity.ai.memory.codec.MemoryCodec Maven / Gradle / Ivy
package cn.nukkit.entity.ai.memory.codec;
import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.entity.EntityIntelligent;
import cn.nukkit.nbt.tag.CompoundTag;
import lombok.Getter;
import javax.annotation.Nullable;
import java.util.function.BiConsumer;
import java.util.function.Function;
@PowerNukkitXOnly
@Since("1.19.63-r1")
@Getter
public class MemoryCodec implements IMemoryCodec {
private final Function decoder;
private final BiConsumer encoder;
@Nullable
private BiConsumer onInit = null;
public MemoryCodec(
Function decoder,
BiConsumer encoder
) {
this.decoder = decoder;
this.encoder = encoder;
}
public MemoryCodec onInit(BiConsumer onInit) {
this.onInit = onInit;
return this;
}
@Override
public void init(Data data, EntityIntelligent entity) {
if (onInit != null) {
onInit.accept(data, entity);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy