Search in sources :

Example 1 with HandledScreen

use of net.minecraft.client.gui.screen.ingame.HandledScreen in project Skyblocker by LifeIsAParadox.

the class QuickNavButton method updateCoordinates.

private void updateCoordinates() {
    Screen screen = MinecraftClient.getInstance().currentScreen;
    if (screen instanceof HandledScreen<?>) {
        HandledScreen<?> handledScreen = (HandledScreen<?>) screen;
        int x = ((HandledScreenAccessor) handledScreen).getX();
        int y = ((HandledScreenAccessor) handledScreen).getY();
        int w = ((HandledScreenAccessor) handledScreen).getBackgroundWidth();
        int h = ((HandledScreenAccessor) handledScreen).getBackgroundHeight();
        // why is this even a thing
        if (h > 166)
            --h;
        this.x = x + this.index % 6 * 28 + 4;
        this.y = this.index < 6 ? y - 28 : y + h - 4;
        this.u = 28;
        this.v = (index < 6 ? 0 : 64) + (toggled ? 32 : 0);
    }
}
Also used : HandledScreenAccessor(me.xmrvizzy.skyblocker.mixin.HandledScreenAccessor) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) Screen(net.minecraft.client.gui.screen.Screen) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen)

Example 2 with HandledScreen

use of net.minecraft.client.gui.screen.ingame.HandledScreen in project BleachHack by BleachDrinker420.

the class AutoSteal method onOpenScreen.

@BleachSubscribe
public void onOpenScreen(EventOpenScreen event) {
    currentSyncId = -1;
    if (mc.player != null) {
        if (event.getScreen() instanceof HandledScreen) {
            ScreenHandler handler = ((HandledScreen<?>) event.getScreen()).getScreenHandler();
            if (handler instanceof GenericContainerScreenHandler) {
                currentSyncId = handler.syncId;
                lastOpen = currentTime;
                if (getSetting(0).asMode().getMode() >= 1) {
                    event.setCancelled(true);
                }
            } else {
                currentItems = null;
                mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
            }
        } else {
            currentItems = null;
            mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
        }
    }
}
Also used : HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) ScreenHandler(net.minecraft.screen.ScreenHandler) GenericContainerScreenHandler(net.minecraft.screen.GenericContainerScreenHandler) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with HandledScreen

use of net.minecraft.client.gui.screen.ingame.HandledScreen in project BleachHack by BleachDrinker420.

the class Peek method drawScreen.

@BleachSubscribe
public void drawScreen(EventRenderTooltip event) {
    if (!(event.getScreen() instanceof HandledScreen)) {
        return;
    }
    Slot slot = ((HandledScreen<?>) event.getScreen()).focusedSlot;
    if (slot == null)
        return;
    if (slot.x != slotX || slot.y != slotY) {
        pageCount = 0;
        pages = null;
        slotX = slot.x;
        slotY = slot.y;
    }
    event.getMatrix().push();
    event.getMatrix().translate(0, 0, 400);
    if (getSetting(0).asToggle().getState()) {
        List<TooltipComponent> components = drawShulkerToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
        if (components != null) {
            if (components.isEmpty()) {
                event.setCancelled(true);
            } else {
                event.setComponents(components);
            }
        }
    }
    if (getSetting(1).asToggle().getState())
        drawBookToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
    if (getSetting(2).asToggle().getState())
        drawMapToolTip(event.getMatrix(), slot, event.getMouseX(), event.getMouseY());
    event.getMatrix().pop();
}
Also used : HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) Slot(net.minecraft.screen.slot.Slot) TooltipComponent(net.minecraft.client.gui.tooltip.TooltipComponent) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

HandledScreen (net.minecraft.client.gui.screen.ingame.HandledScreen)3 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)2 HandledScreenAccessor (me.xmrvizzy.skyblocker.mixin.HandledScreenAccessor)1 Screen (net.minecraft.client.gui.screen.Screen)1 TooltipComponent (net.minecraft.client.gui.tooltip.TooltipComponent)1 CloseHandledScreenC2SPacket (net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket)1 GenericContainerScreenHandler (net.minecraft.screen.GenericContainerScreenHandler)1 ScreenHandler (net.minecraft.screen.ScreenHandler)1 Slot (net.minecraft.screen.slot.Slot)1