use of net.minecraft.client.gui.IGuiEventListener in project Mekanism by mekanism.
the class GuiElementHandler method getIngredientUnderMouse.
@Nullable
private Object getIngredientUnderMouse(List<? extends IGuiEventListener> children, double mouseX, double mouseY) {
for (IGuiEventListener child : children) {
if (child instanceof Widget) {
Widget widget = (Widget) child;
if (!widget.visible) {
// Skip this child if it isn't visible
continue;
}
if (widget instanceof GuiElement) {
GuiElement element = (GuiElement) widget;
// Start by checking if we have any grandchildren that have an element being hovered as if we do it is the one
// we want to take as the grandchildren in general should be a more "forward" facing layer
Object underGrandChild = getIngredientUnderMouse(element.children(), mouseX, mouseY);
if (underGrandChild != null) {
// If we have a grandchild that was an ingredient helper, return its ingredient
return underGrandChild;
}
}
}
if (child instanceof IJEIIngredientHelper && child.isMouseOver(mouseX, mouseY)) {
return ((IJEIIngredientHelper) child).getIngredient(mouseX, mouseY);
}
}
return null;
}
Aggregations