JEIAddedEvents.registerCategories((e) => {
  e.custom(`vinery:pressing`, (category) => {
    const {
      jeiHelpers: { guiHelper },
    } = category;
    category
      .title("Pressing")
      .background(
        guiHelper.createDrawable(
          "vinery:textures/gui/apple_press_gui.png",
          4,
          4,
          168,
          78
        )
      )
      .icon(guiHelper.createDrawableItemStack(Item.of("vinery:apple_press")))
      .isRecipeHandled((recipe) => {
        return !!(
          recipe?.data?.juicedItem !== undefined
        );
      })
      .handleLookup((builder, recipe) => {
        const { pressedItem, juicedItem, juice } = recipe.data;
        pressedItem &&
          builder.addSlot("INPUT", 40, 30).addItemStack(`1x ${pressedItem}`);
        builder.addSlot(juice ? "INPUT" : "OUTPUT", 97, 46).addItemStack(`1x ${juicedItem}`);
        builder
          .addSlot("CATALYST", 10, 30)
          .addItemStack(Item.of("vinery:apple_press"));

        juice &&
          builder.addSlot("INPUT", 115, 46).addItemStack("vinery:wine_bottle");
        juice && builder.addSlot("OUTPUT", 115, 14).addItemStack(juice);
      });
  });
});

JEIAddedEvents.registerRecipes((e) => {
  e.custom("vinery:pressing").add({
    pressedItem: "minecraft:apple",
    juicedItem: "vinery:apple_mash",
  });
  e.custom("vinery:pressing").add({
    juice: "vinery:apple_juice",
    juicedItem: "vinery:apple_mash",
  });
  e.custom("vinery:pressing").add({
    juice: "society:starfruit_juice",
    juicedItem: "pamhc2trees:starfruititem",
  });
  e.custom("vinery:pressing").add({
    juice: "society:ancient_juice",
    juicedItem: "society:ancient_fruit",
  });
});
