2015-10-02 19:58:03 +02:00
|
|
|
/*
|
2015-12-30 22:02:15 +01:00
|
|
|
* This file ("NEIFurnaceDoubleRecipe.java") is part of the Actually Additions Mod for Minecraft.
|
2015-10-02 19:58:03 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-10-02 19:58:03 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-10-02 19:58:03 +02:00
|
|
|
*/
|
|
|
|
|
2015-12-30 22:02:15 +01:00
|
|
|
package de.ellpeck.actuallyadditions.nei;
|
2015-10-02 19:58:03 +02:00
|
|
|
|
|
|
|
import codechicken.lib.gui.GuiDraw;
|
|
|
|
import codechicken.nei.NEIServerUtils;
|
|
|
|
import codechicken.nei.PositionedStack;
|
|
|
|
import codechicken.nei.recipe.RecipeInfo;
|
|
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
2015-12-30 22:02:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.blocks.InitBlocks;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.BookletUtils;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.page.BookletPage;
|
|
|
|
import de.ellpeck.actuallyadditions.inventory.gui.GuiFurnaceDouble;
|
|
|
|
import de.ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.util.StringUtil;
|
2015-10-02 19:58:03 +02:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public class NEIFurnaceDoubleRecipe extends TemplateRecipeHandler implements INEIRecipeHandler{
|
2015-10-02 19:58:03 +02:00
|
|
|
|
|
|
|
public static final String NAME = "actuallyadditions.furnaceDouble";
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public NEIFurnaceDoubleRecipe(){
|
2015-10-02 19:58:03 +02:00
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-27 16:44:39 +01:00
|
|
|
public BookletPage getPageForInfo(int page){
|
|
|
|
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockFurnaceDouble));
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadTransferRects(){
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(51, 40, 24, 22), NAME));
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(101, 40, 24, 22), NAME));
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results){
|
2015-11-27 15:22:44 +01:00
|
|
|
if(outputId.equals(NAME) && getClass() == NEIFurnaceDoubleRecipe.class){
|
2015-10-02 19:58:03 +02:00
|
|
|
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
|
|
|
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
|
|
|
arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue()));
|
|
|
|
}
|
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
else{
|
|
|
|
super.loadCraftingRecipes(outputId, results);
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(ItemStack result){
|
|
|
|
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
|
|
|
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
2015-10-03 10:16:18 +02:00
|
|
|
if(NEIServerUtils.areStacksSameType(recipe.getValue(), result)){
|
2015-10-02 19:58:03 +02:00
|
|
|
arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue()));
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
Map<ItemStack, ItemStack> recipes = (Map<ItemStack, ItemStack>)FurnaceRecipes.smelting().getSmeltingList();
|
|
|
|
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()){
|
|
|
|
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.getKey(), ingredient)){
|
|
|
|
CachedFurn theRecipe = new CachedFurn(recipe.getKey(), recipe.getValue());
|
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient);
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
|
|
|
public String getGuiTexture(){
|
|
|
|
return ModUtil.MOD_ID_LOWER+":textures/gui/guiFurnaceDouble.png";
|
|
|
|
}
|
|
|
|
|
2015-10-02 19:58:03 +02:00
|
|
|
@Override
|
|
|
|
public String getOverlayIdentifier(){
|
|
|
|
return NAME;
|
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
|
|
|
public void drawExtras(int recipe){
|
|
|
|
drawProgressBar(51, 40, 176, 0, 24, 23, 48, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends GuiContainer> getGuiClass(){
|
|
|
|
return GuiFurnaceDouble.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBackground(int recipeIndex){
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
GuiDraw.changeTexture(getGuiTexture());
|
|
|
|
GuiDraw.drawTexturedModalRect(46, 20, 46, 20, 84, 70);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRecipeName(){
|
|
|
|
return StringUtil.localize("container.nei."+NAME+".name");
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:16:18 +02:00
|
|
|
public class CachedFurn extends CachedRecipe{
|
|
|
|
|
|
|
|
public PositionedStack ingredient;
|
|
|
|
public PositionedStack resultOne;
|
|
|
|
|
|
|
|
public CachedFurn(ItemStack in, ItemStack resultOne){
|
|
|
|
in.stackSize = 1;
|
|
|
|
this.ingredient = new PositionedStack(in, 51, 21);
|
|
|
|
this.resultOne = new PositionedStack(resultOne, 50, 69);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public PositionedStack getResult(){
|
|
|
|
return resultOne;
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public List<PositionedStack> getIngredients(){
|
|
|
|
return getCycledIngredients(cycleticks/48, Collections.singletonList(ingredient));
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|