Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @mezz.jei.api.JeiPlugin
- public class JeiPlugin implements IModPlugin {
- public static IJeiHelpers jeiHelper;
- @Override
- public ResourceLocation getPluginUid() {
- return new ResourceLocation("jeitest", "default");
- }
- @Override
- public void registerCategories(IRecipeCategoryRegistration registration) {
- jeiHelper = registration.getJeiHelpers();
- registration.addRecipeCategories(new InfuseBlockJeiCategory(jeiHelper.getGuiHelper()));
- }
- @Override
- public void registerRecipes(IRecipeRegistration registration) {
- registration.addRecipes(generateInfuseBlockRecipes(), InfuseBlockJeiCategory.Uid);
- registration.addRecipes(generateInfuseBlockRecipes2(), InfuseBlockJeiCategory.Uid);
- }
- private List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> generateInfuseBlockRecipes() {
- List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> recipes = new ArrayList<>();
- ArrayList<ItemStack> inputs = new ArrayList<>();
- ArrayList<ItemStack> outputs = new ArrayList<>();
- inputs.add(new ItemStack(Items.DIRT));
- outputs.add(new ItemStack(Items.DIAMOND));
- recipes.add(new InfuseBlockJeiCategory.InfuseBlockRecipeWrapper(inputs, outputs));
- return recipes;
- }
- private List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> generateInfuseBlockRecipes2() {
- List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> recipes = new ArrayList<>();
- ArrayList<ItemStack> inputs = new ArrayList<>();
- ArrayList<ItemStack> outputs = new ArrayList<>();
- inputs.add(new ItemStack(Items.STONE));
- outputs.add(new ItemStack(Items.EMERALD));
- recipes.add(new InfuseBlockJeiCategory.InfuseBlockRecipeWrapper(inputs, outputs));
- return recipes;
- }
- @Override
- public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
- registration.addRecipeCatalyst(new ItemStack(InfuseBenchBlock.block), InfuseBlockJeiCategory.Uid);
- }
- public static class InfuseBlockJeiCategory implements IRecipeCategory<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> {
- private static ResourceLocation Uid = new ResourceLocation("jeitest", "infuseblockcategory");
- private static final int input1 = 0; // THE NUMBER = SLOTID
- private static final int output1 = 1; // THE NUMBER = SLOTID
- // ...
- private final String title;
- private final IDrawable background;
- public InfuseBlockJeiCategory(IGuiHelper guiHelper) {
- this.title = "Infuse Bench";
- this.background = guiHelper.createDrawable(new ResourceLocation("jeitest", "textures/infuse_bench_gui.png"), 0, 0, 175, 166);
- }
- @Override
- public ResourceLocation getUid() {
- return Uid;
- }
- @Override
- public Class<? extends InfuseBlockRecipeWrapper> getRecipeClass() {
- return InfuseBlockJeiCategory.InfuseBlockRecipeWrapper.class;
- }
- @Override
- public String getTitle() {
- return title;
- }
- @Override
- public IDrawable getBackground() {
- return background;
- }
- @Override
- public IDrawable getIcon() {
- return null;
- }
- @Override
- public void setIngredients(InfuseBlockRecipeWrapper recipeWrapper, IIngredients iIngredients) {
- iIngredients.setInputs(VanillaTypes.ITEM, recipeWrapper.getInput());
- iIngredients.setOutputs(VanillaTypes.ITEM, recipeWrapper.getOutput());
- // ...
- }
- @Override
- public void draw(InfuseBlockRecipeWrapper recipe, double mouseX, double mouseY) {
- FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
- ItemStack recipeOutput = (ItemStack) recipe.output.get(0);
- System.out.println(recipeOutput.getItem() == Items.DIAMOND);
- }
- @Override
- public void setRecipe(IRecipeLayout iRecipeLayout, InfuseBlockRecipeWrapper recipeWrapper, IIngredients iIngredients) {
- IGuiItemStackGroup stacks = iRecipeLayout.getItemStacks();
- stacks.init(input1, true, 37, 32);
- stacks.set(input1, iIngredients.getInputs(VanillaTypes.ITEM).get(0));
- // ,,,
- stacks.init(output1, false, 118, 28);
- stacks.set(output1, iIngredients.getOutputs(VanillaTypes.ITEM).get(0));
- // ...
- }
- public static class InfuseBlockRecipeWrapper {
- private ArrayList input;
- private ArrayList output;
- public InfuseBlockRecipeWrapper(ArrayList input, ArrayList output) {
- this.input = input;
- this.output = output;
- }
- public ArrayList getInput() {
- return input;
- }
- public ArrayList getOutput() {
- return output;
- }
- }
- }
- }