Class DamageIndicatedItemComponent

java.lang.Object
org.cyclops.cyclopscore.item.DamageIndicatedItemComponent

public class DamageIndicatedItemComponent extends Object
A component that has to be added for classes that want to implement the DamageIndicator behaviour. Items can add this component (Composite design-pattern) to any item that needs to have a damage indicator based on a custom value. Like for example the amount of energy left in an IC2 electrical wrench, or the amount of MJ's left in a redstone energy cell from Thermal Expansion. See DamageIndicatedItemFluidContainer for an example. This could be for example an Item or an ItemFluidContainer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The item class on which the behaviour will be added.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new DamageIndicatedItemComponent
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInformation(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, List<net.minecraft.network.chat.Component> list, net.minecraft.world.item.TooltipFlag flag)
    Add information to the given list for the given item.
    void
    fillDefaultCreativeTabEntries(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items, net.minecraft.world.level.material.Fluid fluid)
    Add the creative tab items.
    int
    getDurability(net.minecraft.world.item.ItemStack itemStack)
    Get the displayed durability value for the given ItemStack.
    net.minecraft.network.chat.MutableComponent
    getInfo(net.minecraft.world.item.ItemStack itemStack)
    Get hovering info for the given ItemStack.
    static net.minecraft.network.chat.MutableComponent
    getInfo(net.neoforged.neoforge.fluids.FluidStack fluidStack, int amount, int capacity)
    Get hovering info for the given amount and capacity.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • DamageIndicatedItemComponent

      public DamageIndicatedItemComponent(DamageIndicatedItemFluidContainer item)
      Create a new DamageIndicatedItemComponent
      Parameters:
      item - The item class on which the behaviour will be added.
  • Method Details

    • fillDefaultCreativeTabEntries

      public void fillDefaultCreativeTabEntries(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items, net.minecraft.world.level.material.Fluid fluid)
      Add the creative tab items.
      Parameters:
      items - The item list to add to.
      fluid - The fluid in the container that needs to be added.
    • getInfo

      public net.minecraft.network.chat.MutableComponent getInfo(net.minecraft.world.item.ItemStack itemStack)
      Get hovering info for the given ItemStack.
      Parameters:
      itemStack - The item stack to add the info for.
      Returns:
      The info for the item.
    • getInfo

      public static net.minecraft.network.chat.MutableComponent getInfo(net.neoforged.neoforge.fluids.FluidStack fluidStack, int amount, int capacity)
      Get hovering info for the given amount and capacity.
      Parameters:
      fluidStack - The fluid stack for this container, can be null.
      amount - The amount to show.
      capacity - The capacity to show.
      Returns:
      The info generated from the given parameters.
    • addInformation

      public void addInformation(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.Level world, List<net.minecraft.network.chat.Component> list, net.minecraft.world.item.TooltipFlag flag)
      Add information to the given list for the given item.
      Parameters:
      itemStack - The ItemStack to add info for.
      world - The player that will see the info.
      list - The info list where the info will be added.
      flag - the tooltip flag
    • getDurability

      public int getDurability(net.minecraft.world.item.ItemStack itemStack)
      Get the displayed durability value for the given ItemStack.
      Parameters:
      itemStack - The ItemStack to get the displayed damage for.
      Returns:
      The displayed durability.