Skip to content

Commit 92cdc02

Browse files
authored
Fix Phantom Slot JEI highlight when hovering over valid JEI ingredients (#112)
* highlight when hovering over an element * commit suggestion
1 parent fde52cc commit 92cdc02

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/main/java/com/cleanroommc/modularui/core/mixin/jei/GhostIngredientDragManagerAccessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ public interface GhostIngredientDragManagerAccessor {
1010

1111
@Accessor
1212
GhostIngredientDrag<?> getGhostIngredientDrag();
13+
14+
@Accessor
15+
Object getHoveredIngredient();
1316
}

src/main/java/com/cleanroommc/modularui/integration/jei/ModularUIJeiPlugin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,20 @@ public static GhostIngredientDragManager getGhostDragManager() {
3636
return ((IngredientListOverlayAccessor) runtime.getIngredientListOverlay()).getGhostIngredientDragManager();
3737
}
3838

39+
public static boolean hoveringOverIngredient(JeiGhostIngredientSlot<?> ingredientSlot) {
40+
Object hovered = getHoverdObject();
41+
if (hovered == null) return false;
42+
return ingredientSlot.castGhostIngredientIfValid(hovered) != null;
43+
}
44+
3945
public static GhostIngredientDrag<?> getGhostDrag() {
4046
return ((GhostIngredientDragManagerAccessor) getGhostDragManager()).getGhostIngredientDrag();
4147
}
4248

49+
public static Object getHoverdObject() {
50+
return ((GhostIngredientDragManagerAccessor) getGhostDragManager()).getHoveredIngredient();
51+
}
52+
4353
public static boolean hasDraggingGhostIngredient() {
4454
return getGhostDrag() != null;
4555
}

src/main/java/com/cleanroommc/modularui/widgets/ItemSlot.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
9090
drawSlot(getSlot());
9191
RenderHelper.enableStandardItemLighting();
9292
GlStateManager.disableLighting();
93-
if (this.syncHandler.isPhantom() && ModularUI.isJeiLoaded() && ModularUIJeiPlugin.hasDraggingGhostIngredient()) {
93+
if (this.syncHandler.isPhantom() && ModularUI.isJeiLoaded() &&
94+
(ModularUIJeiPlugin.hasDraggingGhostIngredient() || ModularUIJeiPlugin.hoveringOverIngredient(this))) {
9495
GlStateManager.colorMask(true, true, true, false);
9596
drawHighlight(getArea(), isHovering());
9697
GlStateManager.colorMask(true, true, true, true);

0 commit comments

Comments
 (0)