Class NBTIngredient
java.lang.Object
net.minecraft.world.item.crafting.Ingredient
net.neoforged.neoforge.common.crafting.NBTIngredient
Ingredient that matches the given items, performing either a
strict
or a partial NBT test.
Strict NBT ingredients will only match items that have exactly the provided tag, while partial ones will match if the item's tags contain all of the elements of the provided one, while allowing for additional elements to exist.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.item.crafting.Ingredient
Ingredient.ItemValue, Ingredient.TagValue, Ingredient.Value
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<NBTIngredient>
static final com.mojang.serialization.Codec<NBTIngredient>
private final boolean
Fields inherited from class net.minecraft.world.item.crafting.Ingredient
EMPTY, LIST_CODEC, LIST_CODEC_NONEMPTY, values, VANILLA_CODEC, VANILLA_CODEC_NONEMPTY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
NBTIngredient
(Set<Item> items, CompoundTag tag, boolean strict) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
areStacksEqual
(ItemStack left, ItemStack right) private static boolean
compareStacksWithNBT
(ItemStack left, ItemStack right) getTag()
boolean
isSimple()
boolean
isStrict()
static NBTIngredient
of
(boolean strict, CompoundTag nbt, ItemLike... items) Creates a new ingredient matching any item from the list, containing the given NBTstatic NBTIngredient
Creates a new ingredient matching the given item, containing the given NBTboolean
Returns iftrue
, this ingredient will be synchronized using its contents, as in vanilla, otherwise it will be synchronized via thecodec
.Methods inherited from class net.minecraft.world.item.crafting.Ingredient
equals, fromJson, fromNetwork, fromValues, getItems, getStackingIds, getType, getValues, isEmpty, of, of, of, of, of, test, toNetwork
-
Field Details
-
CODEC
-
CODEC_NONEMPTY
-
strict
private final boolean strict
-
-
Constructor Details
-
NBTIngredient
-
-
Method Details
-
areStacksEqual
- Overrides:
areStacksEqual
in classIngredient
-
synchronizeWithContents
public boolean synchronizeWithContents()Description copied from class:Ingredient
Returns iftrue
, this ingredient will be synchronized using its contents, as in vanilla, otherwise it will be synchronized via thecodec
.- Overrides:
synchronizeWithContents
in classIngredient
- Returns:
- if
true
, this ingredient will be synchronized using its contents, as in vanilla, otherwise it will be synchronized via thecodec
-
compareStacksWithNBT
-
of
Creates a new ingredient matching any item from the list, containing the given NBT -
of
Creates a new ingredient matching the given item, containing the given NBT -
getContainedItems
-
getTag
-
isSimple
public boolean isSimple()- Overrides:
isSimple
in classIngredient
-
isStrict
public boolean isStrict()
-