trying to add Anvil Recipe JEI
This commit is contained in:
@@ -6,9 +6,13 @@ import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.OreIngredient;
|
||||
import nmd.primal.forgecraft.compat.JEI.anvil.AnvilRecipeCategory;
|
||||
import nmd.primal.forgecraft.compat.JEI.anvil.AnvilRecipeChecker;
|
||||
import nmd.primal.forgecraft.compat.JEI.anvil.AnvilRecipeHandler;
|
||||
import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeCategory;
|
||||
import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeChecker;
|
||||
import nmd.primal.forgecraft.compat.JEI.crucible.CrucibleRecipeHandler;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
||||
import nmd.primal.forgecraft.init.ModBlocks;
|
||||
|
||||
@@ -37,6 +41,7 @@ public class ModJEI implements IModPlugin
|
||||
// Recipe Categories
|
||||
//
|
||||
registry.addRecipeCategories(new CrucibleRecipeCategory(guiHelper));
|
||||
registry.addRecipeCategories(new AnvilRecipeCategory(guiHelper));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,11 +54,20 @@ public class ModJEI implements IModPlugin
|
||||
// Recipes
|
||||
// ***************************************************************************** //
|
||||
//
|
||||
// Cauldron
|
||||
// Crucible
|
||||
//
|
||||
registry.handleRecipes(CrucibleCrafting.class, new CrucibleRecipeHandler(), CrucibleRecipeCategory.CATEGORY);
|
||||
registry.addRecipes(CrucibleRecipeChecker.getRecipes(), CrucibleRecipeCategory.CATEGORY);
|
||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.nbtCrucible), CrucibleRecipeCategory.CATEGORY);
|
||||
//
|
||||
// Anvil
|
||||
//
|
||||
registry.handleRecipes(AnvilCrafting.class, new AnvilRecipeHandler(), AnvilRecipeCategory.CATEGORY);
|
||||
registry.addRecipes(AnvilRecipeChecker.getRecipes(), AnvilRecipeCategory.CATEGORY);
|
||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.stoneanvil), AnvilRecipeCategory.CATEGORY);
|
||||
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************** //
|
||||
// Info
|
||||
@@ -61,5 +75,7 @@ public class ModJEI implements IModPlugin
|
||||
registry.addIngredientInfo(ItemStack.EMPTY, ItemStack.class, "jei.info.forgecraft.crucible");
|
||||
registry.addIngredientInfo(new ItemStack(ModBlocks.nbtCrucible, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.forgecraft.crucible");
|
||||
registry.addIngredientInfo(new OreIngredient("oreIron"), OreIngredient.class, "jei.info.forgecraft.oreiron");
|
||||
|
||||
registry.addIngredientInfo(new ItemStack(ModBlocks.stoneanvil, 1, OreDictionary.WILDCARD_VALUE), ItemStack.class, "jei.info.forgecraft.anvil");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,117 @@
|
||||
package nmd.primal.forgecraft.compat.JEI.anvil;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import nmd.primal.core.common.helper.CommonUtils;
|
||||
import nmd.primal.forgecraft.ModInfo;
|
||||
import nmd.primal.forgecraft.compat.JEI.AbstractCategory;
|
||||
import nmd.primal.forgecraft.init.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Created by mminaie on 9/16/18.
|
||||
*/
|
||||
public class AnvilRecipeCategory {
|
||||
}
|
||||
public class AnvilRecipeCategory extends AbstractCategory<AnvilRecipeWrapper>
|
||||
{
|
||||
public static String CATEGORY = CommonUtils.prefix("anvil");
|
||||
|
||||
private static ResourceLocation gui_background = new ResourceLocation(ModInfo.MOD_ID,"textures/gui/jei/crucible.png");
|
||||
private final IDrawable background;
|
||||
|
||||
public AnvilRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
//background = guiHelper.createDrawable(gui_background, 0, 0, 134, 144, 0, 0, 0, 0);
|
||||
background = guiHelper.createDrawable(gui_background, 0,0,160,134);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid()
|
||||
{
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return I18n.format("jei.category.forgecraft.anvil");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(@Nonnull Minecraft minecraft)
|
||||
{
|
||||
//progress.draw(minecraft, 67, 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout layout, AnvilRecipeWrapper recipe, IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup items = layout.getItemStacks();
|
||||
|
||||
/***INPUTS***/
|
||||
items.init(0, true, 1, 1);
|
||||
items.init(1, true, 20, 1);
|
||||
items.init(2, true, 39, 1);
|
||||
items.init(3, true, 58, 1);
|
||||
items.init(4, true, 77, 1);
|
||||
|
||||
items.init(5, true, 1, 20);
|
||||
items.init(6, true, 20, 20);
|
||||
items.init(7, true, 39, 20);
|
||||
items.init(8, true, 58, 20);
|
||||
items.init(9, true, 77, 20);
|
||||
|
||||
items.init(10, true, 1, 39);
|
||||
items.init(11, true, 20, 39);
|
||||
items.init(12, true, 39, 39);
|
||||
items.init(13, true, 58, 39);
|
||||
items.init(14, true, 77, 39);
|
||||
|
||||
items.init(15, true, 1, 58);
|
||||
items.init(16, true, 20, 58);
|
||||
items.init(17, true, 39, 58);
|
||||
items.init(18, true, 58, 58);
|
||||
items.init(19, true, 77, 58);
|
||||
|
||||
items.init(20, true, 1, 77);
|
||||
items.init(21, true, 20, 77);
|
||||
items.init(22, true, 39, 77);
|
||||
items.init(23, true, 58, 77);
|
||||
items.init(24, true, 77, 77);
|
||||
|
||||
//items.set(0, recipe.getIngredient(0));
|
||||
|
||||
for(int i =0; i < 25; i++){
|
||||
items.set(i, new ItemStack(recipe.getIngredient(i), 1));
|
||||
}
|
||||
|
||||
/***OUTPUTS***/
|
||||
items.init(25, false, 115, 96);
|
||||
items.set(25, recipe.output);
|
||||
|
||||
/***EXTRAS***/
|
||||
//items.init(6, false, 1, 96);
|
||||
//ItemStack crucibleStack = new ItemStack(ModBlocks.nbtCrucible, 1, 0);
|
||||
//items.set(6, crucibleStack);
|
||||
|
||||
//items.init(7, false, 58, 96);
|
||||
//ItemStack bloomeryStack = new ItemStack(ModBlocks.bloomery_brick, 1, 0);
|
||||
//items.set(7, bloomeryStack);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,20 @@
|
||||
package nmd.primal.forgecraft.compat.JEI.anvil;
|
||||
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mminaie on 9/16/18.
|
||||
*/
|
||||
public class AnvilRecipeChecker {
|
||||
|
||||
public static List<AnvilCrafting> getRecipes() {
|
||||
List<AnvilCrafting> recipes = new ArrayList<>();
|
||||
for (AnvilCrafting recipe : AnvilCrafting.getAnvilRecipes()) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package nmd.primal.forgecraft.compat.JEI.anvil;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Created by mminaie on 9/17/18.
|
||||
*/
|
||||
public class AnvilRecipeHandler implements IRecipeWrapperFactory<AnvilCrafting> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull AnvilCrafting recipe) {
|
||||
return new AnvilRecipeWrapper(recipe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package nmd.primal.forgecraft.compat.JEI.anvil;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import nmd.primal.core.api.PrimalAPI;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
import nmd.primal.forgecraft.init.ModItems;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mminaie on 9/16/18.
|
||||
*/
|
||||
public class AnvilRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
protected final AnvilCrafting recipe;
|
||||
|
||||
protected String[] input;
|
||||
protected String upgradeType;
|
||||
protected ItemStack output;
|
||||
|
||||
public AnvilRecipeWrapper(AnvilCrafting recipe) {
|
||||
|
||||
this.recipe = recipe;
|
||||
this.input = recipe.getInput();
|
||||
this.upgradeType = recipe.getUpgrade();
|
||||
this.output = recipe.getOutput();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
|
||||
for(int i =0; i < input.length; i++){
|
||||
ResourceLocation name = new ResourceLocation(input[i]);
|
||||
ingredients.setInput(ItemStack.class, ForgeRegistries.ITEMS.getValue(name));
|
||||
}
|
||||
}
|
||||
|
||||
public Item getIngredient(int a){
|
||||
|
||||
Item[] tempArray = new Item[25];
|
||||
for(int i =0; i < input.length; i++){
|
||||
ResourceLocation name = new ResourceLocation(input[i]);
|
||||
tempArray[i] = ForgeRegistries.ITEMS.getValue(name);
|
||||
}
|
||||
List<Item> stackList = Arrays.asList(tempArray);
|
||||
return stackList.get(a);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
||||
import nmd.primal.forgecraft.init.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ public class AnvilCrafting {
|
||||
// Recipe Handler AnvilCrafting
|
||||
// ***************************************************************************** //
|
||||
|
||||
public static ArrayList<AnvilCrafting> getAnvilRecipes() {
|
||||
return anvilRecipes;
|
||||
}
|
||||
|
||||
private static ArrayList<AnvilCrafting> anvilRecipes = new ArrayList<>();
|
||||
|
||||
private String[] input = new String[25];
|
||||
|
||||
Reference in New Issue
Block a user