Class DataComponent<T extends DataComponent<T>>

java.lang.Object
net.ixdarklord.coolcatcore.api.data.DataComponent<T>
Direct Known Subclasses:
ItemDataComponent

public abstract class DataComponent<T extends DataComponent<T>> extends Object
A piece of data saved with a Codec under its id in a CompoundTag. 1.20.1 has no data components: this is CoolCatLib's NBT-backed stand-in, stored as "<id>": {...}.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.mojang.serialization.Codec<T>
     
    protected final net.minecraft.resources.ResourceLocation
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    DataComponent(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.resources.ResourceLocation
     
    static <T> Optional<T>
    load(@Nullable net.minecraft.nbt.CompoundTag compoundTag, net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec)
    Reads the data saved under id in compoundTag, if there is any and it can be read.
     
    protected void
    save(net.minecraft.nbt.CompoundTag compoundTag)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      protected final net.minecraft.resources.ResourceLocation id
    • codec

      protected final com.mojang.serialization.Codec<T extends DataComponent<T>> codec
  • Constructor Details

    • DataComponent

      protected DataComponent(net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec)
  • Method Details

    • getId

      public net.minecraft.resources.ResourceLocation getId()
    • onClientUpdate

      public T onClientUpdate()
    • save

      protected void save(net.minecraft.nbt.CompoundTag compoundTag)
    • load

      public static <T> Optional<T> load(@Nullable @Nullable net.minecraft.nbt.CompoundTag compoundTag, net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec)
      Reads the data saved under id in compoundTag, if there is any and it can be read.