2013-08-28 08:32:01 +00:00
|
|
|
package thaumcraft.api.research;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import thaumcraft.api.aspects.AspectList;
|
2013-10-06 20:38:49 +00:00
|
|
|
import thaumcraft.api.crafting.CrucibleRecipe;
|
2013-08-28 08:32:01 +00:00
|
|
|
import thaumcraft.api.crafting.IArcaneRecipe;
|
2013-10-06 20:38:49 +00:00
|
|
|
import thaumcraft.api.crafting.InfusionRecipe;
|
2013-08-28 08:32:01 +00:00
|
|
|
|
|
|
|
public class ResearchPage {
|
|
|
|
public static enum PageType
|
|
|
|
{
|
|
|
|
TEXT,
|
2013-09-01 09:36:19 +00:00
|
|
|
TEXT_CONCEALED,
|
2013-08-28 08:32:01 +00:00
|
|
|
IMAGE,
|
|
|
|
CRUCIBLE_CRAFTING,
|
|
|
|
ARCANE_CRAFTING,
|
|
|
|
ASPECTS,
|
|
|
|
NORMAL_CRAFTING,
|
2013-10-06 20:38:49 +00:00
|
|
|
INFUSION_CRAFTING,
|
2013-08-28 08:32:01 +00:00
|
|
|
COMPOUND_CRAFTING
|
|
|
|
}
|
|
|
|
|
|
|
|
public PageType type = PageType.TEXT;
|
|
|
|
|
|
|
|
public String text=null;
|
2013-09-01 09:36:19 +00:00
|
|
|
public String research=null;
|
2013-08-28 08:32:01 +00:00
|
|
|
public ResourceLocation image=null;
|
|
|
|
public AspectList aspects=null;
|
|
|
|
public Object recipe=null;
|
|
|
|
public ItemStack recipeOutput=null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param text this can (but does not have to) be a reference to a localization variable, not the actual text.
|
|
|
|
*/
|
|
|
|
public ResearchPage(String text) {
|
|
|
|
this.type = PageType.TEXT;
|
|
|
|
this.text = text;
|
|
|
|
}
|
|
|
|
|
2013-09-01 09:36:19 +00:00
|
|
|
/**
|
|
|
|
* @param research this page will only be displayed if the player has discovered this research
|
|
|
|
* @param text this can (but does not have to) be a reference to a localization variable, not the actual text.
|
|
|
|
*/
|
|
|
|
public ResearchPage(String research, String text) {
|
|
|
|
this.type = PageType.TEXT_CONCEALED;
|
|
|
|
this.research = research;
|
|
|
|
this.text = text;
|
|
|
|
}
|
|
|
|
|
2013-08-28 08:32:01 +00:00
|
|
|
/**
|
|
|
|
* @param recipe a vanilla crafting recipe.
|
|
|
|
*/
|
|
|
|
public ResearchPage(IRecipe recipe) {
|
|
|
|
this.type = PageType.NORMAL_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
this.recipeOutput = recipe.getRecipeOutput();
|
|
|
|
}
|
|
|
|
|
2013-09-01 09:36:19 +00:00
|
|
|
/**
|
2013-10-06 20:38:49 +00:00
|
|
|
* @param recipe a collection of vanilla crafting recipes.
|
2013-09-01 09:36:19 +00:00
|
|
|
*/
|
|
|
|
public ResearchPage(IRecipe[] recipe) {
|
|
|
|
this.type = PageType.NORMAL_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
2013-10-06 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param recipe a collection of arcane crafting recipes.
|
|
|
|
*/
|
|
|
|
public ResearchPage(IArcaneRecipe[] recipe) {
|
|
|
|
this.type = PageType.ARCANE_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param recipe a collection of infusion crafting recipes.
|
|
|
|
*/
|
|
|
|
public ResearchPage(InfusionRecipe[] recipe) {
|
|
|
|
this.type = PageType.INFUSION_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
2013-09-01 09:36:19 +00:00
|
|
|
}
|
|
|
|
|
2013-08-28 08:32:01 +00:00
|
|
|
/**
|
|
|
|
* @param recipe a compound crafting recipe.
|
|
|
|
*/
|
|
|
|
public ResearchPage(List recipe) {
|
|
|
|
this.type = PageType.COMPOUND_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param recipe an arcane worktable crafting recipe.
|
|
|
|
*/
|
|
|
|
public ResearchPage(IArcaneRecipe recipe) {
|
|
|
|
this.type = PageType.ARCANE_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
this.recipeOutput = recipe.getRecipeOutput();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param recipe an alchemy crafting recipe.
|
|
|
|
*/
|
2013-10-06 20:38:49 +00:00
|
|
|
public ResearchPage(CrucibleRecipe recipe) {
|
2013-08-28 08:32:01 +00:00
|
|
|
this.type = PageType.CRUCIBLE_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
this.recipeOutput = recipe.recipeOutput;
|
|
|
|
}
|
|
|
|
|
2013-10-06 20:38:49 +00:00
|
|
|
/**
|
|
|
|
* @param recipe an infusion crafting recipe.
|
|
|
|
*/
|
|
|
|
public ResearchPage(InfusionRecipe recipe) {
|
|
|
|
this.type = PageType.INFUSION_CRAFTING;
|
|
|
|
this.recipe = recipe;
|
|
|
|
if (recipe.recipeOutput instanceof ItemStack) {
|
|
|
|
this.recipeOutput = (ItemStack) recipe.recipeOutput;
|
|
|
|
} else {
|
|
|
|
this.recipeOutput = recipe.recipeInput;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 08:32:01 +00:00
|
|
|
/**
|
|
|
|
* @param image
|
|
|
|
* @param caption this can (but does not have to) be a reference to a localization variable, not the actual text.
|
|
|
|
*/
|
|
|
|
public ResearchPage(ResourceLocation image, String caption) {
|
|
|
|
this.type = PageType.IMAGE;
|
|
|
|
this.image = image;
|
|
|
|
this.text = caption;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function should really not be called directly - used internally
|
|
|
|
*/
|
|
|
|
public ResearchPage(AspectList as) {
|
|
|
|
this.type = PageType.ASPECTS;
|
|
|
|
this.aspects = as;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns a localized text of the text field (if one exists). Returns the text field itself otherwise.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getTranslatedText() {
|
|
|
|
String ret="";
|
|
|
|
if (text != null) {
|
|
|
|
ret = StatCollector.translateToLocal(text);
|
|
|
|
if (ret.isEmpty()) ret = text;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|