Interface ChemicalContaining


public interface ChemicalContaining
An interface for items that can contain a variable amount of any chemical in a stack. When an item that inherits ChemicalContaining is finished using by a player and the UseAnim of the item is UseAnim.DRINK or UseAnim.EAT, any chemicals in the item will be added to the player

Note: This interface is intended for items that have a variable amount of chemicals. For Items that will always have the same amount of chemicals, use ChemicalHolderBuilder.addChemical(ResourceLocation, float)

  • Method Summary

    Modifier and Type
    Method
    Description
    float
    getChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
    Obtains the amount of a specific chemical stored in a stack
    default float
    getConsumedChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
    Gets the amount of a specific chemical to actually be consumed upon item use.
  • Method Details

    • getChemicalContent

      float getChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
      Obtains the amount of a specific chemical stored in a stack
      Parameters:
      id - The ID representing the chemical
      stack - The itemStack
      Returns:
      Amount of the desired chemical stored in the stack
    • getConsumedChemicalContent

      default float getConsumedChemicalContent(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level)
      Gets the amount of a specific chemical to actually be consumed upon item use. Use this if the item is consumed in portions.
      Parameters:
      id - The ID representing the chemical
      stack - the item
      Returns:
      Amount of the desired chemical that should be consumed.