Search in sources :

Example 1 with MainWindow

use of net.minecraft.client.MainWindow in project polymer-core by teampolymer.

the class SchematicViewOverlay method renderOverlay.

public void renderOverlay(MatrixStack ms, float pt) {
    Minecraft mc = Minecraft.getInstance();
    MainWindow mainWindow = mc.getWindow();
    if (!initialized)
        init(mc, mainWindow.getGuiScaledWidth(), mainWindow.getGuiScaledHeight());
    int x = (mainWindow.getGuiScaledWidth() - w) / 2 + 15;
    int y = mainWindow.getGuiScaledHeight() - h - 75;
    ms.pushPose();
    ms.translate(0, -yOffset, focused ? 100 : 0);
    IGuiResource gray = GuiResources.TOOLBAR_BACKGROUND;
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.color4f(1, 1, 1, focused ? 3 / 4f : .3f);
    Minecraft.getInstance().getTextureManager().bind(gray.getLocation());
    blit(ms, x - 15, y, gray.getStartX(), gray.getStartY(), w, h, gray.getWidth(), gray.getHeight());
    float toolTipAlpha = yOffset / 10;
    List<ITextComponent> toolTip = currentAction().getDescription();
    int stringAlphaComponent = ((int) (toolTipAlpha * 0xFF)) << 24;
    if (toolTipAlpha > 0.25f) {
        int height = h + 22 + 10 * (toolTip.size() - 1);
        boolean disabled = !currentAction().isEnabled();
        if (disabled) {
            height += 12;
        }
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(.7f, .7f, .8f, toolTipAlpha);
        blit(ms, x - 15, y, gray.getStartX(), gray.getStartY(), w, height, gray.getWidth(), gray.getHeight());
        RenderSystem.color4f(1, 1, 1, 1);
        RenderSystem.disableBlend();
        int yOff = y;
        if (toolTip.size() > 0) {
            yOff += 38;
            font.draw(ms, toolTip.get(0), x - 10, yOff, 0xEEEEEE + stringAlphaComponent);
        }
        if (toolTip.size() > 1) {
            yOff += 12;
            font.draw(ms, toolTip.get(1), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (toolTip.size() > 2) {
            yOff += 10;
            font.draw(ms, toolTip.get(2), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (toolTip.size() > 3) {
            yOff += 10;
            font.draw(ms, toolTip.get(3), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (disabled) {
            yOff += 12;
            font.draw(ms, new TranslationTextComponent("gui.polymer.locator.control.misc.disabled"), x - 10, yOff, 0xCCCCDD + stringAlphaComponent);
        }
    }
    RenderSystem.color4f(1, 1, 1, 1);
    if (actions.length > 1) {
        String keyName = KeysRegistry.TOOL_CTRL_KEY.getTranslatedKeyMessage().getString().toUpperCase(Locale.ROOT);
        int width = minecraft.getWindow().getGuiScaledWidth();
        if (!focused)
            drawCenteredString(ms, font, I18n.get(holdToFocus, keyName), width / 2, y - 10, 0xCCDDFF);
        else
            drawCenteredString(ms, font, scrollToCycle, width / 2, y - 10, 0xCCDDFF);
    } else {
        x += 65;
    }
    for (int i = 0; i < actions.length; i++) {
        ms.pushPose();
        float alpha = focused ? 1 : .2f;
        if (i == current) {
            ms.translate(0, -10, 0);
            drawCenteredString(ms, font, actions[i].getName(), x + i * 40 + 24, y + 28, 0xCCDDFF);
            alpha = 1;
        }
        IGuiResource icon = actions[i].getIcon();
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(0, 0, 0, alpha * .2f);
        icon.draw(ms, 0, x + i * 40 + 17, y + 12);
        if (actions[i].isEnabled()) {
            RenderSystem.color4f(1, 1, 1, alpha);
        } else {
            RenderSystem.color4f(.7f, .7f, .7f, alpha);
        }
        icon.draw(ms, 0, x + i * 40 + 16, y + 11);
        ms.popPose();
    }
    RenderSystem.disableBlend();
    RenderSystem.defaultBlendFunc();
    ms.popPose();
}
Also used : MainWindow(net.minecraft.client.MainWindow) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Minecraft(net.minecraft.client.Minecraft) IGuiResource(com.teampolymer.polymer.core.client.resources.IGuiResource)

Example 2 with MainWindow

use of net.minecraft.client.MainWindow in project iChunUtil by iChun.

the class RenderHelper method renderTestStencil.

public static void renderTestStencil(MatrixStack stack) {
    // Basic stencil test
    Minecraft mc = Minecraft.getInstance();
    MainWindow reso = mc.getMainWindow();
    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GlStateManager.colorMask(false, false, false, false);
    GlStateManager.depthMask(false);
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    GlStateManager.clear(GL11.GL_STENCIL_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
    RenderHelper.drawColour(stack, 0xffffff, 255, 0, 0, 60, 60, 0);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 0, 0xFF);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
    RenderHelper.drawColour(stack, 0xffffff, 255, 0, 0, reso.getScaledWidth(), reso.getScaledHeight(), 0);
    GL11.glDisable(GL11.GL_STENCIL_TEST);
}
Also used : MainWindow(net.minecraft.client.MainWindow) Minecraft(net.minecraft.client.Minecraft)

Example 3 with MainWindow

use of net.minecraft.client.MainWindow in project WarDance by Jackiecrazy.

the class RenderEvents method displayCoolie.

@SubscribeEvent
public static void displayCoolie(RenderGameOverlayEvent.Post event) {
    MainWindow sr = event.getWindow();
    final Minecraft mc = Minecraft.getInstance();
    final MatrixStack stack = event.getMatrixStack();
    if (GeneralConfig.dual) {
        if (event.getType().equals(RenderGameOverlayEvent.ElementType.CROSSHAIRS)) {
            // draw offhand cooldown, crosshair type
            {
                GameSettings gamesettings = mc.options;
                if (gamesettings.getCameraType() == PointOfView.FIRST_PERSON) {
                    int width = sr.getGuiScaledWidth();
                    int height = sr.getGuiScaledHeight();
                    ClientPlayerEntity player = mc.player;
                    if (player == null)
                        return;
                    if (!gamesettings.renderDebug || gamesettings.hideGui || player.isReducedDebugInfo() || gamesettings.reducedDebugInfo) {
                        if (mc.options.attackIndicator == AttackIndicatorStatus.CROSSHAIR) {
                            GlStateManager._enableAlphaTest();
                            float cooldown = CombatUtils.getCooledAttackStrength(player, Hand.OFF_HAND, 0f);
                            boolean hyperspeed = false;
                            if (getEntityLookedAt(player, GeneralUtils.getAttributeValueHandSensitive(player, ForgeMod.REACH_DISTANCE.get(), Hand.OFF_HAND)) != null && cooldown >= 1.0F) {
                                hyperspeed = CombatUtils.getCooldownPeriod(player, Hand.OFF_HAND) > 5.0F;
                                hyperspeed = hyperspeed & (getEntityLookedAt(player, GeneralUtils.getAttributeValueHandSensitive(player, ForgeMod.REACH_DISTANCE.get(), Hand.OFF_HAND))).isAlive();
                            }
                            int y = height / 2 - 7 - 7;
                            int x = width / 2 - 8;
                            if (hyperspeed) {
                                mc.gui.blit(stack, x, y, 68, 94, 16, 16);
                            } else if (cooldown < 1.0F) {
                                int k = (int) (cooldown * 17.0F);
                                mc.gui.blit(stack, x, y, 36, 94, 16, 4);
                                mc.gui.blit(stack, x, y, 52, 94, k, 4);
                            }
                        }
                    }
                }
            }
        }
        if (event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) {
            // draw offhand cooldown, hotbar type
            if (mc.getCameraEntity() instanceof PlayerEntity) {
                GlStateManager._clearColor(1.0F, 1.0F, 1.0F, 1.0F);
                PlayerEntity p = (PlayerEntity) mc.getCameraEntity();
                ItemStack itemstack = p.getOffhandItem();
                HandSide oppositeHand = p.getMainArm().getOpposite();
                int halfOfScreen = sr.getGuiScaledWidth() / 2;
                GlStateManager._enableRescaleNormal();
                RenderSystem.enableBlend();
                RenderSystem.defaultBlendFunc();
                RenderHelper.turnBackOn();
                if (mc.options.attackIndicator == AttackIndicatorStatus.HOTBAR) {
                    float strength = CombatUtils.getCooledAttackStrength(p, Hand.OFF_HAND, 0);
                    if (strength < 1.0F) {
                        int y = sr.getGuiScaledHeight() - 20;
                        int x = halfOfScreen + 91 + 6;
                        if (oppositeHand == HandSide.LEFT) {
                            x = halfOfScreen - 91 - 22;
                        }
                        mc.getTextureManager().bind(AbstractGui.GUI_ICONS_LOCATION);
                        int modStrength = (int) (strength * 19.0F);
                        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
                        mc.gui.blit(stack, x + 18, y, 0, 94, 18, 18);
                        mc.gui.blit(stack, x + 18, y + 18 - modStrength, 18, 112 - modStrength, 18, modStrength);
                    }
                }
                RenderHelper.turnOff();
                RenderSystem.disableBlend();
            }
        }
    }
    if (event.getType().equals(RenderGameOverlayEvent.ElementType.ALL))
        if (mc.getCameraEntity() instanceof PlayerEntity) {
            ClientPlayerEntity player = mc.player;
            ICombatCapability cap = CombatData.getCap(player);
            int width = sr.getGuiScaledWidth();
            int height = sr.getGuiScaledHeight();
            mc.getTextureManager().bind(raihud);
            currentSpiritLevel = updateValue(currentSpiritLevel, cap.getSpirit());
            currentMightLevel = updateValue(currentMightLevel, cap.getMight());
            currentComboLevel = cap.getRank() > currentComboLevel ? updateValue(currentComboLevel, cap.getRank()) : cap.getRank();
            // yourCurrentPostureLevel = updateValue(yourCurrentPostureLevel, cap.getPosture());
            if (cap.isCombatMode()) {
                stack.pushPose();
                RenderSystem.enableBlend();
                RenderSystem.enableAlphaTest();
                Pair<Integer, Integer> pair = translateCoords(ClientConfig.CONFIG.might, width, height);
                int x = Math.max(pair.getFirst() - 16, 0);
                int y = Math.min(pair.getSecond() - 16, height - 32);
                int fillHeight = (int) (Math.min(1, currentMightLevel / cap.getMaxMight()) * 32);
                if (ClientConfig.CONFIG.might.enabled) {
                    // might circle
                    RenderSystem.color4f(1, 1, 1, 1);
                    stack.pushPose();
                    stack.pushPose();
                    mc.gui.blit(stack, x, y, 0, 64, 32, 32);
                    stack.popPose();
                    // might circle filling
                    stack.pushPose();
                    mc.gui.blit(stack, x, y + 32 - fillHeight, 0, 96 - fillHeight, 32, fillHeight);
                    stack.popPose();
                    fillHeight += Math.min(fillHeight, 3);
                    fillHeight = Math.min(fillHeight, 32);
                    // might base
                    stack.pushPose();
                    mc.gui.blit(stack, x, y, 32, 64, 32, 32);
                    stack.popPose();
                    // might illumination
                    stack.pushPose();
                    mc.gui.blit(stack, x, y + 32 - fillHeight, 64, 96 - fillHeight, 32, fillHeight);
                    stack.popPose();
                    stack.popPose();
                }
                pair = translateCoords(ClientConfig.CONFIG.spirit, width, height);
                x = MathHelper.clamp(pair.getFirst() - 16, 0, width - 32);
                y = MathHelper.clamp(pair.getSecond() - 16, 0, height - 32);
                fillHeight = (int) (Math.min(1, currentSpiritLevel / cap.getMaxSpirit()) * 32);
                String display = formatter.format(currentSpiritLevel) + "/" + formatter.format(cap.getMaxSpirit());
                // spirit circle
                stack.pushPose();
                if (ClientConfig.CONFIG.spirit.enabled) {
                    stack.pushPose();
                    mc.gui.blit(stack, x, y, 0, 96, 32, 32);
                    stack.popPose();
                    // spirit circle filling
                    stack.pushPose();
                    mc.gui.blit(stack, x, y + 32 - fillHeight, 0, 128 - fillHeight, 32, fillHeight);
                    stack.popPose();
                    fillHeight += Math.min(fillHeight, 3);
                    fillHeight = Math.min(fillHeight, 32);
                    // spirit base
                    stack.pushPose();
                    mc.gui.blit(stack, x, y + 1, 32, 96, 32, 32);
                    stack.popPose();
                    // spirit illumination
                    stack.pushPose();
                    mc.gui.blit(stack, x, y + 33 - fillHeight, 64, 128 - fillHeight, 32, fillHeight);
                    stack.popPose();
                }
                if (ClientConfig.CONFIG.spiritNumber.enabled) {
                    pair = translateCoords(ClientConfig.CONFIG.spiritNumber, width, height);
                    mc.font.drawShadow(event.getMatrixStack(), display, pair.getFirst() - mc.font.width(display) / 2f, pair.getSecond() - 2, ClientConfig.spiritColor);
                }
                if (ClientConfig.CONFIG.mightNumber.enabled) {
                    pair = translateCoords(ClientConfig.CONFIG.mightNumber, width, height);
                    display = formatter.format(currentMightLevel) + "/" + formatter.format(cap.getMaxMight());
                    mc.font.drawShadow(event.getMatrixStack(), display, pair.getFirst() - mc.font.width(display) / 2f, pair.getSecond() - 2, ClientConfig.mightColor);
                }
                stack.popPose();
                RenderSystem.disableAlphaTest();
                RenderSystem.disableBlend();
                stack.popPose();
                // combo bar at 224,20 to 229, 121. Grace at 222,95 to 224, 121
                // initial bar
                RenderSystem.enableBlend();
                stack.pushPose();
                if (ClientConfig.CONFIG.combo.enabled) {
                    mc.getTextureManager().bind(raihud);
                    int combowidth = 32;
                    float workingCombo = currentComboLevel;
                    int comboU = (int) (MathHelper.clamp(Math.floor(workingCombo), 0, 4)) * 32;
                    int divisor = 1;
                    if (// S
                    workingCombo >= 4)
                        divisor = 2;
                    if (workingCombo >= 6) {
                        // SS
                        combowidth = 33;
                        comboU = 159;
                        divisor = 3;
                    }
                    if (workingCombo >= 9) {
                        // SSS
                        combowidth = 64;
                        comboU = 192;
                        fillHeight = (int) ((workingCombo - 9) * 32f);
                    } else if (divisor > 1)
                        fillHeight = (int) ((workingCombo - divisor * 2) / divisor * 32f);
                    else
                        fillHeight = (int) ((workingCombo - Math.floor(workingCombo)) * 32f);
                    pair = translateCoords(ClientConfig.CONFIG.combo, width, height);
                    x = MathHelper.clamp(pair.getFirst() - combowidth / 2, 0, width - combowidth);
                    y = MathHelper.clamp(pair.getSecond() - 23, 0, height - 46);
                    mc.gui.blit(stack, x, y, comboU, 0, combowidth, 32);
                    // fancy fill percentage
                    mc.gui.blit(stack, x, y + 33 - fillHeight, comboU, 65 - fillHeight, combowidth, fillHeight - 2);
                }
                stack.popPose();
                RenderSystem.disableBlend();
            }
            mc.getTextureManager().bind(amo);
            // render posture bar if not full, displayed even out of combat mode because it's pretty relevant to not dying
            if (cap.isCombatMode() || cap.getPosture() < cap.getMaxPosture() || cap.getStaggerTime() > 0 || cap.getShatterCooldown() < Math.floor(GeneralUtils.getAttributeValueSafe(player, WarAttributes.SHATTER.get())) || cap.getBarrier() < cap.getMaxBarrier())
                drawPostureBarAt(true, stack, player, width, height);
            Entity look = getEntityLookedAt(player, 32);
            if (look instanceof LivingEntity) {
                LivingEntity looked = (LivingEntity) look;
                List<Skill> afflict = new ArrayList<>();
                final ISkillCapability skill = CasterData.getCap(player);
                if (ClientConfig.CONFIG.enemyAfflict.enabled) {
                    // coup de grace
                    final Skill variant = skill.getEquippedVariation(SkillCategories.coup_de_grace);
                    if (look != player && skill.isSkillUsable(variant)) {
                        CoupDeGrace cdg = (CoupDeGrace) variant;
                        if (cdg.willKillOnCast(player, looked)) {
                            afflict.add(cdg);
                        }
                    }
                    // marks
                    afflict.addAll(Marks.getCap(looked).getActiveMarks().keySet());
                    Pair<Integer, Integer> pair = translateCoords(ClientConfig.CONFIG.enemyAfflict, width, height);
                    for (int index = 0; index < afflict.size(); index++) {
                        Skill s = afflict.get(index);
                        mc.getTextureManager().bind(s.icon());
                        Color c = s.getColor();
                        RenderSystem.color4f(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1);
                        AbstractGui.blit(stack, pair.getFirst() - (afflict.size() - 1 - index) * 16 + (afflict.size() - 1) * 8 - 8, pair.getSecond(), 0, 0, 16, 16, 16, 16);
                    }
                }
                stealth: if (ClientConfig.CONFIG.stealth.enabled && cap.isCombatMode()) {
                    Pair<Integer, Integer> pair = translateCoords(ClientConfig.CONFIG.stealth, width, height);
                    final Tuple<StealthUtils.Awareness, Double> info = stealthInfo(looked);
                    double dist = info.getB();
                    int shift = 0;
                    switch(info.getA()) {
                        case ALERT:
                            break stealth;
                        case DISTRACTED:
                            shift = 1;
                            break;
                        case UNAWARE:
                            shift = looked.distanceToSqr(player) < dist * dist ? 2 : 3;
                            break;
                    }
                    renderEye(looked, event.getPartialTicks(), stack);
                    mc.getTextureManager().bind(stealth);
                    AbstractGui.blit(stack, pair.getFirst() - 16, pair.getSecond() - 8, 0, shift * 16, 32, 16, 64, 64);
                }
                RenderSystem.color4f(1, 1, 1, 1);
                if (ClientConfig.CONFIG.enemyPosture.enabled && (cap.isCombatMode() || CombatData.getCap((LivingEntity) look).getPosture() < CombatData.getCap((LivingEntity) look).getMaxPosture() || CombatData.getCap((LivingEntity) look).getStaggerTime() > 0 || cap.getShatterCooldown() < GeneralUtils.getAttributeValueSafe(player, WarAttributes.SHATTER.get()) || cap.getBarrier() < cap.getMaxBarrier()))
                    // Math.min(HudConfig.client.enemyPosture.x, width - 64), Math.min(HudConfig.client.enemyPosture.y, height - 64));
                    drawPostureBarAt(false, stack, looked, width, height);
            }
        }
}
Also used : PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) Entity(net.minecraft.entity.Entity) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) CoupDeGrace(jackiecrazy.wardance.skill.coupdegrace.CoupDeGrace) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) MainWindow(net.minecraft.client.MainWindow) List(java.util.List) ArrayList(java.util.ArrayList) GameSettings(net.minecraft.client.GameSettings) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) Pair(com.mojang.datafixers.util.Pair) HandSide(net.minecraft.util.HandSide) Minecraft(net.minecraft.client.Minecraft) ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability) Skill(jackiecrazy.wardance.skill.Skill) ISkillCapability(jackiecrazy.wardance.capability.skill.ISkillCapability) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with MainWindow

use of net.minecraft.client.MainWindow in project Mekanism by mekanism.

the class RenderTickHandler method renderOverlay.

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
    if (event.getType() == ElementType.HOTBAR) {
        if (!minecraft.player.isSpectator() && MekanismConfig.client.enableHUD.get() && MekanismClient.renderHUD) {
            int count = 0;
            Map<EquipmentSlotType, List<ITextComponent>> renderStrings = new LinkedHashMap<>();
            for (EquipmentSlotType slotType : EQUIPMENT_ORDER) {
                ItemStack stack = minecraft.player.getItemBySlot(slotType);
                if (stack.getItem() instanceof IItemHUDProvider) {
                    List<ITextComponent> list = new ArrayList<>();
                    ((IItemHUDProvider) stack.getItem()).addHUDStrings(list, minecraft.player, stack, slotType);
                    int size = list.size();
                    if (size > 0) {
                        renderStrings.put(slotType, list);
                        count += size;
                    }
                }
            }
            MatrixStack matrix = event.getMatrixStack();
            if (count > 0) {
                int start = (renderStrings.size() * 2) + (count * 9);
                boolean alignLeft = MekanismConfig.client.alignHUDLeft.get();
                MainWindow window = event.getWindow();
                int y = window.getGuiScaledHeight();
                float hudScale = MekanismConfig.client.hudScale.get();
                int yScale = (int) ((1 / hudScale) * y);
                matrix.pushPose();
                matrix.scale(hudScale, hudScale, hudScale);
                for (Map.Entry<EquipmentSlotType, List<ITextComponent>> entry : renderStrings.entrySet()) {
                    for (ITextComponent text : entry.getValue()) {
                        drawString(window, matrix, text, alignLeft, yScale - start, 0xC8C8C8);
                        start -= 9;
                    }
                    start -= 2;
                }
                matrix.popPose();
            }
            if (minecraft.player.getItemBySlot(EquipmentSlotType.HEAD).getItem() instanceof ItemMekaSuitArmor) {
                hudRenderer.renderHUD(matrix, event.getPartialTicks());
            }
        }
    } else if (event.getType() == ElementType.ARMOR) {
        FloatingLong capacity = FloatingLong.ZERO, stored = FloatingLong.ZERO;
        for (ItemStack stack : minecraft.player.inventory.armor) {
            if (stack.getItem() instanceof ItemMekaSuitArmor) {
                IEnergyContainer container = StorageUtils.getEnergyContainer(stack, 0);
                if (container != null) {
                    capacity = capacity.plusEqual(container.getMaxEnergy());
                    stored = stored.plusEqual(container.getEnergy());
                }
            }
        }
        if (!capacity.isZero()) {
            int x = event.getWindow().getGuiScaledWidth() / 2 - 91;
            int y = event.getWindow().getGuiScaledHeight() - ForgeIngameGui.left_height + 2;
            int length = (int) Math.round(stored.divide(capacity).doubleValue() * 79);
            MatrixStack matrix = event.getMatrixStack();
            GuiUtils.renderExtendedTexture(matrix, GuiBar.BAR, 2, 2, x, y, 81, 6);
            minecraft.getTextureManager().bind(POWER_BAR);
            AbstractGui.blit(matrix, x + 1, y + 1, length, 4, 0, 0, length, 4, 79, 4);
            minecraft.getTextureManager().bind(AbstractGui.GUI_ICONS_LOCATION);
            ForgeIngameGui.left_height += 8;
        }
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IItemHUDProvider(mekanism.common.item.interfaces.IItemHUDProvider) FloatingLong(mekanism.api.math.FloatingLong) IEnergyContainer(mekanism.api.energy.IEnergyContainer) MainWindow(net.minecraft.client.MainWindow) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 5 with MainWindow

use of net.minecraft.client.MainWindow in project mxTune by AeronicaMC.

the class MXExtendedList method render.

public void render(MatrixStack pMatrixStack, int pMouseX, int pMouseY, float pPartialTicks) {
    renderBorder(pMatrixStack, pMouseX, pMouseY);
    MainWindow client = minecraft.getWindow();
    double scaleW = (double) client.getWidth() / client.getGuiScaledWidth();
    double scaleH = (double) client.getHeight() / client.getGuiScaledHeight();
    RenderSystem.enableScissor((int) (this.x0 * scaleW), (int) (client.getScreenHeight() - (y1 * scaleH)), (int) ((x1 - x0) * scaleW), (int) ((y1 - y0) * scaleH));
    this.renderBackground(pMatrixStack);
    int i = this.getScrollbarPosition();
    int j = i + 6;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuilder();
    if (this.renderBackground) {
        this.minecraft.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION);
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        float f = 32.0F;
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        bufferbuilder.vertex((double) this.x0, (double) this.y1, 0.0D).uv((float) this.x0 / 32.0F, (float) (this.y1 + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) this.y1, 0.0D).uv((float) this.x1 / 32.0F, (float) (this.y1 + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) this.y0, 0.0D).uv((float) this.x1 / 32.0F, (float) (this.y0 + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) this.y0, 0.0D).uv((float) this.x0 / 32.0F, (float) (this.y0 + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).endVertex();
        tessellator.end();
    }
    int j1 = this.getRowLeft();
    int k = this.y0 + 4 - (int) this.getScrollAmount();
    this.renderList(pMatrixStack, j1, k, pMouseX, pMouseY, pPartialTicks);
    if (this.renderTopAndBottom) {
        this.minecraft.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION);
        RenderSystem.enableDepthTest();
        RenderSystem.depthFunc(519);
        float f1 = 32.0F;
        int l = -100;
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        bufferbuilder.vertex((double) this.x0, (double) this.y0, -100.0D).uv(0.0F, (float) this.y0 / 32.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) (this.x0 + this.width), (double) this.y0, -100.0D).uv((float) this.width / 32.0F, (float) this.y0 / 32.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) (this.x0 + this.width), 0.0D, -100.0D).uv((float) this.width / 32.0F, 0.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, 0.0D, -100.0D).uv(0.0F, 0.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) this.height, -100.0D).uv(0.0F, (float) this.height / 32.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) (this.x0 + this.width), (double) this.height, -100.0D).uv((float) this.width / 32.0F, (float) this.height / 32.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) (this.x0 + this.width), (double) this.y1, -100.0D).uv((float) this.width / 32.0F, (float) this.y1 / 32.0F).color(64, 64, 64, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) this.y1, -100.0D).uv(0.0F, (float) this.y1 / 32.0F).color(64, 64, 64, 255).endVertex();
        tessellator.end();
        RenderSystem.depthFunc(515);
        RenderSystem.disableDepthTest();
        RenderSystem.enableBlend();
        RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
        RenderSystem.disableAlphaTest();
        RenderSystem.shadeModel(7425);
        RenderSystem.disableTexture();
        int i1 = 4;
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        bufferbuilder.vertex((double) this.x0, (double) (this.y0 + 4), 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 0).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) (this.y0 + 4), 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 0).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) this.y0, 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) this.y0, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) this.y1, 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) this.y1, 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) this.x1, (double) (this.y1 - 4), 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 0).endVertex();
        bufferbuilder.vertex((double) this.x0, (double) (this.y1 - 4), 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 0).endVertex();
        tessellator.end();
    }
    int k1 = this.getMaxScroll();
    if (k1 > 0) {
        RenderSystem.disableTexture();
        int l1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) / (float) this.getMaxPosition());
        l1 = MathHelper.clamp(l1, 32, this.y1 - this.y0 - 8);
        int i2 = (int) this.getScrollAmount() * (this.y1 - this.y0 - l1) / k1 + this.y0;
        if (i2 < this.y0) {
            i2 = this.y0;
        }
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        bufferbuilder.vertex((double) i, (double) this.y1, 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) j, (double) this.y1, 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) j, (double) this.y0, 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) i, (double) this.y0, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
        bufferbuilder.vertex((double) i, (double) (i2 + l1), 0.0D).uv(0.0F, 1.0F).color(128, 128, 128, 255).endVertex();
        bufferbuilder.vertex((double) j, (double) (i2 + l1), 0.0D).uv(1.0F, 1.0F).color(128, 128, 128, 255).endVertex();
        bufferbuilder.vertex((double) j, (double) i2, 0.0D).uv(1.0F, 0.0F).color(128, 128, 128, 255).endVertex();
        bufferbuilder.vertex((double) i, (double) i2, 0.0D).uv(0.0F, 0.0F).color(128, 128, 128, 255).endVertex();
        bufferbuilder.vertex((double) i, (double) (i2 + l1 - 1), 0.0D).uv(0.0F, 1.0F).color(192, 192, 192, 255).endVertex();
        bufferbuilder.vertex((double) (j - 1), (double) (i2 + l1 - 1), 0.0D).uv(1.0F, 1.0F).color(192, 192, 192, 255).endVertex();
        bufferbuilder.vertex((double) (j - 1), (double) i2, 0.0D).uv(1.0F, 0.0F).color(192, 192, 192, 255).endVertex();
        bufferbuilder.vertex((double) i, (double) i2, 0.0D).uv(0.0F, 0.0F).color(192, 192, 192, 255).endVertex();
        tessellator.end();
    }
    RenderSystem.disableScissor();
    this.renderDecorations(pMatrixStack, pMouseX, pMouseY);
    RenderSystem.enableTexture();
    RenderSystem.shadeModel(7424);
    RenderSystem.enableAlphaTest();
    RenderSystem.disableBlend();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) MainWindow(net.minecraft.client.MainWindow) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Aggregations

MainWindow (net.minecraft.client.MainWindow)5 Minecraft (net.minecraft.client.Minecraft)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ItemStack (net.minecraft.item.ItemStack)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 Pair (com.mojang.datafixers.util.Pair)1 IGuiResource (com.teampolymer.polymer.core.client.resources.IGuiResource)1 ICombatCapability (jackiecrazy.wardance.capability.resources.ICombatCapability)1 ISkillCapability (jackiecrazy.wardance.capability.skill.ISkillCapability)1 Skill (jackiecrazy.wardance.skill.Skill)1 CoupDeGrace (jackiecrazy.wardance.skill.coupdegrace.CoupDeGrace)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 IEnergyContainer (mekanism.api.energy.IEnergyContainer)1 FloatingLong (mekanism.api.math.FloatingLong)1