Skip to content

GUI Integration [Minecraft 1.21.11 to 26.2]

mezz edited this page Jul 8, 2026 · 2 revisions

Note

Version note: This page covers Minecraft 1.21.11, 26.1.2, and 26.2.

Related pages for other README-supported versions:

GUI Integration

Use registerGuiHandlers when JEI needs to understand your screen layout, clickable areas, non-slot ingredients, or ghost ingredient targets.

@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
  registration.addRecipeClickArea(
    CrusherScreen.class,
    78,
    34,
    24,
    17,
    ExampleJeiPlugin.CRUSHING
  );

  registration.addGuiContainerHandler(CrusherScreen.class, new CrusherGuiHandler());
  registration.addGhostIngredientHandler(CrusherScreen.class, new CrusherGhostIngredientHandler());
}

Click Areas

Use addRecipeClickArea for a fixed area of your container screen that should open JEI to one or more recipe types.

The x, y, width, and height values are relative to the left and top of the GUI, not the full screen.

registration.addRecipeClickArea(CrusherScreen.class, 78, 34, 24, 17, ExampleJeiPlugin.CRUSHING);

For dynamic areas, implement IGuiContainerHandler#getGuiClickableAreas.

Extra Areas

If your screen draws tabs, side panels, or other widgets outside the normal GUI rectangle, return those rectangles so JEI can avoid covering them.

public final class CrusherGuiHandler implements IGuiContainerHandler<CrusherScreen> {
  @Override
  public List<Rect2i> getGuiExtraAreas(CrusherScreen screen) {
    return List.of(screen.getUpgradePanelArea());
  }
}

These rectangles are in absolute screen coordinates.

Clickable Ingredients

JEI detects normal slots automatically. Use getClickableIngredientUnderMouse for ingredients drawn outside slots, such as a fluid tank, an energy-like custom ingredient, or a rendered item preview.

public final class CrusherGuiHandler implements IGuiContainerHandler<CrusherScreen> {
  @Override
  public Optional<? extends IClickableIngredient<?>> getClickableIngredientUnderMouse(
    IClickableIngredientFactory factory,
    CrusherScreen screen,
    double mouseX,
    double mouseY
  ) {
    Rect2i tankArea = screen.getTankArea();
    if (!tankArea.contains((int) mouseX, (int) mouseY)) {
      return Optional.empty();
    }

    return factory.createBuilder(screen.getTankItemStack())
      .buildWithArea(tankArea);
  }
}

For fluids or custom ingredient types, use factory.createBuilder(ingredientType, ingredient) with the platform ingredient type you registered or imported.

Ghost Ingredients

Use IGhostIngredientHandler when players should be able to drag ingredients from JEI into your screen as filters, patterns, or recipe templates. Ghost ingredients are not moved from the player's inventory.

public final class CrusherGhostIngredientHandler implements IGhostIngredientHandler<CrusherScreen> {
  @Override
  public <I> List<Target<I>> getTargetsTyped(CrusherScreen screen, ITypedIngredient<I> ingredient, boolean doStart) {
    Rect2i area = screen.getGhostFilterArea();

    return List.of(new Target<>() {
      @Override
      public Rect2i getArea() {
        return area;
      }

      @Override
      public void accept(I ingredient) {
        screen.setGhostFilter(ingredient);
      }
    });
  }

  @Override
  public void onComplete() {
  }
}

Target areas are in absolute screen coordinates. Use the typed ingredient to decide whether your screen can accept the dragged ingredient.

When To Use Each Handler

  • Use addRecipeClickArea for a static button, arrow, flame, progress bar, or machine icon that opens recipes.
  • Use getGuiExtraAreas when JEI overlaps parts of your screen.
  • Use getClickableIngredientUnderMouse for rendered ingredients that are not normal container slots.
  • Use addGhostIngredientHandler for filters, encoded patterns, and recipe previews.
  • Use addGuiScreenHandler only when your screen is not an AbstractContainerScreen.

Home

List of Plugin Implementations

Minecraft 26.1.2 and 26.2

  1. Setup
  1. Ingredients and Search
  1. Recipes
  1. Screen Integration

Minecraft 1.21.11

  1. Setup
  1. Ingredients and Search
  1. Recipes
  1. Screen Integration

Minecraft 1.21 and 1.21.1

  1. Setup
  1. Ingredients and Search
  1. Recipes

Minecraft 1.18.2, 1.19.2, and 1.20.1

  1. Setup
  1. Item Ingredients
  1. Working with Recipes
  1. Essential Extras
  1. Advanced

Minecraft 1.16.5

  1. Setup
  1. Item Ingredients
  1. Working with Recipes
  1. Essential Extras
  1. Advanced

Minecraft 1.12.2

  1. Setup
  1. Item Ingredients
  1. Working with Recipes
  1. Essential Extras
  1. Advanced

Clone this wiki locally