Package org.cyclops.cyclopscore.infobook
Class InfoBookParser
java.lang.Object
org.cyclops.cyclopscore.infobook.InfoBookParser
XML parser which will generate the infobook.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceInfoBookParser.IAppendixItemFactory<C extends net.minecraft.world.item.crafting.RecipeInput,R extends net.minecraft.world.item.crafting.Recipe<C>> static interfacestatic interfacestatic classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static InfoSectionbuildSection(IInfoBook infoBook, InfoSection parent, int childIndex, Element sectionElement, ModBase<?> modSection) protected static SectionAppendixcreateAppendix(IInfoBook infoBook, String type, net.minecraft.world.item.crafting.RecipeHolder<net.minecraft.world.item.crafting.Recipe<?>> recipe) protected static SectionAppendixcreateAppendix(IInfoBook infoBook, String type, Element node) protected static List<SectionAppendix> createAppendixes(IInfoBook infoBook, String factory, Element node) static net.neoforged.neoforge.fluids.FluidStackcreateFluidStack(Element node) Get the fluidstack represented by the given node.static net.neoforged.neoforge.fluids.FluidStackcreateFluidStackFromIngredient(Element ingredientNode) Get the fluidstack from the given ingredient node.static List<net.neoforged.neoforge.fluids.FluidStack> createFluidStacksFromIngredient(Element ingredientNode) Get a list of fluidstacks from the given ingredient node.static net.minecraft.world.item.crafting.IngredientcreateIngredient(Element node) Get the ingredient from the given node.static net.minecraft.world.item.crafting.IngredientcreateIngredientFromIngredient(Element ingredientNode) Get the ingredient from the given ingredient node.static net.minecraft.core.NonNullList<net.minecraft.world.item.crafting.Ingredient> createIngredientsFromIngredient(Element ingredientNode) Get a list of ingredients from the given ingredient node.static net.neoforged.neoforge.fluids.FluidStackcreateOptionalFluidStackFromIngredient(Element ingredientNode) Get the fluidstack from the given ingredient node.static List<net.neoforged.neoforge.fluids.FluidStack> createOptionalFluidStacksFromIngredient(Element ingredientNode) Get a list of fluidstacks from the given ingredient node.static net.minecraft.world.item.crafting.IngredientcreateOptionalIngredientFromIngredient(Element ingredientNode) Get the ingredient from the given ingredient node.static net.minecraft.core.NonNullList<net.minecraft.world.item.crafting.Ingredient> createOptionalIngredientsFromIngredient(Element ingredientNode) Get a list of ingredients from the given ingredient node.static net.minecraft.world.item.ItemStackcreateOptionalStackFromIngredient(Element ingredientNode) Get the item from the given ingredient node.static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> createOptionalStacksFromIngredient(Element ingredientNode) Get a list of stacks from the given ingredient node.protected static IRewardcreateReward(IInfoBook infoBook, String type, Element node) protected static InfoSectioncreateSection(IInfoBook infoBook, InfoSection parent, int childIndex, String type, String translationKey, ArrayList<String> paragraphs, List<SectionAppendix> appendixes, ArrayList<String> tagList, ModBase<?> mod) static net.minecraft.world.item.ItemStackcreateStack(Element node) Get the itemstack represented by the given node.static net.minecraft.world.item.ItemStackcreateStackFromIngredient(Element ingredientNode) Get the item from the given ingredient node.static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> createStacksFromIngredient(Element ingredientNode) Get a list of stacks from the given ingredient node.static intGet the index attribute value of the given node.protected static net.minecraft.resources.ResourceLocationstatic InfoSectioninitializeInfoBook(ModBase<?> mod, IInfoBook infoBook, String path, InfoSection parent) Initialize the given infobook from the given xml file.static <R> RinvalidAppendixExceptionThrowableOr(InfoBookParser.InvalidAppendixException.IThrower<R> thrower, R fallback) static voidregisterAppendixFactory(String name, InfoBookParser.IAppendixFactory factory) Register a new appendix factory.static voidregisterAppendixItemFactory(String name, InfoBookParser.IAppendixItemFactory factory) Register a new appendix item factory.static voidregisterAppendixListFactory(String name, InfoBookParser.IAppendixListFactory factory) Register a new appendix list factory.static <C extends net.minecraft.world.item.crafting.RecipeInput,R extends net.minecraft.world.item.crafting.Recipe<C>>
voidregisterAppendixRecipeFactories(net.minecraft.world.item.crafting.RecipeType<R> recipeType, InfoBookParser.IAppendixItemFactory<C, R> factory) Register new appendix recipe factories.static voidregisterAppendixRewardFactory(String name, IRewardFactory factory) Register a new reward factory.static voidregisterIgnoredFactory(String name) Indicate that the given factory should be ignored, this is useful when a target is somehow being disabled and no corresponding factory results should be shown.static voidregisterSectionFactory(String name, InfoBookParser.IInfoSectionFactory factory) Register a new info section factory.
-
Field Details
-
RECIPE_CONDITION_HANDLERS
-
-
Constructor Details
-
InfoBookParser
public InfoBookParser()
-
-
Method Details
-
getNodeResourceLocation
-
registerSectionFactory
Register a new info section factory.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.factory- The factory
-
registerIgnoredFactory
Indicate that the given factory should be ignored, this is useful when a target is somehow being disabled and no corresponding factory results should be shown.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.
-
registerAppendixFactory
Register a new appendix factory.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.factory- The factory
-
registerAppendixItemFactory
public static void registerAppendixItemFactory(String name, InfoBookParser.IAppendixItemFactory factory) Register a new appendix item factory.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.factory- The factory
-
registerAppendixRecipeFactories
public static <C extends net.minecraft.world.item.crafting.RecipeInput,R extends net.minecraft.world.item.crafting.Recipe<C>> void registerAppendixRecipeFactories(net.minecraft.world.item.crafting.RecipeType<R> recipeType, InfoBookParser.IAppendixItemFactory<C, R> factory) Register new appendix recipe factories.- Type Parameters:
C- The recipe inventory typeR- The recipe type- Parameters:
recipeType- The recipe typefactory- The factory
-
registerAppendixListFactory
public static void registerAppendixListFactory(String name, InfoBookParser.IAppendixListFactory factory) Register a new appendix list factory.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.factory- The factory
-
registerAppendixRewardFactory
Register a new reward factory.- Parameters:
name- The unique name for this factory, make sure to namespace this to your mod to avoid collisions.factory- The factory
-
getIndex
Get the index attribute value of the given node.- Parameters:
node- An element node.- Returns:
- The index attribute
-
createStack
public static net.minecraft.world.item.ItemStack createStack(Element node) throws InfoBookParser.InvalidAppendixException Get the itemstack represented by the given node. Interpreted attributes: amount: the stacksize, defaults to 1.- Parameters:
node- A node- Returns:
- An itemstack.
- Throws:
InfoBookParser.InvalidAppendixException- If the node was incorrectly structured.
-
createStacksFromIngredient
public static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> createStacksFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get a list of stacks from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The list of stacks.
- Throws:
InfoBookParser.InvalidAppendixException- If one of the item nodes was invalid
-
createStackFromIngredient
public static net.minecraft.world.item.ItemStack createStackFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get the item from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The stack.
- Throws:
InfoBookParser.InvalidAppendixException- If not exactly one item node was found or if the item node was invalid.
-
createOptionalStackFromIngredient
public static net.minecraft.world.item.ItemStack createOptionalStackFromIngredient(Element ingredientNode) Get the item from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The valid stack.
-
createOptionalStacksFromIngredient
public static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> createOptionalStacksFromIngredient(Element ingredientNode) Get a list of stacks from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The list of valid stacks.
-
createIngredient
public static net.minecraft.world.item.crafting.Ingredient createIngredient(Element node) throws InfoBookParser.InvalidAppendixException Get the ingredient from the given node.- Parameters:
node- A node- Returns:
- An ingredient
- Throws:
InfoBookParser.InvalidAppendixException- If the node was incorrectly structured.
-
createIngredientsFromIngredient
public static net.minecraft.core.NonNullList<net.minecraft.world.item.crafting.Ingredient> createIngredientsFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get a list of ingredients from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The list of ingredients.
- Throws:
InfoBookParser.InvalidAppendixException- If one of the item nodes was invalid
-
createOptionalIngredientFromIngredient
public static net.minecraft.world.item.crafting.Ingredient createOptionalIngredientFromIngredient(Element ingredientNode) Get the ingredient from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The valid ingredient.
-
createOptionalIngredientsFromIngredient
public static net.minecraft.core.NonNullList<net.minecraft.world.item.crafting.Ingredient> createOptionalIngredientsFromIngredient(Element ingredientNode) Get a list of ingredients from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The list of valid ingredients.
-
createIngredientFromIngredient
public static net.minecraft.world.item.crafting.Ingredient createIngredientFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get the ingredient from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'item' nodes.- Returns:
- The ingredient.
- Throws:
InfoBookParser.InvalidAppendixException- If not exactly one item node was found or if the item node was invalid.
-
createFluidStack
public static net.neoforged.neoforge.fluids.FluidStack createFluidStack(Element node) throws InfoBookParser.InvalidAppendixException Get the fluidstack represented by the given node. Interpreted attributes: amount: the fluid amount, defaults to 1000.- Parameters:
node- A node- Returns:
- A fluidstack.
- Throws:
InfoBookParser.InvalidAppendixException- If the node was incorrectly structured.
-
createFluidStacksFromIngredient
public static List<net.neoforged.neoforge.fluids.FluidStack> createFluidStacksFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get a list of fluidstacks from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'fluid' nodes.- Returns:
- The list of fluidstacks.
- Throws:
InfoBookParser.InvalidAppendixException- If one of the fluid nodes was invalid
-
createFluidStackFromIngredient
@Nullable public static net.neoforged.neoforge.fluids.FluidStack createFluidStackFromIngredient(Element ingredientNode) throws InfoBookParser.InvalidAppendixException Get the fluidstack from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'fluid' nodes.- Returns:
- The ingredient.
- Throws:
InfoBookParser.InvalidAppendixException- If not exactly one fluid node was found or if the fluid node was invalid.
-
createOptionalFluidStackFromIngredient
@Nullable public static net.neoforged.neoforge.fluids.FluidStack createOptionalFluidStackFromIngredient(Element ingredientNode) Get the fluidstack from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'fluid' nodes.- Returns:
- The valid fluidstack.
-
createOptionalFluidStacksFromIngredient
public static List<net.neoforged.neoforge.fluids.FluidStack> createOptionalFluidStacksFromIngredient(Element ingredientNode) Get a list of fluidstacks from the given ingredient node.- Parameters:
ingredientNode- A node that can contain 'fluid' nodes.- Returns:
- The list of valid fluidstacks.
-
invalidAppendixExceptionThrowableOr
public static <R> R invalidAppendixExceptionThrowableOr(InfoBookParser.InvalidAppendixException.IThrower<R> thrower, R fallback) -
initializeInfoBook
public static InfoSection initializeInfoBook(ModBase<?> mod, IInfoBook infoBook, String path, @Nullable InfoSection parent) Initialize the given infobook from the given xml file.- Parameters:
mod- The mod owning the sectioninfoBook- The infobook to register.path- The path to the xml file of the book.parent- The parent section.- Returns:
- The root of the infobook.
-
buildSection
protected static InfoSection buildSection(IInfoBook infoBook, InfoSection parent, int childIndex, Element sectionElement, ModBase<?> modSection) -
createSection
protected static InfoSection createSection(IInfoBook infoBook, InfoSection parent, int childIndex, String type, String translationKey, ArrayList<String> paragraphs, List<SectionAppendix> appendixes, ArrayList<String> tagList, ModBase<?> mod) -
createAppendix
protected static SectionAppendix createAppendix(IInfoBook infoBook, String type, Element node) throws InfoBookParser.InvalidAppendixException -
createAppendix
protected static SectionAppendix createAppendix(IInfoBook infoBook, String type, net.minecraft.world.item.crafting.RecipeHolder<net.minecraft.world.item.crafting.Recipe<?>> recipe) throws InfoBookParser.InvalidAppendixException -
createAppendixes
protected static List<SectionAppendix> createAppendixes(IInfoBook infoBook, String factory, Element node) throws InfoBookParser.InvalidAppendixException -
createReward
protected static IReward createReward(IInfoBook infoBook, String type, Element node) throws InfoBookParser.InvalidAppendixException
-