2015-11-15 18:05:58 +01:00
|
|
|
/*
|
|
|
|
* This file ("AtomicReconstructorRecipeHandler.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.nei;
|
|
|
|
|
|
|
|
import codechicken.lib.gui.GuiDraw;
|
|
|
|
import codechicken.nei.PositionedStack;
|
|
|
|
import codechicken.nei.recipe.RecipeInfo;
|
|
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
|
|
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
2015-11-27 16:48:01 +01:00
|
|
|
import ellpeck.actuallyadditions.booklet.BookletUtils;
|
2015-11-15 18:39:05 +01:00
|
|
|
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
2015-11-15 18:05:58 +01:00
|
|
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
|
|
|
import ellpeck.actuallyadditions.util.ItemUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-11-15 18:39:05 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2015-11-15 18:05:58 +01:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
2015-11-15 18:39:05 +01:00
|
|
|
import java.util.List;
|
2015-11-15 18:05:58 +01:00
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public class NEIReconstructorRecipe extends TemplateRecipeHandler implements INEIRecipeHandler{
|
2015-11-15 18:05:58 +01:00
|
|
|
|
|
|
|
public static final String NAME = "actuallyadditions.reconstructor";
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public NEIReconstructorRecipe(){
|
2015-11-15 18:05:58 +01:00
|
|
|
super();
|
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-27 16:48:01 +01:00
|
|
|
public BookletPage getPageForInfo(int page){
|
|
|
|
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
|
2015-11-15 18:05:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRecipeName(){
|
|
|
|
return StringUtil.localize("container.nei."+NAME+".name");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadTransferRects(){
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results){
|
2015-11-27 15:22:44 +01:00
|
|
|
if(outputId.equals(NAME) && getClass() == NEIReconstructorRecipe.class){
|
2015-11-15 18:05:58 +01:00
|
|
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
|
|
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
2015-11-22 22:17:42 +01:00
|
|
|
arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.lens));
|
2015-11-15 18:05:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
super.loadCraftingRecipes(outputId, results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(ItemStack result){
|
|
|
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
|
|
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
2015-11-15 18:14:39 +01:00
|
|
|
if(ItemUtil.contains(OreDictionary.getOres(recipe.output, false), result, true)){
|
2015-11-22 22:17:42 +01:00
|
|
|
arecipes.add(new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.lens));
|
2015-11-15 18:05:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
ArrayList<ReconstructorRecipeHandler.Recipe> recipes = ReconstructorRecipeHandler.recipes;
|
|
|
|
for(ReconstructorRecipeHandler.Recipe recipe : recipes){
|
2015-11-15 18:14:39 +01:00
|
|
|
if(ItemUtil.contains(OreDictionary.getOres(recipe.input, false), ingredient, true)){
|
2015-11-22 22:17:42 +01:00
|
|
|
CachedReconstructorRecipe theRecipe = new CachedReconstructorRecipe(recipe.input, recipe.output, recipe.type.lens);
|
2015-11-15 18:05:58 +01:00
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getGuiTexture(){
|
2015-11-15 18:39:05 +01:00
|
|
|
return ModUtil.MOD_ID_LOWER+":textures/gui/guiNEIAtomicReconstructor.png";
|
2015-11-15 18:05:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getOverlayIdentifier(){
|
|
|
|
return NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends GuiContainer> getGuiClass(){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBackground(int recipeIndex){
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
GuiDraw.changeTexture(getGuiTexture());
|
|
|
|
GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60);
|
|
|
|
}
|
|
|
|
|
2015-11-15 18:39:05 +01:00
|
|
|
@Override
|
|
|
|
public void drawForeground(int recipe){
|
|
|
|
if(Minecraft.getMinecraft().currentScreen != null){
|
|
|
|
BookletPage.renderItem(Minecraft.getMinecraft().currentScreen, new ItemStack(InitBlocks.blockAtomicReconstructor), 32+34, 19, 1.0F);
|
|
|
|
}
|
2015-11-22 20:23:54 +01:00
|
|
|
|
|
|
|
CachedReconstructorRecipe cache = (CachedReconstructorRecipe)this.arecipes.get(recipe);
|
2015-11-22 22:17:42 +01:00
|
|
|
GuiDraw.drawString(cache.lens == null ? StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".noLens") : cache.lens.getItem().getItemStackDisplayName(cache.lens), 10, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
2015-11-15 18:39:05 +01:00
|
|
|
}
|
|
|
|
|
2015-11-15 18:05:58 +01:00
|
|
|
@Override
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CachedReconstructorRecipe extends CachedRecipe{
|
|
|
|
|
|
|
|
public PositionedStack result;
|
|
|
|
public PositionedStack input;
|
2015-11-22 22:17:42 +01:00
|
|
|
public ItemStack lens;
|
2015-11-15 18:05:58 +01:00
|
|
|
|
2015-11-22 22:17:42 +01:00
|
|
|
public CachedReconstructorRecipe(String input, String result, ItemStack lens){
|
2015-11-15 18:39:05 +01:00
|
|
|
List<ItemStack> outputs = OreDictionary.getOres(result, false);
|
|
|
|
for(ItemStack ore : outputs){
|
|
|
|
ore.stackSize = 1;
|
|
|
|
}
|
|
|
|
List<ItemStack> inputs = OreDictionary.getOres(input, false);
|
|
|
|
for(ItemStack ore : inputs){
|
|
|
|
ore.stackSize = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.result = new PositionedStack(outputs, 67+32, 19);
|
|
|
|
this.input = new PositionedStack(inputs, 5+32, 19);
|
2015-11-22 20:23:54 +01:00
|
|
|
this.lens = lens;
|
2015-11-15 18:05:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PositionedStack getResult(){
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PositionedStack getIngredient(){
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|