Skip to content

GUI Integration en

eaker edited this page Oct 17, 2026 · 6 revisions

English | 简体中文

GUI integration

Register GUI integration in registerGuiHandlers(IGuiHandlerRegistration registration). MachineScreen below is a placeholder for your own screen class; adapt its fields and coordinates to your implementation.

Recipe side-button direction

Configure the whole button group in the category's setRecipe:

builder.setRecipeButtonDirection(RecipeButtonDirection.LEFT);
builder.moveRecipeTransferButton(155, 90);

RecipeButtonDirection is in eakerzt.jiv.api.gui.buttons. It supports UP, DOWN, LEFT, and RIGHT; the default UP preserves existing layouts. Buttons remain 13×13 with 2 GUI pixels between them. This example places transfer at (140,90) and bookmark at (155,90).

For LEFT, the anchor is the top-left corner of the rightmost button. The group grows left while retaining logical left-to-right order: transfer, bookmark, then plugin buttons. If transfer is hidden, bookmark remains at (155,90). Horizontal rows do not wrap; reserve room in the category. JIV includes left overflow when measuring width. Vertical directions wrap into columns to the right; position custom anchors with enough vertical room.

Use IRecipeLayoutDrawable.getSideButtonArea(visibleIndex, visibleCount) for actual visible-button bounds. The single-argument overload addresses spatial positions from the anchor, without visible-count/order adjustment. Direction does not enable transfer support for otherwise unsupported containers.

Recipe click areas

registration.addRecipeClickArea(
    MachineScreen.class, 78, 32, 28, 18, DemoRecipe.TYPE);

The position is relative to the container GUI's top-left corner; width and height define the hit area. Supply multiple recipe types if needed. This method applies to AbstractContainerScreen and registers the area through a container GUI handler.

The area opens recipe categories; it does not craft or transfer items.

Exclude extra panels from the overlay

Report tabs, tank panels, and upgrade areas outside the normal container rectangle through IGuiContainerHandler<T>.getGuiExtraAreas:

registration.addGuiContainerHandler(MachineScreen.class,
    new IGuiContainerHandler<MachineScreen>() {
        @Override
        public List<Rect2i> getGuiExtraAreas(MachineScreen screen) {
            return List.of(new Rect2i(
                screen.getGuiLeft() + screen.getXSize(),
                screen.getGuiTop(), 24, screen.getYSize()));
        }
    });

Adapt the boundary getter names to your screen. Rect2i is in net.minecraft.client.renderer. Exclusion rectangles use absolute screen coordinates, unlike GUI-relative click areas. Return the actual occupied bounds for expandable panels.

Use addGlobalGuiHandler for shared extra areas. For a regular Screen, register an IScreenHandler with addGuiScreenHandler to provide GUI bounds and allow overlay layout.

Tanks and custom ingredient displays

Normal item slots usually already support R / U lookups. For a tank or custom icon, override getClickableIngredientUnderMouse and use the supplied IClickableIngredientFactory to return its clickable ingredient on a hit.

Mouse coordinates are absolute screen coordinates. The ingredient type must be registered, such as NeoForgeTypes.FLUID_STACK for fluids. Return Optional.empty() outside the target.

Ghost ingredient dragging

Filters and recipe templates can register IGhostIngredientHandler<T> using addGhostIngredientHandler(screenClass, handler).

  1. getTargetsTyped(gui, typedIngredient, doStart) supplies target rectangles.
  2. A successful drop calls Target<I>.accept(I ingredient).
  3. onComplete() runs when dragging ends, whether or not the drop succeeded.

Targets use absolute screen coordinates. doStart=false is a preview and must not change the filter. Save the setting only when an ingredient is accepted. Ghost ingredients are template data; no real item is removed from the inventory. Send and validate your own setting request when the filter belongs to the server.

Source: IGuiHandlerRegistration, IGuiContainerHandler, IGhostIngredientHandler.

Recipe-screen extensions

Recipe-specific titles, native side panels, ingredient queries, pagination limits and direct mouse capture are documented in Recipe-screen extension API, with a complete Java example.

Clone this wiki locally