2015-06-12 19:12:06 +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;
|
2015-08-16 21:21:23 +02:00
|
|
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
2015-06-12 19:12:06 +02:00
|
|
|
import ellpeck.actuallyadditions.inventory.gui.GuiCoffeeMachine;
|
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
|
|
|
import ellpeck.actuallyadditions.items.ItemCoffee;
|
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class CoffeeMachineRecipeHandler extends TemplateRecipeHandler{
|
|
|
|
|
|
|
|
public static final String NAME = "actuallyadditions.coffee";
|
|
|
|
|
|
|
|
public CoffeeMachineRecipeHandler(){
|
|
|
|
super();
|
2015-07-29 11:03:17 +02:00
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 35, 3);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public class CachedCoffee extends CachedRecipe{
|
|
|
|
|
|
|
|
public PositionedStack cup;
|
|
|
|
public PositionedStack coffeeBeans;
|
|
|
|
public PositionedStack result;
|
|
|
|
public PositionedStack ingredientStack;
|
|
|
|
public String extraText;
|
2015-06-13 20:39:54 +02:00
|
|
|
public int maxAmp;
|
2015-06-12 19:12:06 +02:00
|
|
|
|
|
|
|
public CachedCoffee(ItemCoffee.Ingredient ingredient){
|
|
|
|
this.cup = new PositionedStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), 45, 39);
|
2015-08-16 21:21:23 +02:00
|
|
|
this.coffeeBeans = new PositionedStack(new ItemStack(InitItems.itemCoffeeBean, ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()), 2, 39);
|
2015-06-12 21:29:21 +02:00
|
|
|
this.ingredientStack = new PositionedStack(ingredient.ingredient.copy(), 90, 21);
|
2015-06-12 19:12:06 +02:00
|
|
|
this.setupResult(ingredient);
|
|
|
|
this.extraText = ingredient.getExtraText();
|
2015-06-13 20:39:54 +02:00
|
|
|
this.maxAmp = ingredient.maxAmplifier;
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setupResult(ItemCoffee.Ingredient ingredient){
|
|
|
|
ItemStack result = new ItemStack(InitItems.itemCoffee);
|
|
|
|
ItemCoffee.addEffectToStack(result, ingredient);
|
|
|
|
this.result = new PositionedStack(result.copy(), 45, 70);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<PositionedStack> getIngredients(){
|
|
|
|
ArrayList<PositionedStack> list = new ArrayList<PositionedStack>();
|
|
|
|
list.add(this.ingredientStack);
|
|
|
|
list.add(this.cup);
|
|
|
|
list.add(this.coffeeBeans);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PositionedStack getResult(){
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadTransferRects(){
|
2015-07-29 11:03:17 +02:00
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(20, 39, 20, 16), NAME));
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(64, 42, 23, 10), NAME));
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends GuiContainer> getGuiClass(){
|
|
|
|
return GuiCoffeeMachine.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRecipeName(){
|
2015-08-01 00:40:29 +02:00
|
|
|
return StringUtil.localize("container.nei."+NAME+".name");
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results){
|
|
|
|
if(outputId.equals(NAME) && getClass() == CoffeeMachineRecipeHandler.class){
|
|
|
|
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
|
|
|
for(ItemCoffee.Ingredient ingredient : ingredients){
|
|
|
|
arecipes.add(new CachedCoffee(ingredient));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else super.loadCraftingRecipes(outputId, results);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(ItemStack result){
|
|
|
|
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
|
|
|
for(ItemCoffee.Ingredient ingredient : ingredients){
|
|
|
|
if(result.getItem() instanceof ItemCoffee) arecipes.add(new CachedCoffee(ingredient));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
|
|
|
|
ArrayList<ItemCoffee.Ingredient> ingredients = ItemCoffee.ingredients;
|
|
|
|
for(ItemCoffee.Ingredient ingr : ingredients){
|
2015-06-12 21:29:21 +02:00
|
|
|
if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemCoffeeBean), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(ingr.ingredient.copy(), ingredient)){
|
2015-06-12 19:12:06 +02:00
|
|
|
CachedCoffee theRecipe = new CachedCoffee(ingr);
|
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredientStack), ingredient);
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getGuiTexture(){
|
|
|
|
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEICoffeeMachine.png";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBackground(int recipeIndex){
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
GuiDraw.changeTexture(getGuiTexture());
|
|
|
|
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 126, 88);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawExtras(int recipe){
|
2015-07-29 11:03:17 +02:00
|
|
|
drawProgressBar(20, 39, 126, 0, 21, 16, 48, 0);
|
2015-06-12 19:12:06 +02:00
|
|
|
drawProgressBar(63, 42, 125, 16, 24, 12, 48, 2);
|
|
|
|
|
|
|
|
CachedCoffee cache = (CachedCoffee)this.arecipes.get(recipe);
|
|
|
|
if(cache.extraText != null){
|
2015-08-01 00:40:29 +02:00
|
|
|
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
2015-06-13 20:39:54 +02:00
|
|
|
GuiDraw.drawString(cache.extraText, 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
|
|
|
}
|
2015-08-01 00:40:29 +02:00
|
|
|
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.shift"), 1, 75, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
2015-06-13 20:39:54 +02:00
|
|
|
|
|
|
|
if(cache.maxAmp > 0){
|
2015-08-01 00:40:29 +02:00
|
|
|
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.maxAmount") + ": " + cache.maxAmp, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getOverlayIdentifier(){
|
|
|
|
return NAME;
|
|
|
|
}
|
|
|
|
}
|