Skip to content

Commit 1b356ef

Browse files
committed
more jei stuff
1 parent 3295c66 commit 1b356ef

File tree

5 files changed

+42
-36
lines changed

5 files changed

+42
-36
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.cleanroommc.modularui.core.mixins.late.jei;
2+
3+
import com.cleanroommc.modularui.api.IMuiScreen;
4+
5+
import mezz.jei.gui.GuiEventHandler;
6+
7+
import mezz.jei.gui.GuiScreenHelper;
8+
9+
import net.minecraftforge.client.event.GuiScreenEvent;
10+
11+
import org.spongepowered.asm.mixin.Final;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.Shadow;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
18+
/**
19+
* Modifies JEI to not draw tooltips when the cursor has a mui draggable element or the mouse is inside an exclusion area.
20+
*/
21+
@Mixin(value = GuiEventHandler.class, remap = false)
22+
public class GuiEventHandlerMixin {
23+
24+
@Shadow
25+
@Final
26+
private GuiScreenHelper guiScreenHelper;
27+
28+
@Inject(method = "onDrawScreenEventPost", at = @At(value = "INVOKE", target = "Lmezz/jei/gui/overlay/IngredientListOverlay;drawTooltips(Lnet/minecraft/client/Minecraft;II)V"), cancellable = true)
29+
public void onDrawScreenEventPost(GuiScreenEvent.DrawScreenEvent.Post event, CallbackInfo ci) {
30+
if (event.getGui() instanceof IMuiScreen muiScreen && muiScreen.getScreen().getContext().hasDraggable()) {
31+
ci.cancel();
32+
return;
33+
}
34+
if (guiScreenHelper.isInGuiExclusionArea(event.getMouseX(), event.getMouseY())) {
35+
ci.cancel();
36+
}
37+
}
38+
}

src/main/java/com/cleanroommc/modularui/core/mixins/late/jei/IngredientGridMixin.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/java/com/cleanroommc/modularui/screen/ModularPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public boolean onMousePressed(int mouseButton) {
325325
animateClose();
326326
result = true;
327327
}
328-
} else if (checkJeiGhostIngredient(mouseButton)) {
328+
} else if (checkRecipeViewerGhostIngredient(mouseButton)) {
329329
return true;
330330
} else {
331331
for (LocatedWidget widget : this.hovering) {
@@ -386,7 +386,7 @@ public boolean onMousePressed(int mouseButton) {
386386
});
387387
}
388388

389-
private boolean checkJeiGhostIngredient(int mouseButton) {
389+
private boolean checkRecipeViewerGhostIngredient(int mouseButton) {
390390
if (ModularUI.Mods.JEI.isLoaded() && ModularUIJeiPlugin.getGhostDrag() != null) {
391391
// try inserting ghost ingredient
392392
GhostIngredientDrag<?> drag = ModularUIJeiPlugin.getGhostDrag();

src/main/java/com/cleanroommc/modularui/screen/RecipeViewerSettingsImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public List<RecipeViewerGhostIngredientSlot<?>> getRecipeViewerGhostIngredientSl
157157

158158
@ApiStatus.Internal
159159
public List<Rectangle> getAllRecipeViewerExclusionAreas() {
160-
this.recipeViewerExclusionWidgets.removeIf(widget -> !widget.isValid());
161160
List<Rectangle> areas = new ArrayList<>(this.recipeViewerExclusionAreas);
162161
for (Iterator<IWidget> iterator = this.recipeViewerExclusionWidgets.iterator(); iterator.hasNext(); ) {
163162
IWidget widget = iterator.next();

src/main/resources/mixin.modularui.jei.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"client": [],
88
"mixins": [
99
"GhostIngredientDragManagerAccessor",
10-
"IngredientGridMixin",
10+
"GuiEventHandlerMixin",
1111
"IngredientListOverlayAccessor"
1212
]
13-
}
13+
}

0 commit comments

Comments
 (0)