use of mekanism.client.jei.interfaces.IJEIGhostTarget in project Mekanism by mekanism.
the class GhostIngredientHandler method getTargets.
private <INGREDIENT> List<TargetInfo<INGREDIENT>> getTargets(List<? extends IGuiEventListener> children, INGREDIENT ingredient) {
List<TargetInfo<INGREDIENT>> ghostTargets = new ArrayList<>();
for (IGuiEventListener child : children) {
if (child instanceof Widget) {
Widget widget = (Widget) child;
if (widget.visible) {
if (widget instanceof GuiElement) {
// Start by adding any grandchild ghost targets we have as they are the "top" layer, and we want them
// to get checked/interacted with first
ghostTargets.addAll(getTargets(((GuiElement) widget).children(), ingredient));
}
// Then go ahead and check if our element is a ghost target and if it is, and it supports the ingredient add it
if (widget instanceof IJEIGhostTarget) {
IJEIGhostTarget ghostTarget = (IJEIGhostTarget) widget;
IGhostIngredientConsumer ghostHandler = ghostTarget.getGhostHandler();
if (ghostHandler != null && ghostHandler.supportsIngredient(ingredient)) {
ghostTargets.add(new TargetInfo<>(ghostTarget, ghostHandler, widget.x, widget.y, widget.getWidth(), widget.getHeight()));
}
}
}
}
}
return ghostTargets;
}
Aggregations