Search in sources :

Example 6 with WindowWidget

use of org.bleachhack.gui.window.widget.WindowWidget in project BleachHack by BleachDrinker420.

the class Window method render.

public void render(MatrixStack matrices, int mouseX, int mouseY) {
    TextRenderer textRend = MinecraftClient.getInstance().textRenderer;
    if (dragging) {
        x2 = (x2 - x1) + mouseX - dragOffX - Math.min(0, mouseX - dragOffX);
        y2 = (y2 - y1) + mouseY - dragOffY - Math.min(0, mouseY - dragOffY);
        x1 = Math.max(0, mouseX - dragOffX);
        y1 = Math.max(0, mouseY - dragOffY);
    }
    drawBackground(matrices, mouseX, mouseY, textRend);
    for (WindowWidget w : widgets) {
        if (w.shouldRender(x1, y1, x2, y2)) {
            w.render(matrices, x1, y1, mouseX, mouseY);
        }
    }
    boolean blockItem = icon != null && icon.getItem() instanceof BlockItem;
    /* window icon */
    if (icon != null) {
        RenderSystem.getModelViewStack().push();
        RenderSystem.getModelViewStack().translate(x1 + (blockItem ? 3 : 2), y1 + 2, 0);
        RenderSystem.getModelViewStack().scale(0.6f, 0.6f, 1f);
        DiffuseLighting.enableGuiDepthLighting();
        MinecraftClient.getInstance().getItemRenderer().renderInGui(icon, 0, 0);
        DiffuseLighting.disableGuiDepthLighting();
        RenderSystem.getModelViewStack().pop();
        RenderSystem.applyModelViewMatrix();
    }
    /* window title */
    textRend.drawWithShadow(matrices, title, x1 + (icon == null || icon.getItem() == Items.AIR ? 4 : (blockItem ? 15 : 14)), y1 + 3, -1);
}
Also used : BlockItem(net.minecraft.item.BlockItem) WindowWidget(org.bleachhack.gui.window.widget.WindowWidget) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 7 with WindowWidget

use of org.bleachhack.gui.window.widget.WindowWidget in project BleachHack by BleachDrinker420.

the class WindowScreen method render.

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    super.render(matrices, mouseX, mouseY, delta);
    for (WindowWidget w : globalWidgets) {
        w.render(matrices, 0, 0, mouseX, mouseY);
    }
    int sel = getSelectedWindow();
    if (sel == -1) {
        for (int i : getWindowsFrontToBack()) {
            if (!getWindow(i).closed) {
                selectWindow(i);
                break;
            }
        }
    }
    boolean close = true;
    for (int w : getWindowsBackToFront()) {
        if (!getWindow(w).closed) {
            close = false;
            onRenderWindow(matrices, w, mouseX, mouseY);
        }
    }
    if (autoClose && close)
        this.onClose();
}
Also used : WindowWidget(org.bleachhack.gui.window.widget.WindowWidget)

Aggregations

WindowWidget (org.bleachhack.gui.window.widget.WindowWidget)7 WindowScrollbarWidget (org.bleachhack.gui.window.widget.WindowScrollbarWidget)4 ItemStack (net.minecraft.item.ItemStack)2 Window (org.bleachhack.gui.window.Window)2 ConcurrentModificationException (java.util.ConcurrentModificationException)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 BlockItem (net.minecraft.item.BlockItem)1 HoverEvent (net.minecraft.text.HoverEvent)1 LiteralText (net.minecraft.text.LiteralText)1 WindowTextWidget (org.bleachhack.gui.window.widget.WindowTextWidget)1