net.minecraft.client.gui.ScaledResolution Java Examples

The following examples show how to use net.minecraft.client.gui.ScaledResolution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinGuiConnecting.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());

    this.drawDefaultBackground();

    RenderUtils.drawLoadingCircle(scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 70);

    String ip = "Unknown";

    final ServerData serverData = mc.getCurrentServerData();
    if(serverData != null)
        ip = serverData.serverIP;

    Fonts.font40.drawCenteredString("Connecting to", scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 110, 0xFFFFFF, true);
    Fonts.font35.drawCenteredString(ip, scaledResolution.getScaledWidth() / 2, scaledResolution.getScaledHeight() / 4 + 120, 0x5281FB, true);

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
Example #2
Source File: VanillaEnhancementsHud.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@InvokeEvent
public void renderEnchantments(RenderHUDEvent e) {
    if (Settings.ENCHANTMENTS_ABOVE_HOTBAR) {
        ItemStack heldItemStack = mc.thePlayer.inventory.getCurrentItem();
        if (heldItemStack != null) {
            String toDraw = heldItemStack.getItem() instanceof ItemPotion ? getPotionEffectString(heldItemStack) : getEnchantmentString(heldItemStack);
            GL11.glPushMatrix();
            GL11.glScalef(0.5f, 0.5f, 0.5f);
            ScaledResolution res = ResolutionUtil.current();
            int y = res.getScaledHeight() - 59;
            y += (mc.playerController.shouldDrawHUD() ? -2 : 14);
            y = y + mc.fontRendererObj.FONT_HEIGHT;
            y <<= 1;
            int x = res.getScaledWidth() - (mc.fontRendererObj.getStringWidth(toDraw) >> 1);
            mc.fontRendererObj.drawString(toDraw, x, y, 13421772);
            GL11.glScalef(2.0f, 2.0f, 2.0f);
            GL11.glPopMatrix();
        }
    }
}
 
Example #3
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Scaffold visuals
 *
 * @param event
 */
@EventTarget
public void onRender2D(final Render2DEvent event) {
    if (counterDisplayValue.get()) {
        GlStateManager.pushMatrix();

        final BlockOverlay blockOverlay = (BlockOverlay) LiquidBounce.moduleManager.getModule(BlockOverlay.class);
        if (blockOverlay.getState() && blockOverlay.getInfoValue().get() && blockOverlay.getCurrentBlock() != null)
            GlStateManager.translate(0, 15F, 0);

        final String info = "Blocks: §7" + getBlocksAmount();
        final ScaledResolution scaledResolution = new ScaledResolution(mc);

        RenderUtils.drawBorderedRect((scaledResolution.getScaledWidth() / 2) - 2,
                (scaledResolution.getScaledHeight() / 2) + 5,
                (scaledResolution.getScaledWidth() / 2) + Fonts.font40.getStringWidth(info) + 2,
                (scaledResolution.getScaledHeight() / 2) + 16, 3, Color.BLACK.getRGB(), Color.BLACK.getRGB());
        GlStateManager.resetColor();
        Fonts.font40.drawString(info, scaledResolution.getScaledWidth() / 2,
                scaledResolution.getScaledHeight() / 2 + 7, Color.WHITE.getRGB());

        GlStateManager.popMatrix();
    }
}
 
Example #4
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tower visuals
 *
 * @param event
 */
@EventTarget
public void onRender2D(final Render2DEvent event) {
    if(counterDisplayValue.get()) {
        GlStateManager.pushMatrix();

        final BlockOverlay blockOverlay = (BlockOverlay) LiquidBounce.moduleManager.getModule(BlockOverlay.class);
        if (blockOverlay.getState() && blockOverlay.getInfoValue().get() && blockOverlay.getCurrentBlock() != null)
            GlStateManager.translate(0, 15F, 0);

        final String info = "Blocks: §7" + getBlocksAmount();
        final ScaledResolution scaledResolution = new ScaledResolution(mc);

        RenderUtils.drawBorderedRect((scaledResolution.getScaledWidth() / 2) - 2,
                (scaledResolution.getScaledHeight() / 2) + 5,
                (scaledResolution.getScaledWidth() / 2) + Fonts.font40.getStringWidth(info) + 2,
                (scaledResolution.getScaledHeight() / 2) + 16, 3, Color.BLACK.getRGB(), Color.BLACK.getRGB());
        GlStateManager.resetColor();
        Fonts.font40.drawString(info, scaledResolution.getScaledWidth() / 2,
                scaledResolution.getScaledHeight() / 2 + 7, Color.WHITE.getRGB());

        GlStateManager.popMatrix();
    }
}
 
Example #5
Source File: HyperiumOverlay.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void handleMouseInput() {
    ScaledResolution sr = ResolutionUtil.current();
    int sw = sr.getScaledWidth();
    int sh = sr.getScaledHeight();
    int mx = Mouse.getX() * sw / Minecraft.getMinecraft().displayWidth;
    int my = sh - Mouse.getY() * sh / Minecraft.getMinecraft().displayHeight - 1;

    Integer[] counter = new Integer[]{0};

    components.forEach(c -> c.handleMouseInput(mx, my, sr.getScaledWidth() / 6 * 2,
        sr.getScaledHeight() / 4 + 20 * counter[0]++ + offsetY, sr.getScaledWidth() / 6 * 2, 20));

    int i = Mouse.getEventDWheel();
    if (i > 0 && offsetY != 0) offsetY += 5;
    else if (i < 0) offsetY -= 5;
}
 
Example #6
Source File: ItemQuantumGoggles.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHelmetOverlay( ItemStack stack, EntityPlayer player, ScaledResolution resolution, float partialTicks, boolean hasScreen, int mouseX, int mouseY )
{
    switch( stack.getItemDamage() )
    {
        case SubTypes.Quantum:
        default:
        {
            QCraft.renderQuantumGogglesOverlay( resolution.getScaledWidth(), resolution.getScaledHeight() );
            break;
        }
        case SubTypes.AntiObservation:
        {
            QCraft.renderAOGogglesOverlay( resolution.getScaledWidth(), resolution.getScaledHeight() );
            break;
        }
    }
}
 
Example #7
Source File: FramebufferShader.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author TheSlowly
 */
public void drawFramebuffer(final Framebuffer framebuffer) {
    final ScaledResolution scaledResolution = new ScaledResolution(mc);
    glBindTexture(GL_TEXTURE_2D, framebuffer.framebufferTexture);
    glBegin(GL_QUADS);
    glTexCoord2d(0, 1);
    glVertex2d(0, 0);
    glTexCoord2d(0, 0);
    glVertex2d(0, scaledResolution.getScaledHeight());
    glTexCoord2d(1, 0);
    glVertex2d(scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());
    glTexCoord2d(1, 1);
    glVertex2d(scaledResolution.getScaledWidth(), 0);
    glEnd();
    glUseProgram(0);
}
 
Example #8
Source File: HudElementBase.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void render(EntityPlayer player, ScaledResolution resolution, boolean hudjackAvailable, boolean isConfigOpen, float partialTicks)
{
	int x = getX();
	int y = getY();
	if (getHorizontalAnchor() == EnumAnchorHorizontal.RIGHT)
	{
		x = resolution.getScaledWidth() - x - getWidth();
	}
	if (getVerticalAnchor() == EnumAnchorVertical.BOTTOM)
	{
		y = resolution.getScaledHeight() - y - getHeight();
	}
	
	renderElement(x, y, player, resolution, hudjackAvailable, isConfigOpen, partialTicks);
}
 
Example #9
Source File: PlayerStatsGui.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
    boolean flag = false;
    for (GuiButton guiButton : buttonList) {
        if (guiButton.isMouseOver()) flag = true;
    }

    boolean flag2 = focused == null;
    if (!flag && flag2) focused = null;

    ScaledResolution current = ResolutionUtil.current();
    if (focused != null && new GuiBlock((current.getScaledWidth() / 2 - 22 - 64), (current.getScaledWidth() / 2 - 22), 73, 73 + 64).isMouseOver(mouseX, mouseY)) {
        focused = null;
        offset = 0;
    }

    if (flag2 && mouseButton == 0) {
        location.keySet().stream().filter(abstractHypixelStats -> location.get(abstractHypixelStats).isMouseOver(mouseX, mouseY))
            .forEach(abstractHypixelStats -> {
                focused = abstractHypixelStats;
                hovered = null;
                offset = 0;
            });
    }
}
 
Example #10
Source File: FontHelper.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
private static void set2DMode(FloatBuffer matrixData) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    mc.entityRenderer.setupOverlayRendering();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    //GL11.glLoadMatrix(matrixData);

    GL11.glLoadIdentity();
    GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    Matrix4f matrix = new Matrix4f();
    matrix.load(matrixData);
    GL11.glTranslatef(matrix.m30*sr.getScaleFactor(),-matrix.m31*sr.getScaleFactor(), 0f);

}
 
Example #11
Source File: Particle.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
void fall() {
    final Minecraft mc = Minecraft.getMinecraft();
    final ScaledResolution scaledResolution = new ScaledResolution(mc);
    y = (y + ySpeed);
    x = (x + xSpeed);

    if(y > mc.displayHeight)
        y = 1;

    if(x > mc.displayWidth)
        x = 1;

    if(x < 1)
        x = scaledResolution.getScaledWidth();

    if(y < 1)
        y = scaledResolution.getScaledHeight();
}
 
Example #12
Source File: Events.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onGameOverlay(RenderGameOverlayEvent.Text event) {
    if (!cheatEnabled) {
        return;
    }
    GLUtils.hasClearedDepth = false;
    ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> {
        mod.onGameOverlay(event);
    });
    if (Wrapper.INSTANCE.mc().currentScreen == null) {
        int x2 = 8;
        int y2 = 7;
        GL11.glPushMatrix();
        GL11.glScalef(1f, 1f, 1f);
        String Copyright1 = "EHacks Pro v" + Main.version;
        String Copyright2 = "by radioegor146";
        ScaledResolution get = new ScaledResolution(Wrapper.INSTANCE.mc(), Wrapper.INSTANCE.mc().displayWidth, Wrapper.INSTANCE.mc().displayHeight);
        this.fontRender.drawString(Copyright1, 2, 2, Events.rainbowEffect_Text(9999999L, 1.0f).getRGB());
        this.fontRender.drawStringWithShadow(Copyright2, get.getScaledWidth() - 2 - this.fontRender.getStringWidth(Copyright2), get.getScaledHeight() - this.fontRender.FONT_HEIGHT - 2, GLUtils.getColor(255, 255, 255));
        GL11.glPopMatrix();
    }
    EHacksGui.clickGui.drawBack();
}
 
Example #13
Source File: Drawable.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public void draw(ScaledResolution resolution, RenderState renderState, float partialTicks) {
	final float screenX = alignment.getScreenAnchorX(resolution.getScaledWidth()) + boundingBox.left;
	final float screenY = alignment.getScreenAnchorY(resolution.getScaledHeight()) + boundingBox.top;

	final float anchorX = alignment.getObjectAnchorX(boundingBox);
	final float anchorY = alignment.getObjectAnchorY(boundingBox);

	GL11.glPushMatrix();
	if (rotation != 0) {
		GL11.glTranslatef(screenX, screenY, z);
		GL11.glRotated(rotation, 0, 0, 1);
		GL11.glTranslatef(anchorX, anchorY, 0);
	} else {
		GL11.glTranslatef(screenX + anchorX, screenY + anchorY, z);
	}

	drawContents(renderState, partialTicks);
	GL11.glPopMatrix();
}
 
Example #14
Source File: CivilizationClientHandlers.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPostRenderOverlay(RenderGameOverlayEvent.Pre event) {
	if (event.getType() != ElementType.HOTBAR) {
		return;
	}
	ScaledResolution resolution = event.getResolution();

	if (hud == null) {
		hud = new CivilizationOverlayHandler(Minecraft.getMinecraft());
	}

	hud.render(resolution.getScaledWidth(), resolution.getScaledHeight());
}
 
Example #15
Source File: VanillaEnhancementsHud.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void onRenderArmor(GuiDrawScreenEvent e) {
    if ((Settings.ARMOR_PROT_POTENTIONAL || Settings.ARMOR_PROJ_POTENTIONAL) && (e.getScreen() instanceof GuiInventory || e.getScreen() instanceof GuiContainerCreative)) {
        ScaledResolution res = new ScaledResolution(mc);
        String message = getArmorString();
        mc.currentScreen.drawString(mc.fontRendererObj, message, 10, res.getScaledHeight() - 16, -1);
    }
}
 
Example #16
Source File: GuiHudConfiguration.java    From Cyberware with MIT License 5 votes vote down vote up
public static int getAbsoluteX(ScaledResolution sr, IHudElement element)
{
	if (element.getHorizontalAnchor() == EnumAnchorHorizontal.RIGHT)
	{
		return sr.getScaledWidth() - element.getX() - element.getWidth();
	}
	return element.getX();
}
 
Example #17
Source File: GuiHelmetMainScreen.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static void init(){
    instance = new GuiHelmetMainScreen();
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    ScaledResolution scaledresolution = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
    int width = scaledresolution.getScaledWidth();
    int height = scaledresolution.getScaledHeight();
    instance.setWorldAndResolution(minecraft, width, height);

    for(int i = 1; i < instance.upgradePages.size(); i++) {
        page = i;
        instance.initGui();
    }
    page = 0;
    instance.init = false;
}
 
Example #18
Source File: GuiCapture.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	final int button = Mouse.getEventButton();
	final int wheel = Mouse.getEventDWheel();
	final int mx = Mouse.getEventX();
	final int my = Mouse.getEventY();

	final float scaleX = (float)this.width / this.mc.displayWidth;
	final float scaleY = (float)this.height / this.mc.displayHeight;

	final float x = mx * scaleX;
	final float y = this.height - my * scaleY;

	if (button != -1 || wheel != 0) {
		final ScaledResolution resolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
		final DrawableHitInfo hit = TerminalManagerClient.instance.findDrawableHit(guid, resolution, x, y);

		if (button != -1) {
			final boolean state = Mouse.getEventButtonState();
			createMouseButtonEvent(button, state, hit).sendToServer();
			final boolean draggingStarted = updateButtonCounter(state);
			if (draggingStarted) resetDraggingLimiter(x, y);
		}

		if (wheel != 0) createMouseWheelEvent(wheel, hit).sendToServer();
	}

	{
		final float dx = (x - lastDragX);
		final float dy = (y - lastDragY);

		if (canSendDragEvent(dx, dy)) {
			createDragEvent(dx, dy).sendToServer();
			resetDraggingLimiter(x, y);
		}
	}

}
 
Example #19
Source File: SkyblockAddonsGui.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Draws the default text at the top at bottoms of the GUI.
 * @param gui The gui to draw the text on.
 */
static void drawDefaultTitleText(GuiScreen gui, int alpha) {
    int defaultBlue = SkyblockAddons.getInstance().getUtils().getDefaultBlue(alpha);

    int height = 90;
    int width = height*2;
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());

    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();

    SkyblockAddons.getInstance().getUtils().enableStandardGLOptions();
    textureManager.bindTexture(LOGO);
    SkyblockAddons.getInstance().getUtils().drawModalRectWithCustomSizedTexture(scaledResolution.getScaledWidth()/2F-width/2F, 3, 0, 0, width, height, width, height, true);

    int animationMillis = 4000;
    float glowAlpha;
    glowAlpha = System.currentTimeMillis()%animationMillis;
    if (glowAlpha > animationMillis/2F) {
        glowAlpha = (animationMillis-glowAlpha)/(animationMillis/2F);
    } else {
        glowAlpha = glowAlpha/(animationMillis/2F);
    }

    GlStateManager.color(1,1,1, glowAlpha);
    textureManager.bindTexture(LOGO_GLOW);
    SkyblockAddons.getInstance().getUtils().drawModalRectWithCustomSizedTexture(scaledResolution.getScaledWidth()/2F-width/2F, 3, 0, 0, width, height, width, height, true);

    GlStateManager.color(1,1,1, 1);
    String version = "v" + SkyblockAddons.VERSION.replace("beta", "b") + " by Biscut";
    drawScaledString(gui, version, 55, defaultBlue, 1.3, 170 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(version), false);

    if (gui instanceof SkyblockAddonsGui) {
        drawScaledString(gui, "Special Credits: InventiveTalent - Magma Boss Timer API", gui.height - 22, defaultBlue, 1, 0);
    }
    SkyblockAddons.getInstance().getUtils().restoreGLOptions();
}
 
Example #20
Source File: GuiHudEditor.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    super.drawScreen(mouseX, mouseY, partialTicks);
    this.drawDefaultBackground();

    final ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());

    final float halfWidth = res.getScaledWidth() / 2.0f;
    final float halfHeight = res.getScaledHeight() / 2.0f;
    RenderUtil.drawLine(halfWidth, 0, halfWidth, res.getScaledHeight(), 1, 0x75909090);
    RenderUtil.drawLine(0, halfHeight, res.getScaledWidth(), halfHeight, 1, 0x75909090);

    for (AnchorPoint point : Seppuku.INSTANCE.getHudManager().getAnchorPoints()) {
        RenderUtil.drawRect(point.getX() - 1, point.getY() - 1, point.getX() + 1, point.getY() + 1, 0x75909090);
    }

    for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) {
        if (component.isVisible()) {
            component.render(mouseX, mouseY, partialTicks);

            if (component instanceof DraggableHudComponent) {
                DraggableHudComponent draggable = (DraggableHudComponent) component;
                if (draggable.isDragging()) {
                    RenderUtil.drawRect(draggable.getX(), draggable.getY(), draggable.getX() + draggable.getW(), draggable.getY() + draggable.getH(), 0x35FFFFFF);
                    for (HudComponent other : Seppuku.INSTANCE.getHudManager().getComponentList()) {
                        if (other != draggable && draggable.collidesWith(other) && other.isVisible() && draggable.isSnappable()) {
                            RenderUtil.drawRect(draggable.getX(), draggable.getY(), draggable.getX() + draggable.getW(), draggable.getY() + draggable.getH(), 0x3510FF10);
                            RenderUtil.drawRect(other.getX(), other.getY(), other.getX() + other.getW(), other.getY() + other.getH(), 0x35FF1010);
                        }
                    }
                }
            }
        }
    }
}
 
Example #21
Source File: TooltipOverlayHandler.java    From IGW-mod with GNU General Public License v2.0 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END && TickHandler.showTooltip() && ConfigHandler.shouldShowTooltip && FMLClientHandler.instance().getClient().inGameHasFocus && IGWMod.proxy.getPlayer().world != null) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String objectName = TickHandler.getCurrentObjectName();
        String moreInfo = "'" + Keyboard.getKeyName(ClientProxy.openInterfaceKey.getKeyCode()) + "' for more info";
        fontRenderer.drawString(objectName, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(objectName) / 2, sr.getScaledHeight() / 2 - 20, 0xFFFFFFFF);
        fontRenderer.drawString(moreInfo, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(moreInfo) / 2, sr.getScaledHeight() / 2 - 10, 0xFFFFFFFF);
    }
}
 
Example #22
Source File: HyperiumGuiIngame.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void renderGameOverlay(float part) {
    Minecraft.getMinecraft().mcProfiler.startSection("hyperium_overlay");
    EventBus.INSTANCE.post(new RenderHUDEvent(new ScaledResolution(Minecraft.getMinecraft()), part));
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    Minecraft.getMinecraft().mcProfiler.endSection();

}
 
Example #23
Source File: BackgroundShader.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateUniforms() {
    final ScaledResolution scaledResolution = new ScaledResolution(mc);

    final int resolutionID = getUniform("iResolution");
    if(resolutionID > -1)
        GL20.glUniform2f(resolutionID, (float) scaledResolution.getScaledWidth() * 2, (float) scaledResolution.getScaledHeight() * 2);
    final int timeID = getUniform("iTime");
    if(timeID > -1) GL20.glUniform1f(timeID, time);

    time += 0.005F * RenderUtils.deltaTime;
}
 
Example #24
Source File: MixinMinecraft.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "displayGuiScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;currentScreen:Lnet/minecraft/client/gui/GuiScreen;", shift = At.Shift.AFTER))
private void displayGuiScreen(CallbackInfo callbackInfo) {
    if(currentScreen instanceof net.minecraft.client.gui.GuiMainMenu || (currentScreen != null && currentScreen.getClass().getName().startsWith("net.labymod") && currentScreen.getClass().getSimpleName().equals("ModGuiMainMenu"))) {
        currentScreen = new GuiMainMenu();

        ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
        currentScreen.setWorldAndResolution(Minecraft.getMinecraft(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());
        skipRenderWorld = false;
    }

    LiquidBounce.eventManager.callEvent(new ScreenEvent(currentScreen));
}
 
Example #25
Source File: ClientEventHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END && FMLClientHandler.instance().getClient().inGameHasFocus && PneumaticCraft.proxy.getPlayer().worldObj != null && (ModuleRegulatorTube.inverted || !ModuleRegulatorTube.inLine)) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String warning = EnumChatFormatting.RED + I18n.format("gui.regulatorTube.hudMessage." + (ModuleRegulatorTube.inverted ? "inverted" : "notInLine"));
        fontRenderer.drawStringWithShadow(warning, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(warning) / 2, sr.getScaledHeight() / 2 + 30, 0xFFFFFFFF);
    }
}
 
Example #26
Source File: MixinGuiInGame.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "renderTooltip", at = @At("RETURN"))
private void renderTooltipPost(ScaledResolution sr, float partialTicks, CallbackInfo callbackInfo) {
    if (!ClassUtils.hasClass("net.labymod.api.LabyModAPI")) {
        LiquidBounce.eventManager.callEvent(new Render2DEvent(partialTicks));
        AWTFontRenderer.Companion.garbageCollectionTick();
    }
}
 
Example #27
Source File: HyperiumGuiIngame.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void renderScoreboard(ScoreObjective objective, ScaledResolution resolution) {
    //For *extra* scoreboards
    ScoreboardDisplay.objective = objective;
    ScoreboardDisplay.resolution = resolution;

    if (renderScoreboard) Hyperium.INSTANCE.getHandlers().getScoreboardRenderer().render(objective, resolution);
}
 
Example #28
Source File: HyperiumFontRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public HyperiumFontRenderer(String fontName, float fontSize) {
    name = fontName;
    size = fontSize;
    ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft());

    try {
        prevScaleFactor = resolution.getScaleFactor();
        unicodeFont = new UnicodeFont(getFontByName(fontName).deriveFont(fontSize * prevScaleFactor / 2));
        unicodeFont.addAsciiGlyphs();
        unicodeFont.getEffects().add(new ColorEffect(java.awt.Color.WHITE));
        unicodeFont.loadGlyphs();
    } catch (FontFormatException | IOException | SlickException e) {
        e.printStackTrace();
    }

    this.antiAliasingFactor = resolution.getScaleFactor();
}
 
Example #29
Source File: HyperiumOverlay.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void mouseClicked() {
    ScaledResolution sr = ResolutionUtil.current();
    int sw = sr.getScaledWidth();
    int sh = sr.getScaledHeight();
    int mx = Mouse.getX() * sw / Minecraft.getMinecraft().displayWidth;
    int my = sh - Mouse.getY() * sh / Minecraft.getMinecraft().displayHeight - 1;

    Integer[] counter = new Integer[]{0};

    components.forEach(c -> c.mouseClicked(mx, my, sr.getScaledWidth() / 6 * 2,
        sr.getScaledHeight() / 4 + 20 * counter[0]++ + offsetY, sr.getScaledWidth() / 6 * 2, 20));
}
 
Example #30
Source File: GuiHudConfiguration.java    From Cyberware with MIT License 5 votes vote down vote up
public static void setYFromAbsolute(ScaledResolution sr, IHudElement element, int y)
{
	if (element.getVerticalAnchor() == EnumAnchorVertical.BOTTOM)
	{
		element.setY(sr.getScaledHeight() - y - element.getHeight());
	}
	else
	{
		element.setY(y);
	}
}