Class FluidIngredient

java.lang.Object
net.minecraft.world.item.crafting.Ingredient
me.desht.pneumaticcraft.api.crafting.ingredient.FluidIngredient
All Implemented Interfaces:
Predicate<net.minecraft.world.item.ItemStack>
Direct Known Subclasses:
CompoundFluidIngredient

public class FluidIngredient extends net.minecraft.world.item.crafting.Ingredient
A fluid ingredient matcher, with fluid tag support. Can also match items; it checks if the item contains the desired fluid.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested classes/interfaces inherited from class net.minecraft.world.item.crafting.Ingredient

    net.minecraft.world.item.crafting.Ingredient.ItemValue, net.minecraft.world.item.crafting.Ingredient.TagValue, net.minecraft.world.item.crafting.Ingredient.Value
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final FluidIngredient
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    FluidIngredient(List<net.minecraft.world.level.material.Fluid> fluids, int amount, net.minecraft.resources.ResourceLocation fluidId, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTagKey, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    protected Collection<net.minecraft.world.level.material.Fluid>
     
    List<net.minecraftforge.fluids.FluidStack>
     
    net.minecraft.world.item.ItemStack[]
     
    net.minecraftforge.common.crafting.IIngredientSerializer<? extends net.minecraft.world.item.crafting.Ingredient>
     
    boolean
     
    of(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.resources.ResourceLocation fluidId)
    Create a fluid ingredient from the given fluid registry ID.
    of(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag)
    Create a fluid ingredient from the given fluid tag
    of(int amount, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.world.level.material.Fluid... fluids)
    Create a fluid ingredient from the given list of fluids
    of(int amount, net.minecraft.resources.ResourceLocation fluidId)
    Create a fluid ingredient from the given fluid registry ID.
    of(int amount, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag)
    Create a fluid ingredient from the given fluid tag
    of(int amount, net.minecraft.world.level.material.Fluid... fluids)
    Create a fluid ingredient from the given list of fluids
    of(net.minecraftforge.fluids.FluidStack fluidStack)
    Create a fluid ingredient from the given FluidStack.
    Create a fluid ingredient from the given stream of other fluid ingredients.
    boolean
    test(net.minecraft.world.item.ItemStack stack)
    Test the given item against this ingredient.
    boolean
    testFluid(net.minecraft.world.level.material.Fluid fluid)
    Test the given fluid against this ingredient.
    boolean
    testFluid(net.minecraftforge.fluids.FluidStack fluidStack)
    Test the given fluid stack against this ingredient.
    com.google.gson.JsonElement
     

    Methods inherited from class net.minecraft.world.item.crafting.Ingredient

    checkInvalidation, fromJson, fromNetwork, fromValues, getStackingIds, invalidate, invalidateAll, isSimple, isVanilla, markValid, merge, of, of, of, of, of, toNetwork, valueFromJson

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Predicate

    and, negate, or
  • Field Details

  • Constructor Details

    • FluidIngredient

      protected FluidIngredient(List<net.minecraft.world.level.material.Fluid> fluids, int amount, net.minecraft.resources.ResourceLocation fluidId, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTagKey, net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT)
  • Method Details

    • of

      public static FluidIngredient of(net.minecraftforge.fluids.FluidStack fluidStack)
      Create a fluid ingredient from the given FluidStack. If the FluidStack has any NBT, this will also be required as an ingredient match, in a non-fuzzy way (exact match of all fields required).
      Parameters:
      fluidStack - the fluidstack to match against
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.world.level.material.Fluid... fluids)
      Create a fluid ingredient from the given list of fluids
      Parameters:
      amount - the amount, in mB
      nbt - the NBT, or null for no NBT matching
      fuzzyNBT - true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.
      fluids - the list of fluids
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, net.minecraft.world.level.material.Fluid... fluids)
      Create a fluid ingredient from the given list of fluids
      Parameters:
      amount - the amount, in mB
      fluids - the list of fluids
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag)
      Create a fluid ingredient from the given fluid tag
      Parameters:
      amount - the amount, in mB
      nbt - the NBT, or null for no NBT matching
      fuzzyNBT - true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.
      fluidTag - the fluid tag
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, net.minecraft.tags.TagKey<net.minecraft.world.level.material.Fluid> fluidTag)
      Create a fluid ingredient from the given fluid tag
      Parameters:
      amount - the amount, in mB
      fluidTag - the fluid tag
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, @Nullable net.minecraft.nbt.CompoundTag nbt, boolean fuzzyNBT, net.minecraft.resources.ResourceLocation fluidId)
      Create a fluid ingredient from the given fluid registry ID. Use this if the fluid might not exist at runtime (e.g. it's from another mod which may or may not be loaded). If the fluid does not exist at runtime, this ingredient will never match anything.
      Parameters:
      amount - the amount, in mB
      nbt - the NBT, or null for no NBT matching
      fuzzyNBT - true for a fuzzy match (only fields in the ingredient will be matched), false for an exact match. Ignored if the nbt parameter is null.
      fluidId - the fluid's registry ID
      Returns:
      the fluid ingredient
    • of

      public static FluidIngredient of(int amount, net.minecraft.resources.ResourceLocation fluidId)
      Create a fluid ingredient from the given fluid registry ID. Use this if the fluid might not exist at runtime (e.g. it's from another mod which may or may not be loaded). If the fluid does not exist at runtime, this ingredient will never match anything.
      Parameters:
      amount - the amount, in mB
      fluidId - the fluid's registry ID
      Returns:
      the fluid ingredient
    • ofFluidStream

      public static FluidIngredient ofFluidStream(Stream<FluidIngredient> stream)
      Create a fluid ingredient from the given stream of other fluid ingredients. This new compound ingredient is effectively a logical OR of all the constituent ingredients.
      Parameters:
      stream - a stream of ingredients
      Returns:
      the fluid ingredient
      API Note:
      this method is called "ofFluidStream" rather than "of" to avoid confusion with Ingredient.of(Stream)
    • getFluidList

      protected Collection<net.minecraft.world.level.material.Fluid> getFluidList()
    • isEmpty

      public boolean isEmpty()
      Overrides:
      isEmpty in class net.minecraft.world.item.crafting.Ingredient
    • test

      public boolean test(@Nullable net.minecraft.world.item.ItemStack stack)
      Test the given item against this ingredient. The item must be a fluid container item (providing the CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY capability) containing fluid which matches this ingredient, AND it must be a container item (IForgeItem.hasContainerItem(ItemStack) must return true).
      Specified by:
      test in interface Predicate<net.minecraft.world.item.ItemStack>
      Overrides:
      test in class net.minecraft.world.item.crafting.Ingredient
      Parameters:
      stack - the itemstack to test
      Returns:
      true if the fluid in the given itemstack matches this ingredient
    • getItems

      public net.minecraft.world.item.ItemStack[] getItems()
      Overrides:
      getItems in class net.minecraft.world.item.crafting.Ingredient
    • testFluid

      public boolean testFluid(net.minecraftforge.fluids.FluidStack fluidStack)
      Test the given fluid stack against this ingredient. The fluid must match, and the fluid stack amount must be at least as large. In addition, if the ingredient specifies any NBT, that must also match.
      Parameters:
      fluidStack - the fluid stack to test
      Returns:
      true if the fluid stack matches, false otherwise
    • testFluid

      public boolean testFluid(net.minecraft.world.level.material.Fluid fluid)
      Test the given fluid against this ingredient. Just a fluid match; no amount or NBT matching is done.
      Parameters:
      fluid - the fluid to test
      Returns:
      true if the fluid matches, false otherwise
    • toJson

      public com.google.gson.JsonElement toJson()
      Overrides:
      toJson in class net.minecraft.world.item.crafting.Ingredient
    • getSerializer

      public net.minecraftforge.common.crafting.IIngredientSerializer<? extends net.minecraft.world.item.crafting.Ingredient> getSerializer()
      Overrides:
      getSerializer in class net.minecraft.world.item.crafting.Ingredient
    • getAmount

      public int getAmount()
    • getFluidStacks

      public List<net.minecraftforge.fluids.FluidStack> getFluidStacks()