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
Modifier and TypeClassDescriptionstatic interface
static interface
InfoBookParser.IAppendixItemFactory<C extends net.minecraft.world.Container,
R extends net.minecraft.world.item.crafting.Recipe<C>> static interface
static interface
static class
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static InfoSection
buildSection
(IInfoBook infoBook, InfoSection parent, int childIndex, Element sectionElement, ModBase<?> modSection) protected static SectionAppendix
createAppendix
(IInfoBook infoBook, String type, net.minecraft.world.item.crafting.Recipe<?> recipe) protected static SectionAppendix
createAppendix
(IInfoBook infoBook, String type, Element node) protected static List<SectionAppendix>
createAppendixes
(IInfoBook infoBook, String factory, Element node) static net.minecraftforge.fluids.FluidStack
createFluidStack
(Element node) Get the fluidstack represented by the given node.static net.minecraftforge.fluids.FluidStack
createFluidStackFromIngredient
(Element ingredientNode) Get the fluidstack from the given ingredient node.static List<net.minecraftforge.fluids.FluidStack>
createFluidStacksFromIngredient
(Element ingredientNode) Get a list of fluidstacks from the given ingredient node.static net.minecraft.world.item.crafting.Ingredient
createIngredient
(Element node) Get the ingredient from the given node.static net.minecraft.world.item.crafting.Ingredient
createIngredientFromIngredient
(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.minecraftforge.fluids.FluidStack
createOptionalFluidStackFromIngredient
(Element ingredientNode) Get the fluidstack from the given ingredient node.static List<net.minecraftforge.fluids.FluidStack>
createOptionalFluidStacksFromIngredient
(Element ingredientNode) Get a list of fluidstacks from the given ingredient node.static net.minecraft.world.item.crafting.Ingredient
createOptionalIngredientFromIngredient
(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.ItemStack
createOptionalStackFromIngredient
(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 IReward
createReward
(IInfoBook infoBook, String type, Element node) 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) static net.minecraft.world.item.ItemStack
createStack
(Element node) Get the itemstack represented by the given node.static net.minecraft.world.item.ItemStack
createStackFromIngredient
(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 int
Get the index attribute value of the given node.protected static net.minecraft.resources.ResourceLocation
static InfoSection
initializeInfoBook
(ModBase<?> mod, IInfoBook infoBook, String path, InfoSection parent) Initialize the given infobook from the given xml file.static <R> R
invalidAppendixExceptionThrowableOr
(InfoBookParser.InvalidAppendixException.IThrower<R> thrower, R fallback) static void
registerAppendixFactory
(String name, InfoBookParser.IAppendixFactory factory) Register a new appendix factory.static void
registerAppendixItemFactory
(String name, InfoBookParser.IAppendixItemFactory factory) Register a new appendix item factory.static void
registerAppendixListFactory
(String name, InfoBookParser.IAppendixListFactory factory) Register a new appendix list factory.static <C extends net.minecraft.world.Container,
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 void
registerAppendixRewardFactory
(String name, IRewardFactory factory) Register a new reward factory.static void
registerIgnoredFactory
(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 void
registerSectionFactory
(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.Container,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.minecraftforge.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.minecraftforge.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.minecraftforge.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.minecraftforge.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.minecraftforge.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.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
-