2015-10-02 19:58:03 +02:00
|
|
|
/*
|
|
|
|
* This file ("HairyBallRecipeHandler.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-11-02 20:55:19 +01:00
|
|
|
* © 2015 Ellpeck
|
2015-10-02 19:58:03 +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-12-17 22:18:37 +01:00
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
2015-10-02 19:58:03 +02:00
|
|
|
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
|
|
|
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;
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public class NEIHairyBallRecipe extends TemplateRecipeHandler implements INEIRecipeHandler{
|
2015-10-02 19:58:03 +02:00
|
|
|
|
|
|
|
public static final String NAME = "actuallyadditions.ballOfHair";
|
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public NEIHairyBallRecipe(){
|
2015-10-02 19:58:03 +02:00
|
|
|
super();
|
|
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-04 15:24:11 +02:00
|
|
|
public ItemStack getStackForInfo(int page){
|
2015-12-17 22:18:37 +01:00
|
|
|
return new ItemStack(InitItems.itemHairyBall);
|
2015-10-02 19:58:03 +02: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() == NEIHairyBallRecipe.class){
|
2015-10-02 19:58:03 +02:00
|
|
|
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
|
|
|
for(HairyBallHandler.Return recipe : recipes){
|
|
|
|
arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
|
|
|
}
|
|
|
|
}
|
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){
|
|
|
|
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
|
|
|
for(HairyBallHandler.Return recipe : recipes){
|
2015-10-03 10:16:18 +02:00
|
|
|
if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)){
|
|
|
|
arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void loadUsageRecipes(ItemStack ingredient){
|
|
|
|
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
|
|
|
for(HairyBallHandler.Return recipe : recipes){
|
|
|
|
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.inputItem, ingredient)){
|
|
|
|
CachedBallRecipe theRecipe = new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight);
|
|
|
|
theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient);
|
|
|
|
arecipes.add(theRecipe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getGuiTexture(){
|
2015-10-03 10:16:18 +02:00
|
|
|
return ModUtil.MOD_ID_LOWER+":textures/gui/guiNEISimple.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 rec){
|
|
|
|
CachedBallRecipe recipe = (CachedBallRecipe)this.arecipes.get(rec);
|
|
|
|
if(recipe.result != null){
|
|
|
|
int secondChance = recipe.chance;
|
2015-10-03 10:16:18 +02:00
|
|
|
String secondString = secondChance+"%";
|
2015-10-02 19:58:03 +02:00
|
|
|
GuiDraw.drawString(secondString, 65+32, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int recipiesPerPage(){
|
|
|
|
return 2;
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
2015-10-03 10:16:18 +02:00
|
|
|
|
|
|
|
public class CachedBallRecipe extends CachedRecipe{
|
|
|
|
|
|
|
|
public PositionedStack result;
|
|
|
|
public PositionedStack input;
|
|
|
|
public int chance;
|
|
|
|
|
|
|
|
public CachedBallRecipe(ItemStack input, ItemStack result, int chance){
|
|
|
|
this.result = new PositionedStack(result, 67+32, 19);
|
|
|
|
this.chance = chance;
|
|
|
|
this.input = new PositionedStack(input, 5+32, 19);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public PositionedStack getResult(){
|
|
|
|
return result;
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public PositionedStack getIngredient(){
|
|
|
|
return input;
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|