Fixed & Changed Reconstructor Recipe Handler a bit, restructured Reconstructor's main booklet page

This commit is contained in:
Ellpeck 2015-11-25 22:13:51 +01:00
parent f24f398656
commit 2e312db996
7 changed files with 100 additions and 55 deletions

View file

@ -26,8 +26,8 @@ import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.metalists.TheFoods;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
import ellpeck.actuallyadditions.util.Util;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@ -56,12 +56,12 @@ public class InitBooklet{
//Getting Started
chapterIntro = new BookletChapter("intro", entryGettingStarted, new ItemStack(InitItems.itemLexicon), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
new BookletChapter("bookTutorial", entryGettingStarted, new ItemStack(InitItems.itemLexicon), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook));
new BookletChapterReconstructor("crystals", entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.RECONSTRUCTOR_BASE_ENERGY_USE.getValue()), new PageTextOnly(2), new PagePicture(3, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(4), new PageCrafting(5, BlockCrafting.recipeAtomicReconstructor).setNoText(), new PageCrafting(6, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(7, new ItemStack(InitItems.itemColorLens)).setNoText()).setSpecial();
new BookletChapterReconstructor("crystals", entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.RECONSTRUCTOR_BASE_ENERGY_USE.getValue()), new PageTextOnly(2), new PagePicture(3, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(4), new PageCrafting(5, BlockCrafting.recipeAtomicReconstructor).setNoText(), new PageCrafting(6, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(7, ReconstructorRecipeHandler.recipeColorLens).setNoText()).setSpecial();
new BookletChapter("coalGen", entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).addTextReplacement("<rf>", ConfigIntValues.COAL_GEN_ENERGY_PRODUCED.getValue()));
new BookletChapter("craftingIngs", entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeStoneCase).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(7, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(8, ItemCrafting.recipeRing).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(11, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(12, ItemCrafting.recipeDough).setNoText(), new PageCrafting(13, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(14, BlockCrafting.recipeIronCase).setNoText()).setImportant();
//Miscellaneous
new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, new ItemStack(Blocks.soul_sand)).setNoText(), new PageReconstructor(3, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)), new PageReconstructor(4, new ItemStack(InitBlocks.blockTestifiBucksGreenWall)).setNoText()).setImportant();
new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, ReconstructorRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(3, ReconstructorRecipeHandler.recipeWhiteWall), new PageReconstructor(4, ReconstructorRecipeHandler.recipeGreenWall).setNoText(), new PageReconstructor(5, ReconstructorRecipeHandler.colorConversionRecipes)).setImportant();
new BookletChapter("bookStand", entryMisc, new ItemStack(InitBlocks.blockBookletStand), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBookStand));
new BookletChapter("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("<highest>", ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText());
new BookletChapter("cloud", entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText()).setSpecial();

View file

@ -45,9 +45,7 @@ public class BookletChapterReconstructor extends BookletChapter{
}
}.setNoText());
for(int i = 0; i < ReconstructorRecipeHandler.RECIPES_FOR_BOOKLET_PAGE; i++){
allPages.add(new PageReconstructor(allPages.size()+1, ReconstructorRecipeHandler.recipes.get(i).getFirstOutput()).setNoText());
}
allPages.add(new PageReconstructor(allPages.size()+1, ReconstructorRecipeHandler.mainPageRecipes).setNoText());
return allPages.toArray(new BookletPage[allPages.size()]);
}

View file

@ -140,7 +140,7 @@ public class PageCrafting extends BookletPage{
@Override
public void updateScreen(int ticksElapsed){
if(ticksElapsed%30 == 0){
if(ticksElapsed%15 == 0){
if(this.recipePos+1 >= this.recipes.length){
this.recipePos = 0;
}
@ -152,19 +152,23 @@ public class PageCrafting extends BookletPage{
@Override
public ItemStack[] getItemStacksForPage(){
if(this.recipes != null && this.recipes.length > 0 && this.recipes[0] != null){
ItemStack output = this.recipes[0].getRecipeOutput();
if(this.recipes != null){
ItemStack[] stacks = new ItemStack[this.recipes.length];
for(int i = 0; i < this.recipes.length; i++){
ItemStack output = this.recipes[i].getRecipeOutput();
if(output != null){
if(!this.arePageStacksWildcard){
return new ItemStack[]{output};
stacks[i] = output;
}
else{
ItemStack wildcardOutput = output.copy();
wildcardOutput.setItemDamage(Util.WILDCARD);
return new ItemStack[]{wildcardOutput};
stacks[i] = wildcardOutput;
}
}
}
return stacks;
}
return null;
}
}

View file

@ -21,27 +21,39 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
public class PageReconstructor extends BookletPage{
private final ItemStack result;
private final ItemStack input;
private ReconstructorRecipeHandler.Recipe[] recipes;
private int recipePos;
public PageReconstructor(int id, ItemStack result){
this(id, null, result);
public PageReconstructor(int id, ReconstructorRecipeHandler.Recipe... recipes){
super(id);
this.recipes = recipes;
this.addToPagesWithItemStackData();
}
public PageReconstructor(int id, ItemStack input, ItemStack result){
super(id);
this.result = result;
this.input = input;
this.addToPagesWithItemStackData();
public PageReconstructor(int id, ArrayList<ReconstructorRecipeHandler.Recipe> recipes){
this(id, recipes.toArray(new ReconstructorRecipeHandler.Recipe[recipes.size()]));
}
@Override
public void updateScreen(int ticksElapsed){
if(ticksElapsed%15 == 0){
if(this.recipePos+1 >= this.recipes.length){
this.recipePos = 0;
}
else{
this.recipePos++;
}
}
}
@Override
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
if(this.input != null || this.getInputForOutput(this.result) != null){
if(this.recipes[this.recipePos] != null){
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 188, 154, 60, 60);
}
@ -50,8 +62,8 @@ public class PageReconstructor extends BookletPage{
@SuppressWarnings("unchecked")
@Override
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
if(input == null){
ReconstructorRecipeHandler.Recipe recipe = this.recipes[this.recipePos];
if(recipe == null){
gui.mc.fontRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
}
else{
@ -59,7 +71,7 @@ public class PageReconstructor extends BookletPage{
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
//Lens
ItemStack lens = this.getRecipeForOutput(this.result).type.lens;
ItemStack lens = recipe.type.lens;
strg = lens == null ? StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".noLens") : lens.getItem().getItemStackDisplayName(lens);
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+75, 0);
}
@ -69,11 +81,11 @@ public class PageReconstructor extends BookletPage{
gui.mc.fontRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0);
}
if(input != null){
if(recipe != null){
renderItem(gui, new ItemStack(InitBlocks.blockAtomicReconstructor), gui.guiLeft+37+22, gui.guiTop+20+21, 1.0F);
for(int i = 0; i < 2; i++){
for(int x = 0; x < 2; x++){
ItemStack stack = x == 0 ? input : this.result;
ItemStack stack = x == 0 ? this.getInputForRecipe(recipe) : recipe.getFirstOutput();
if(stack.getItemDamage() == Util.WILDCARD){
stack.setItemDamage(0);
}
@ -96,30 +108,22 @@ public class PageReconstructor extends BookletPage{
@Override
public ItemStack[] getItemStacksForPage(){
return this.result == null ? new ItemStack[0] : new ItemStack[]{this.result};
}
private ReconstructorRecipeHandler.Recipe getRecipeForOutput(ItemStack output){
for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){
List<ItemStack> stacks = OreDictionary.getOres(recipe.output, false);
for(ItemStack stack : stacks){
if(output.isItemEqual(stack)){
return recipe;
}
if(this.recipes != null){
ItemStack[] stacks = new ItemStack[this.recipes.length];
for(int i = 0; i < this.recipes.length; i++){
stacks[i] = this.recipes[i].getFirstOutput();
}
return stacks;
}
return null;
}
private ItemStack getInputForOutput(ItemStack output){
ReconstructorRecipeHandler.Recipe recipe = this.getRecipeForOutput(output);
if(recipe != null){
List<ItemStack> inputs = OreDictionary.getOres(recipe.input, false);
if(inputs != null && !inputs.isEmpty() && inputs.get(0) != null){
ItemStack input = inputs.get(0).copy();
input.stackSize = 1;
return input;
}
private ItemStack getInputForRecipe(ReconstructorRecipeHandler.Recipe recipe){
List<ItemStack> stacks = OreDictionary.getOres(recipe.input, false);
if(stacks != null && !stacks.isEmpty() && stacks.get(0) != null){
ItemStack copy = stacks.get(0).copy();
copy.stackSize = 1;
return copy;
}
return null;
}

View file

@ -25,46 +25,76 @@ import java.util.Objects;
public class ReconstructorRecipeHandler{
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
public static final int RECIPES_FOR_BOOKLET_PAGE = 12;
public static ArrayList<Recipe> mainPageRecipes = new ArrayList<Recipe>();
public static Recipe recipeColorLens;
public static Recipe recipeSoulSand;
public static Recipe recipeGreenWall;
public static Recipe recipeWhiteWall;
public static ArrayList<Recipe> colorConversionRecipes = new ArrayList<Recipe>();
public static void init(){
//Crystal Blocks
addRecipe("blockRedstone", "blockCrystalRed", 400);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockLapis", "blockCrystalBlue", 400);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockDiamond", "blockCrystalLightBlue", 6000);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockEmerald", "blockCrystalGreen", 10000);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockCoal", "blockCrystalBlack", 600);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockIron", "blockCrystalWhite", 800);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
//Crystal Items
addRecipe("dustRedstone", "crystalRed", 40);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("gemLapis", "crystalBlue", 40);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("gemDiamond", "crystalLightBlue", 600);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("gemEmerald", "crystalGreen", 1000);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("coal", "crystalBlack", 60);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("ingotIron", "crystalWhite", 80);
mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
//Lenses
addRecipe("itemLens", "itemColorLens", 5000);
addRecipe("itemColorLens", "itemLens", 5000);
recipeColorLens = Util.GetRecipes.lastReconstructorRecipe();
//Misc
if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){
addRecipe("sand", "soulSand", 20000);
recipeSoulSand = Util.GetRecipes.lastReconstructorRecipe();
addRecipe("blockQuartz", "blockWhiteBrick", 10);
recipeWhiteWall = Util.GetRecipes.lastReconstructorRecipe();
addRecipe("blockQuartz", "blockGreenBrick", 10, LensType.COLOR);
recipeGreenWall = Util.GetRecipes.lastReconstructorRecipe();
//Colors
for(int i = 0; i < TheColoredLampColors.values().length-1; i++){
addRecipe("dye"+TheColoredLampColors.values()[i].name, "dye"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("wool"+TheColoredLampColors.values()[i].name, "wool"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("clay"+TheColoredLampColors.values()[i].name, "clay"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockGlass"+TheColoredLampColors.values()[i].name, "blockGlass"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
}
addRecipe("dye"+TheColoredLampColors.values()[15].name, "dye"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("wool"+TheColoredLampColors.values()[15].name, "wool"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("clay"+TheColoredLampColors.values()[15].name, "clay"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
addRecipe("blockGlass"+TheColoredLampColors.values()[15].name, "blockGlass"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR);
colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe());
}
}
@ -105,8 +135,10 @@ public class ReconstructorRecipeHandler{
public ItemStack getFirstOutput(){
List<ItemStack> stacks = OreDictionary.getOres(this.output, false);
if(stacks != null && !stacks.isEmpty()){
return stacks.get(0);
if(stacks != null && !stacks.isEmpty() && stacks.get(0) != null){
ItemStack stack = stacks.get(0).copy();
stack.stackSize = 1;
return stack;
}
return null;
}

View file

@ -12,6 +12,7 @@ package ellpeck.actuallyadditions.util;
import cpw.mods.fml.common.FMLCommonHandler;
import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry;
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.item.Item;
@ -61,6 +62,11 @@ public class Util{
public static class GetRecipes{
public static ReconstructorRecipeHandler.Recipe lastReconstructorRecipe(){
ArrayList<ReconstructorRecipeHandler.Recipe> list = ReconstructorRecipeHandler.recipes;
return list.get(list.size()-1);
}
public static CrusherRecipeRegistry.CrusherRecipe lastCrusherRecipe(){
ArrayList<CrusherRecipeRegistry.CrusherRecipe> list = CrusherRecipeRegistry.recipes;
return list.get(list.size()-1);

View file

@ -611,8 +611,9 @@ booklet.actuallyadditions.chapter.bookTutorial.text.2=<imp>The Buttons at the to
booklet.actuallyadditions.chapter.bookTutorial.text.3=If you, for some reason, want to craft this book again, just take a <item>piece of paper<r> and a <item>canola seed<r> which you can find randomly generated and craft them together!
booklet.actuallyadditions.chapter.miscReconstructor.name=Useful Reconstructor Recipes
booklet.actuallyadditions.chapter.miscReconstructor.text.1=There are some additional recipes for the <item>Atomic Reconstructor<r> that could be very useful to you. <n>These include <imp>decor blocks and items<r> as well as some <imp>useful conversions<r>. Flip through the following pages to see them all. <n><n>For example, by firing at <imp>Wool, Stained Clay, Stained Glass and Dye<r> with a <item>Lens: Color<r> multiple times, you can <imp>cycle through<r> all of their colors.
booklet.actuallyadditions.chapter.miscReconstructor.text.1=There are some additional recipes for the <item>Atomic Reconstructor<r> that could be very useful to you. <n>These include <imp>decor blocks and items<r> as well as some <imp>useful conversions<r>. Flip through the following pages to see them all.
booklet.actuallyadditions.chapter.miscReconstructor.text.3=The <item>Ethetic Quartz Blocks<r> are Quartz Blocks spruced up. <n>They can be crafted into <imp>stairs<r>, <imp>slabs<r> and <imp>walls<r> with the same recipes as cobblestone has. <n><n><i>No, not misspelled
booklet.actuallyadditions.chapter.miscReconstructor.text.5=By firing at <imp>Wool, Stained Clay, Stained Glass and Dye<r> with a <item>Lens: Color<r> multiple times, you can <imp>cycle through<r> all of their colors.
booklet.actuallyadditions.chapter.bookStand.name=Manual Stand
booklet.actuallyadditions.chapter.bookStand.text.1=The <item>Manual Stand<r> is a block that is supposed to mainly be used on <imp>Servers<r>. <n>You can, provided you are the person who <imp>placed it down<r>, set a page in the GUI that will <imp>open when someone else accesses it<r> by pressing the "Set Page"-button while being on the desired page. <n>The Manual Stand <imp>does not save<r> pages another player navigated to, meaing re-accessing the Stand will cause it to always <imp>end up on the page speficied<r> by the placer.