TBroski

Updated Code

Jun 11th, 2020
1,136
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.54 KB | None | 1 0
  1. @mezz.jei.api.JeiPlugin
  2. public class JeiPlugin implements IModPlugin {
  3.     public static IJeiHelpers jeiHelper;
  4.     @Override
  5.     public ResourceLocation getPluginUid() {
  6.         return new ResourceLocation("jeitest", "default");
  7.     }
  8.  
  9.     @Override
  10.     public void registerCategories(IRecipeCategoryRegistration registration) {
  11.         jeiHelper = registration.getJeiHelpers();
  12.         registration.addRecipeCategories(new InfuseBlockJeiCategory(jeiHelper.getGuiHelper()));
  13.     }
  14.  
  15.     @Override
  16.     public void registerRecipes(IRecipeRegistration registration) {
  17.         registration.addRecipes(generateInfuseBlockRecipes(), InfuseBlockJeiCategory.Uid);
  18.         registration.addRecipes(generateInfuseBlockRecipes2(), InfuseBlockJeiCategory.Uid);
  19.     }
  20.  
  21.     private List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> generateInfuseBlockRecipes() {
  22.         List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> recipes = new ArrayList<>();
  23.         ArrayList<ItemStack> inputs = new ArrayList<>();
  24.         ArrayList<ItemStack> outputs = new ArrayList<>();
  25.         inputs.add(new ItemStack(Items.DIRT));
  26.         outputs.add(new ItemStack(Items.DIAMOND));
  27.         recipes.add(new InfuseBlockJeiCategory.InfuseBlockRecipeWrapper(inputs, outputs));
  28.         return recipes;
  29.     }
  30.  
  31.         private List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> generateInfuseBlockRecipes2() {
  32.         List<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> recipes = new ArrayList<>();
  33.         ArrayList<ItemStack> inputs = new ArrayList<>();
  34.         ArrayList<ItemStack> outputs = new ArrayList<>();
  35.         inputs.add(new ItemStack(Items.STONE));
  36.         outputs.add(new ItemStack(Items.EMERALD));
  37.         recipes.add(new InfuseBlockJeiCategory.InfuseBlockRecipeWrapper(inputs, outputs));
  38.         return recipes;
  39.     }
  40.  
  41.     @Override
  42.     public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
  43.         registration.addRecipeCatalyst(new ItemStack(InfuseBenchBlock.block), InfuseBlockJeiCategory.Uid);
  44.     }
  45.     public static class InfuseBlockJeiCategory implements IRecipeCategory<InfuseBlockJeiCategory.InfuseBlockRecipeWrapper> {
  46.         private static ResourceLocation Uid = new ResourceLocation("jeitest", "infuseblockcategory");
  47.         private static final int input1 = 0; // THE NUMBER = SLOTID
  48.         private static final int output1 = 1; // THE NUMBER = SLOTID
  49.         // ...
  50.         private final String title;
  51.         private final IDrawable background;
  52.        
  53.         public InfuseBlockJeiCategory(IGuiHelper guiHelper) {
  54.             this.title = "Infuse Bench";
  55.             this.background = guiHelper.createDrawable(new ResourceLocation("jeitest", "textures/infuse_bench_gui.png"), 0, 0, 175, 166);
  56.         }
  57.  
  58.         @Override
  59.         public ResourceLocation getUid() {
  60.             return Uid;
  61.         }
  62.  
  63.         @Override
  64.         public Class<? extends InfuseBlockRecipeWrapper> getRecipeClass() {
  65.             return InfuseBlockJeiCategory.InfuseBlockRecipeWrapper.class;
  66.         }
  67.  
  68.         @Override
  69.         public String getTitle() {
  70.             return title;
  71.         }
  72.  
  73.         @Override
  74.         public IDrawable getBackground() {
  75.             return background;
  76.         }
  77.  
  78.         @Override
  79.         public IDrawable getIcon() {
  80.             return null;
  81.         }
  82.  
  83.         @Override
  84.         public void setIngredients(InfuseBlockRecipeWrapper recipeWrapper, IIngredients iIngredients) {
  85.             iIngredients.setInputs(VanillaTypes.ITEM, recipeWrapper.getInput());
  86.             iIngredients.setOutputs(VanillaTypes.ITEM, recipeWrapper.getOutput());
  87.             // ...
  88.         }
  89.  
  90.         @Override
  91.         public void draw(InfuseBlockRecipeWrapper recipe, double mouseX, double mouseY) {
  92.             FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
  93.             ItemStack recipeOutput = (ItemStack) recipe.output.get(0);
  94.             System.out.println(recipeOutput.getItem() == Items.DIAMOND);
  95.            
  96.         }
  97.         @Override
  98.         public void setRecipe(IRecipeLayout iRecipeLayout, InfuseBlockRecipeWrapper recipeWrapper, IIngredients iIngredients) {
  99.             IGuiItemStackGroup stacks = iRecipeLayout.getItemStacks();
  100.             stacks.init(input1, true, 37, 32);
  101.             stacks.set(input1, iIngredients.getInputs(VanillaTypes.ITEM).get(0));
  102.             // ,,,
  103.            
  104.             stacks.init(output1, false, 118, 28);
  105.             stacks.set(output1, iIngredients.getOutputs(VanillaTypes.ITEM).get(0));
  106.             // ...
  107.         }
  108.         public static class InfuseBlockRecipeWrapper {
  109.             private ArrayList input;
  110.             private ArrayList output;
  111.  
  112.             public InfuseBlockRecipeWrapper(ArrayList input, ArrayList output) {
  113.                 this.input = input;
  114.                 this.output = output;
  115.             }
  116.  
  117.  
  118.             public ArrayList getInput() {
  119.                 return input;
  120.             }
  121.  
  122.             public ArrayList getOutput() {
  123.                 return output;
  124.             }
  125.         }
  126.     }
  127. }
Comments
Add Comment
Please, Sign In to add comment