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
Modifier and TypeFieldDescriptionnet.minecraftforge.fluids.capability.ItemFluidContainer
The item class on which the behaviour will be added. -
Constructor Summary
ConstructorDescriptionDamageIndicatedItemComponent
(net.minecraftforge.fluids.capability.ItemFluidContainer item) Create a new DamageIndicatedItemComponent -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 givenItemStack
.net.minecraft.network.chat.MutableComponent
getInfo
(net.minecraft.world.item.ItemStack itemStack) Get hovering info for the givenItemStack
.static net.minecraft.network.chat.MutableComponent
getInfo
(net.minecraftforge.fluids.FluidStack fluidStack, int amount, int capacity) Get hovering info for the given amount and capacity.
-
Field Details
-
item
public net.minecraftforge.fluids.capability.ItemFluidContainer itemThe item class on which the behaviour will be added.
-
-
Constructor Details
-
DamageIndicatedItemComponent
public DamageIndicatedItemComponent(net.minecraftforge.fluids.capability.ItemFluidContainer 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 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.minecraftforge.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
- TheItemStack
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 givenItemStack
.- Parameters:
itemStack
- TheItemStack
to get the displayed damage for.- Returns:
- The displayed durability.
-