2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("CompostRecipeHandler.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
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
|
package ellpeck.actuallyadditions.nei;
|
|
|
|
|
|
|
|
|
|
import codechicken.lib.gui.GuiDraw;
|
|
|
|
|
import codechicken.nei.NEIServerUtils;
|
|
|
|
|
import codechicken.nei.PositionedStack;
|
|
|
|
|
import codechicken.nei.recipe.RecipeInfo;
|
|
|
|
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
|
|
|
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
|
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
|
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-08-01 00:40:29 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-05-20 22:39:43 +02:00
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
|
|
public class CompostRecipeHandler extends TemplateRecipeHandler{
|
|
|
|
|
|
2015-06-12 19:12:06 +02:00
|
|
|
|
public static final String NAME = "actuallyadditions.compost";
|
2015-05-20 22:39:43 +02:00
|
|
|
|
|
|
|
|
|
public CompostRecipeHandler(){
|
|
|
|
|
super();
|
|
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CachedCompostRecipe extends CachedRecipe{
|
|
|
|
|
|
|
|
|
|
public PositionedStack result;
|
|
|
|
|
public PositionedStack input;
|
|
|
|
|
public int chance;
|
|
|
|
|
|
|
|
|
|
public CachedCompostRecipe(ItemStack input, ItemStack result){
|
|
|
|
|
this.result = new PositionedStack(result, 67+32, 19);
|
|
|
|
|
this.input = new PositionedStack(input, 5+32, 19);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PositionedStack getIngredient(){
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PositionedStack getResult(){
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Class<? extends GuiContainer> getGuiClass(){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getRecipeName(){
|
2015-08-01 00:40:29 +02:00
|
|
|
|
return StringUtil.localize("container.nei."+NAME+".name");
|
2015-05-20 22:39:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void loadTransferRects(){
|
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results){
|
|
|
|
|
if(outputId.equals(NAME) && getClass() == CompostRecipeHandler.class){
|
|
|
|
|
arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())));
|
|
|
|
|
}
|
|
|
|
|
else super.loadCraftingRecipes(outputId, results);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void loadCraftingRecipes(ItemStack result){
|
|
|
|
|
if(NEIServerUtils.areStacksSameType(new ItemStack(InitItems.itemFertilizer), result)) arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
|
if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), ingredient)){
|
|
|
|
|
CachedCompostRecipe theRecipe = new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()));
|
|
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getGuiTexture(){
|
2015-08-14 11:33:06 +02:00
|
|
|
|
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png";
|
2015-05-20 22:39:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getOverlayIdentifier(){
|
|
|
|
|
return NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|