Skip to content

Fix tooltip padding + merge JEI history from JEI-Utilities by vfyjxf#181

Open
tttsaurus wants to merge 7 commits intoCleanroomMC:cleanroomfrom
tttsaurus:cleanroom
Open

Fix tooltip padding + merge JEI history from JEI-Utilities by vfyjxf#181
tttsaurus wants to merge 7 commits intoCleanroomMC:cleanroomfrom
tttsaurus:cleanroom

Conversation

@tttsaurus
Copy link
Copy Markdown
Member

Fix Padding

Snipaste_2026-04-09_15-11-34 Snipaste_2026-04-09_15-00-39

JEI History

image

Note:
My implementation is still compatible with JEI-Utilities. No crash. It will disable itself when JEI-Utilities is installed since it modified the ctor that JEI-Utilities overrides

  public IngredientGrid(GridAlignment alignment) { // Left in for compatibility with JEI Utilities
  	this(new IngredientListBatchRenderer(), alignment, enableHistory:false);
  }

Concerns:

Firstly,

@Override
public <V> void show(IFocus<V> focus) {
	focus = Focus.check(focus);

	if (logic.setFocus(focus)) {
		open();
	}

	IngredientGridHistoryProvider.onSetFocus(focus);
}

I post an event in RecipesGui#show to notify enabled history providers, which looks pretty inelegant. JEI-Utilities does ASM on this.

Secondly, in order to notify all history providers

private static final List<IngredientGridHistoryProvider> GLOBAL_HISTORY_CONTAINER = new ArrayList<>();

public IngredientGridHistoryProvider(boolean enable) {
    this.enable = enable;
    this.guiHistoryIngredientSlots = new IngredientListBatchRenderer();

    GLOBAL_HISTORY_CONTAINER.add(this);
}

I created a static field to record all history providers, which looks rough too, but accessing history providers via a Internal.getRuntime()... chain doesn't look good either.

Comment thread src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java Outdated
Comment thread src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java Outdated
Comment thread src/main/java/mezz/jei/gui/overlay/IngredientGrid.java
Comment thread src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java Outdated
Comment thread src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java Outdated
} else if (copy instanceof FluidStack) {
((FluidStack) copy).amount = 1000;
}
return copy;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there anything that can be done for other types of ingredients - ie mekanism gas or thaumic jei aspects?

Comment on lines +300 to +303
GL11.glVertex2i(x, y);
GL11.glVertex2i(x + width, y);
GL11.glVertex2i(x + width, y + height);
GL11.glVertex2i(x, y + height);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to have a box? it seems like we could just use a horizontal line above the history section to separate it from the bookmarks (or ingredients)


Rectangle firstRect = guiHistoryIngredientSlots.getAllGuiIngredientSlots().get(0).getArea();

drawSpillingArea(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also have an if (guiHistoryIngredientSlots.isEmpty()) return;? we dont need to display the border for a box that isnt used.


private static final List<IngredientGridHistoryProvider> GLOBAL_HISTORY_CONTAINER = new ArrayList<>();

public static final int USE_ROWS = 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how reasonable would having this as a config be? perhaps it could be edited in-game via dragging the border up/downwards.

firstRect.height * USE_ROWS,
BACKGROUND_COLOR);

guiHistoryIngredientSlots.render(minecraft);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, if you hover an ingredient in the history it doesnt have a highlighted background.
adding the mouseX and mouseY params + this solves that

IngredientRenderer hoveredHistory = guiHistoryIngredientSlots.getHovered(mouseX, mouseY);
if (hoveredHistory != null) {
    hoveredHistory.drawHighlight();
}

this.enabled = enabled;
this.guiHistoryIngredientSlots = new IngredientListBatchRenderer();

GLOBAL_HISTORY_CONTAINER.add(this);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this, perhaps use Internal to set/get bookmark handler? there really should only be one, and i think it would make sense to expose this in that way. would look something like having JeiStarter#load have Internal.setHistory(new IngredientGridHistoryProvider()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants