Interface IMemoryCodec<Data>

All Known Implementing Classes:
BooleanMemoryCodec, MemoryCodec, NumberMemoryCodec, StringMemoryCodec

@PowerNukkitXOnly @Since("1.19.63-r1") public interface IMemoryCodec<Data>
记忆编解码器
  • Method Details

    • getDecoder

      Function<CompoundTag,Data> getDecoder()
      获取记忆解码器,用于从CompoundTag读取持久化数据写入到实体记忆中

      Obtain a memory decoder for reading persistent data from Compound Tag and writing it to entity memory

      Returns:
      the decoder
    • getEncoder

      BiConsumer<Data,CompoundTag> getEncoder()
      获取记忆编码器,将实体记忆中的数据持久化进实体CompoundTag

      Get the memory encoder to persist the data in the entity memory into the entity Compound Tag

      Returns:
      the encoder
    • init

      void init(@Nullable Data data, EntityIntelligent entity)
      从实体记忆初始化实体,可以用于初始化实体DataFlag.

      Initialize the entity from the entity memory, which can be used to initialize the entity Data Flag.

      Parameters:
      data - the data
      entity - the entity
    • decode

      @Nullable default Data decode(CompoundTag tag)
    • encode

      default void encode(Data data, CompoundTag tag)