Class ItemStat<T extends StatValue>

java.lang.Object
dev.potota.itemstats.api.ItemStat<T>
Direct Known Subclasses:
ItemStat.Float, ItemStat.Integer, ItemStat.RegistryMapped

public abstract class ItemStat<T extends StatValue> extends Object
  • Field Details

    • AS_ID_CODEC

      public static final com.mojang.serialization.Codec<ItemStat<?>> AS_ID_CODEC
    • valueClass

      protected final Class<T extends StatValue> valueClass
    • id

      protected net.minecraft.resources.ResourceLocation id
  • Constructor Details

    • ItemStat

      protected ItemStat(net.minecraft.tags.TagKey<net.minecraft.world.item.Item> appliesTo, Class<T> valueClass)
  • Method Details

    • appliesTo

      public boolean appliesTo(net.minecraft.world.item.ItemStack stack) throws IllegalStateException
      Throws:
      IllegalStateException - if called before item tags are loaded (i.e. when not in a world)
    • appliesTo

      public boolean appliesTo(net.minecraft.world.item.Item item) throws IllegalStateException
      Throws:
      IllegalStateException - if called before item tags are loaded (i.e. when not in a world)
    • id

      public net.minecraft.resources.ResourceLocation id()
    • defaultValue

      public abstract T defaultValue()
    • format

      public net.minecraft.network.chat.MutableComponent format(StatValue value)
    • name

      public net.minecraft.network.chat.Component name()
    • castValue

      @NotNull protected T castValue(@NotNull @NotNull StatValue value)
    • getValue

      protected Optional<T> getValue(net.minecraft.world.item.ItemStack stack)
    • modifyStat

      protected void modifyStat(net.minecraft.world.item.ItemStack stack, UnaryOperator<T> modifier)