2015-10-02 19:58:03 +02:00
|
|
|
/*
|
2015-12-30 22:02:15 +01:00
|
|
|
* This file ("NEICoffeeMachineRecipe.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
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.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;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
2016-01-05 14:57:50 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeBrewing;
|
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-10-02 19:58:03 +02:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2016-01-08 15:21:05 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-10-02 19:58:03 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public class NEICoffeeMachineRecipe extends TemplateRecipeHandler implements INEIRecipeHandler{
|
2015-10-02 19:58:03 +02:00
|
|
|
|
|
|
|
public static final String NAME = "actuallyadditions.coffee";
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public NEICoffeeMachineRecipe(){
|
2015-10-02 19:58:03 +02:00
|
|
|
super();
|
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 35, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-27 16:44:39 +01:00
|
|
|
public BookletPage getPageForInfo(int page){
|
|
|
|
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockCoffeeMachine));
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadTransferRects(){
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(20, 39, 20, 16), NAME));
|
|
|
|
transferRects.add(new RecipeTransferRect(new Rectangle(64, 42, 23, 10), NAME));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(String outputId, Object... results){
|
2015-11-27 15:22:44 +01:00
|
|
|
if(outputId.equals(NAME) && getClass() == NEICoffeeMachineRecipe.class){
|
2016-01-05 04:47:35 +01:00
|
|
|
List<CoffeeIngredient> ingredients = ActuallyAdditionsAPI.coffeeMachineIngredients;
|
|
|
|
for(CoffeeIngredient ingredient : ingredients){
|
2015-10-02 19:58:03 +02:00
|
|
|
arecipes.add(new CachedCoffee(ingredient));
|
|
|
|
}
|
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
else{
|
|
|
|
super.loadCraftingRecipes(outputId, results);
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadCraftingRecipes(ItemStack result){
|
2016-01-05 04:47:35 +01:00
|
|
|
List<CoffeeIngredient> ingredients = ActuallyAdditionsAPI.coffeeMachineIngredients;
|
|
|
|
for(CoffeeIngredient ingredient : ingredients){
|
2015-10-03 10:16:18 +02:00
|
|
|
if(result.getItem() instanceof ItemCoffee){
|
|
|
|
arecipes.add(new CachedCoffee(ingredient));
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
List<CoffeeIngredient> ingredients = ActuallyAdditionsAPI.coffeeMachineIngredients;
|
|
|
|
for(CoffeeIngredient ingr : ingredients){
|
2015-10-02 19:58:03 +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)){
|
|
|
|
CachedCoffee theRecipe = new CachedCoffee(ingr);
|
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredientStack), ingredient);
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getGuiTexture(){
|
2015-10-03 10:16:18 +02:00
|
|
|
return ModUtil.MOD_ID_LOWER+":textures/gui/guiNEICoffeeMachine.png";
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public String getOverlayIdentifier(){
|
|
|
|
return NAME;
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawExtras(int recipe){
|
|
|
|
drawProgressBar(20, 39, 126, 0, 21, 16, 48, 0);
|
|
|
|
drawProgressBar(63, 42, 125, 16, 24, 12, 48, 2);
|
|
|
|
|
|
|
|
CachedCoffee cache = (CachedCoffee)this.arecipes.get(recipe);
|
|
|
|
if(cache.extraText != null){
|
2015-10-03 10:16:18 +02:00
|
|
|
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special")+":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
2015-10-02 19:58:03 +02:00
|
|
|
GuiDraw.drawString(cache.extraText, 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
|
|
|
}
|
|
|
|
GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.shift"), 1, 75, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
|
|
|
|
|
|
|
if(cache.maxAmp > 0){
|
2015-10-03 10:16:18 +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-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public Class<? extends GuiContainer> getGuiClass(){
|
|
|
|
return GuiCoffeeMachine.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawBackground(int recipeIndex){
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2015-10-03 10:19:40 +02:00
|
|
|
GuiDraw.changeTexture(getGuiTexture());
|
|
|
|
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 126, 88);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getRecipeName(){
|
|
|
|
return StringUtil.localize("container.nei."+NAME+".name");
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
|
|
|
|
public class CachedCoffee extends CachedRecipe{
|
|
|
|
|
|
|
|
public PositionedStack cup;
|
|
|
|
public PositionedStack coffeeBeans;
|
|
|
|
public PositionedStack result;
|
|
|
|
public PositionedStack ingredientStack;
|
|
|
|
public String extraText;
|
|
|
|
public int maxAmp;
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
public CachedCoffee(CoffeeIngredient ingredient){
|
2015-10-03 10:16:18 +02:00
|
|
|
this.cup = new PositionedStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), 45, 39);
|
2015-11-28 19:02:01 +01:00
|
|
|
this.coffeeBeans = new PositionedStack(new ItemStack(InitItems.itemCoffeeBean, TileEntityCoffeeMachine.CACHE_USE), 2, 39);
|
2015-10-03 10:16:18 +02:00
|
|
|
this.ingredientStack = new PositionedStack(ingredient.ingredient.copy(), 90, 21);
|
|
|
|
this.setupResult(ingredient);
|
|
|
|
this.extraText = ingredient.getExtraText();
|
|
|
|
this.maxAmp = ingredient.maxAmplifier;
|
|
|
|
}
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
public void setupResult(CoffeeIngredient ingredient){
|
2015-10-03 10:16:18 +02:00
|
|
|
ItemStack result = new ItemStack(InitItems.itemCoffee);
|
2016-01-05 04:47:35 +01:00
|
|
|
CoffeeBrewing.addEffectToStack(result, ingredient);
|
2015-10-03 10:16:18 +02:00
|
|
|
this.result = new PositionedStack(result.copy(), 45, 70);
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
|
|
|
public PositionedStack getResult(){
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:16:18 +02:00
|
|
|
@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;
|
|
|
|
}
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|