Class ItemDataComponent<T extends ItemDataComponent<T>>

java.lang.Object
net.ixdarklord.coolcatcore.api.data.DataComponent<T>
net.ixdarklord.coolcatcore.api.data.ItemDataComponent<T>

public abstract class ItemDataComponent<T extends ItemDataComponent<T>> extends DataComponent<T>
A DataComponent kept in an item stack's NBT tag, under its id.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected net.minecraft.world.item.ItemStack
     

    Fields inherited from class net.ixdarklord.coolcatcore.api.data.DataComponent

    codec, id
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
     
    static <T extends ItemDataComponent<T>>
    T
    load(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec, Supplier<T> fallback)
    The data saved in a stack, bound to it, or fallback's (also bound) when there's none.
    void
    Writes the data into its stack's tag.
    setStack(net.minecraft.world.item.ItemStack stack)
     

    Methods inherited from class net.ixdarklord.coolcatcore.api.data.DataComponent

    getId, load, onClientUpdate, save

    Methods inherited from class java.lang.Object

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

    • stack

      protected net.minecraft.world.item.ItemStack stack
  • Constructor Details

    • ItemDataComponent

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

    • getStack

      public net.minecraft.world.item.ItemStack getStack()
    • setStack

      public T setStack(net.minecraft.world.item.ItemStack stack)
    • save

      public void save()
      Writes the data into its stack's tag.
    • load

      public static <T extends ItemDataComponent<T>> T load(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation id, com.mojang.serialization.Codec<T> codec, Supplier<T> fallback)
      The data saved in a stack, bound to it, or fallback's (also bound) when there's none.