Package org.moddingx.libx.crafting
Class RecipeHelper
java.lang.Object
org.moddingx.libx.crafting.RecipeHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isItemValidInput
(net.minecraft.world.item.crafting.RecipeManager rm, net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.item.ItemStack stack) Gets whether anItemStack
is a valid input for at least one recipe of a given recipe type.static boolean
matches
(net.minecraft.world.item.crafting.Recipe<?> recipe, List<net.minecraft.world.item.ItemStack> stacks, boolean exactMatch) Checks whether all the ingredients of a recipe are present in a list ofItemStack
s.static JsonObject
serializeItemStack
(net.minecraft.world.item.ItemStack stack, boolean writeNBT) Serialises the givenItemStack
to json, so it can be read back byCraftingHelper.getItemStack(JsonObject, boolean)
.static List<net.minecraft.world.item.ItemStack>
Takes a list ofItemStacks
and stacks them up so multiple ItemStacks that can be stacked are transformed into one.
-
Constructor Details
-
RecipeHelper
public RecipeHelper()
-
-
Method Details
-
isItemValidInput
public static boolean isItemValidInput(net.minecraft.world.item.crafting.RecipeManager rm, net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.item.ItemStack stack) Gets whether anItemStack
is a valid input for at least one recipe of a given recipe type.- Parameters:
rm
- The recipe manager to use. You can get one from a world.
-
matches
public static boolean matches(net.minecraft.world.item.crafting.Recipe<?> recipe, List<net.minecraft.world.item.ItemStack> stacks, boolean exactMatch) Checks whether all the ingredients of a recipe are present in a list ofItemStack
s. This does not check that all ingredients are on different slots.- Parameters:
exactMatch
- When this is true this will return false if the stack list contains more items than the recipe requires.
-
stackUp
public static List<net.minecraft.world.item.ItemStack> stackUp(List<net.minecraft.world.item.ItemStack> stacks) Takes a list ofItemStacks
and stacks them up so multiple ItemStacks that can be stacked are transformed into one. -
serializeItemStack
public static JsonObject serializeItemStack(net.minecraft.world.item.ItemStack stack, boolean writeNBT) Serialises the givenItemStack
to json, so it can be read back byCraftingHelper.getItemStack(JsonObject, boolean)
.
-