mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-16 13:03:12 +01:00
2c6bcd72cf
-Coffee Machine -Paxels
129 lines
No EOL
4.2 KiB
Java
129 lines
No EOL
4.2 KiB
Java
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.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 net.minecraft.util.StatCollector;
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import java.awt.*;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
|
|
public class HairyBallRecipeHandler extends TemplateRecipeHandler{
|
|
|
|
public static final String NAME = "actuallyadditions.ballOfHair";
|
|
|
|
public HairyBallRecipeHandler(){
|
|
super();
|
|
RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0);
|
|
}
|
|
|
|
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
|
|
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(){
|
|
return StatCollector.translateToLocal("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){
|
|
if(outputId.equals(NAME) && getClass() == HairyBallRecipeHandler.class){
|
|
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
|
for(HairyBallHandler.Return recipe : recipes){
|
|
arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
|
}
|
|
}
|
|
else super.loadCraftingRecipes(outputId, results);
|
|
}
|
|
|
|
@Override
|
|
public void loadCraftingRecipes(ItemStack result){
|
|
ArrayList<HairyBallHandler.Return> recipes = HairyBallHandler.returns;
|
|
for(HairyBallHandler.Return recipe : recipes){
|
|
if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight));
|
|
}
|
|
}
|
|
|
|
@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(){
|
|
return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEIHairyBall.png";
|
|
}
|
|
|
|
@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 void drawExtras(int rec){
|
|
CachedBallRecipe recipe = (CachedBallRecipe)this.arecipes.get(rec);
|
|
if(recipe.result != null){
|
|
int secondChance = recipe.chance;
|
|
String secondString = secondChance + "%";
|
|
GuiDraw.drawString(secondString, 65+32, 48, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getOverlayIdentifier(){
|
|
return NAME;
|
|
}
|
|
} |