use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class ElementFertile method changeFocus.
@Override
public // do the default from INestedGuiEventHandler
boolean changeFocus(// do the default from INestedGuiEventHandler
boolean direction) {
IGuiEventListener iguieventlistener = this.getListener();
boolean flag = iguieventlistener != null;
if (flag && iguieventlistener.changeFocus(direction)) {
return true;
} else {
List<? extends IGuiEventListener> list = this.getEventListeners();
int j = list.indexOf(iguieventlistener);
int i;
if (flag && j >= 0) {
i = j + (direction ? 1 : 0);
} else if (direction) {
i = 0;
} else {
i = list.size();
}
ListIterator<? extends IGuiEventListener> listiterator = list.listIterator(i);
BooleanSupplier booleansupplier = direction ? listiterator::hasNext : listiterator::hasPrevious;
Supplier<? extends IGuiEventListener> supplier = direction ? listiterator::next : listiterator::previous;
while (booleansupplier.getAsBoolean()) {
IGuiEventListener iguieventlistener1 = supplier.get();
if (iguieventlistener1.changeFocus(direction)) {
this.setListener(iguieventlistener1);
return true;
}
}
this.setListener(null);
return false;
}
}
use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.
the class ElementFertile method getMinWidth.
@Override
public int getMinWidth() {
int min = 0;
for (IGuiEventListener child : getEventListeners()) {
if (child instanceof Fragment<?>) {
Fragment<?> fragment = (Fragment<?>) child;
int fragWidth = getConstraintSensitiveMinWidth(fragment);
if (fragWidth > min) {
min = fragWidth;
}
}
}
return min > 0 ? min + (getBorderSize() * 2) : 4;
}
use of net.minecraft.client.gui.IGuiEventListener in project Mekanism by mekanism.
the class GuiMekanism method mouseClicked.
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
hasClicked = true;
// first try to send the mouse event to our overlays
GuiWindow top = windows.isEmpty() ? null : windows.iterator().next();
GuiWindow focused = windows.stream().filter(overlay -> overlay.mouseClicked(mouseX, mouseY, button)).findFirst().orElse(null);
if (focused != null) {
if (windows.contains(focused)) {
// Validate that the focused window is still one of our windows, as if it wasn't focused/on top, and
// it is being closed, we don't want to update and mark it as focused, as our defocusing code won't
// run as we ran it when we pressed the button
setFocused(focused);
if (button == 0) {
setDragging(true);
}
// this check prevents us from moving the window to the top of the stack if the clicked window opened up an additional window
if (top != focused) {
top.onFocusLost();
windows.moveUp(focused);
focused.onFocused();
}
}
return true;
}
// otherwise, we send it to the current element
for (int i = buttons.size() - 1; i >= 0; i--) {
IGuiEventListener listener = buttons.get(i);
if (listener.mouseClicked(mouseX, mouseY, button)) {
setFocused(listener);
if (button == 0) {
setDragging(true);
}
return true;
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
use of net.minecraft.client.gui.IGuiEventListener in project SophisticatedBackpacks by P3pp3rF1y.
the class BackpackScreen method mouseDragged.
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
for (IGuiEventListener child : children) {
if (child.isMouseOver(mouseX, mouseY) && child.mouseDragged(mouseX, mouseY, button, dragX, dragY)) {
return true;
}
}
Slot slot = findSlot(mouseX, mouseY);
ItemStack itemstack = minecraft.player.inventory.getCarried();
if (isQuickCrafting && slot != null && !itemstack.isEmpty() && (itemstack.getCount() > quickCraftSlots.size() || quickCraftingType == 2) && BackpackContainer.canMergeItemToSlot(slot, itemstack) && slot.mayPlace(itemstack) && menu.canDragTo(slot)) {
quickCraftSlots.add(slot);
recalculateQuickCraftRemaining();
}
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
use of net.minecraft.client.gui.IGuiEventListener in project BoundingBoxOutlineReloaded by irtimaled.
the class ListScreen method mouseClicked.
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
for (IGuiEventListener control : this.children()) {
if (control.mouseClicked(mouseX, mouseY, button)) {
IGuiEventListener focused = getFocused();
if (focused instanceof IFocusableControl && focused != control) {
((IFocusableControl) focused).clearFocus();
}
this.setFocused(control);
if (button == 0)
this.setDragging(true);
return true;
}
}
return false;
}
Aggregations