Added more nei handers.

This commit is contained in:
Modmuss50 2015-04-15 17:46:35 +01:00
parent b7ccae4b8c
commit 7e0119bce6
3 changed files with 210 additions and 0 deletions

View file

@ -19,9 +19,17 @@ public class NEIConfig implements IConfigureNEI {
@Override
public void loadConfig() {
CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler();
ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler();
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler();
API.registerRecipeHandler(centrifugeRecipeHandler);
API.registerUsageHandler(centrifugeRecipeHandler);
API.registerUsageHandler(shapedRollingMachineHandler);
API.registerRecipeHandler(shapedRollingMachineHandler);
API.registerUsageHandler(shapelessRollingMachineHandler);
API.registerRecipeHandler(shapelessRollingMachineHandler);
}
}

View file

@ -0,0 +1,98 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapedRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiRollingMachine.class;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcrafting", new Object[0]));
}
@Override
public String getRecipeName() {
return "rollingcrafting";
}
@Override
public String getOverlayIdentifier() {
return "rollingcrafting";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcrafting") && getClass() == ShapedRollingMachineHandler.class) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
continue;
recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
}

View file

@ -0,0 +1,104 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapelessRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiRollingMachine.class;
}
public String getRecipeName() {
return "Shapeless Rolling Machine";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcraftingnoshape"));
}
@Override
public String getOverlayIdentifier() {
return "rollingcraftingnoshape";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcraftingnoshape") && getClass() == ShapelessRollingMachineHandler.class) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
if(recipe.recipeItems == null)
return null;
return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput());
}
}