Package org.cyclops.cyclopscore.item
Class DamageIndicatedItemComponent
java.lang.Object
org.cyclops.cyclopscore.item.DamageIndicatedItemComponent
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
FieldsModifier and TypeFieldDescriptionThe item class on which the behaviour will be added. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new DamageIndicatedItemComponent -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInformation(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.item.Item.TooltipContext context, List<net.minecraft.network.chat.Component> list, net.minecraft.world.item.TooltipFlag flag) Add information to the given list for the given item.voidfillDefaultCreativeTabEntries(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items, net.minecraft.world.level.material.Fluid fluid) Add the creative tab items.intgetDurability(net.minecraft.world.item.ItemStack itemStack) Get the displayed durability value for the givenItemStack.net.minecraft.network.chat.MutableComponentgetInfo(net.minecraft.world.item.ItemStack itemStack) Get hovering info for the givenItemStack.static net.minecraft.network.chat.MutableComponentgetInfo(net.neoforged.neoforge.fluids.FluidStack fluidStack, int amount, int capacity) Get hovering info for the given amount and capacity.
-
Field Details
-
item
The item class on which the behaviour will be added.
-
-
Constructor Details
-
DamageIndicatedItemComponent
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 givenItemStack.- 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.item.Item.TooltipContext context, 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- TheItemStackto add info for.context- The context 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 givenItemStack.- Parameters:
itemStack- TheItemStackto get the displayed damage for.- Returns:
- The displayed durability.
-