Search in sources :

Example 16 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenRefractionTable method render.

@Override
public void render(MatrixStack renderStack, int mouseX, int mouseY, float pTicks) {
    RenderSystem.enableDepthTest();
    super.render(renderStack, mouseX, mouseY, pTicks);
    this.mapRenderedConstellations.clear();
    if (this.getTile().hasParchment()) {
        this.drawWHRect(renderStack, TexturesAS.TEX_GUI_REFRACTION_TABLE_PARCHMENT);
    } else {
        this.drawWHRect(renderStack, TexturesAS.TEX_GUI_REFRACTION_TABLE_EMPTY);
    }
    if (DayTimeHelper.getCurrentDaytimeDistribution(this.getTile().getWorld()) <= 0.05 || !this.getTile().hasParchment()) {
        this.currentlyDrawnConstellations.clear();
        this.dragging = null;
    }
    List<ITextProperties> tooltip = new ArrayList<>();
    FontRenderer tooltipRenderer = Minecraft.getInstance().fontRenderer;
    tooltipRenderer = this.renderTileItems(renderStack, mouseX, mouseY, tooltip, tooltipRenderer);
    this.renderConstellationOptions(renderStack, mouseX, mouseY, tooltip);
    this.renderRunningHalo(renderStack);
    this.renderInputItem(renderStack);
    this.renderDrawnConstellations(renderStack, mouseX, mouseY, tooltip);
    this.renderDraggedConstellations(renderStack);
    this.renderDragging(renderStack, mouseX, mouseY);
    if (!tooltip.isEmpty()) {
        this.setBlitOffset(510);
        RenderingDrawUtils.renderBlueTooltipComponents(renderStack, mouseX, mouseY, this.getGuiZLevel(), tooltip, tooltipRenderer, true);
        this.setBlitOffset(0);
    }
}
Also used : ITextProperties(net.minecraft.util.text.ITextProperties) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 17 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenRefractionTable method renderConstellationOptions.

private void renderConstellationOptions(MatrixStack renderStack, int mouseX, int mouseY, List<ITextProperties> tooltip) {
    ItemStack glass = this.getTile().getGlassStack();
    if (glass.isEmpty()) {
        return;
    }
    World world = this.getTile().getWorld();
    float nightPerc = DayTimeHelper.getCurrentDaytimeDistribution(world);
    WorldContext ctx = SkyHandler.getContext(world, LogicalSide.CLIENT);
    if (ctx == null || !this.getTile().doesSeeSky() || nightPerc <= 0.05F) {
        return;
    }
    List<IConstellation> cstList = ctx.getActiveCelestialsHandler().getActiveConstellations().stream().filter(c -> ResearchHelper.getClientProgress().hasConstellationDiscovered(c)).collect(Collectors.toList());
    Random rand = new Random(WorldSeedCache.getSeedIfPresent(world.getDimensionKey()).orElse(0x515F1EB654AB915EL));
    for (int i = 0; i < ctx.getConstellationHandler().getLastTrackedDay(); i++) {
        rand.nextLong();
    }
    Collections.shuffle(cstList, rand);
    for (int i = 0; i < Math.min(cstList.size(), 12); i++) {
        IConstellation cst = cstList.get(i);
        int offsetX = guiLeft + (i % 2 == 0 ? 8 : 232);
        int offsetY = guiTop + (40 + (i / 2) * 23);
        Rectangle rct = new Rectangle(offsetX, offsetY, 16, 16);
        this.mapRenderedConstellations.put(rct, cst);
        RenderSystem.enableBlend();
        Blending.DEFAULT.apply();
        RenderingConstellationUtils.renderConstellationIntoGUI(Color.WHITE, cst, renderStack, offsetX, offsetY, this.getGuiZLevel(), 16, 16, 0.5, () -> DayTimeHelper.getCurrentDaytimeDistribution(world), true, false);
        RenderSystem.disableBlend();
        if (rct.contains(mouseX, mouseY)) {
            tooltip.add(cst.getConstellationName());
        }
    }
}
Also used : EngravedStarMap(hellfirepvp.astralsorcery.common.constellation.engraving.EngravedStarMap) java.util(java.util) TileEntityScreen(hellfirepvp.astralsorcery.client.screen.base.TileEntityScreen) hellfirepvp.astralsorcery.client.util(hellfirepvp.astralsorcery.client.util) SkyHandler(hellfirepvp.astralsorcery.common.constellation.SkyHandler) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) Supplier(java.util.function.Supplier) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) DayTimeHelper(hellfirepvp.astralsorcery.common.constellation.world.DayTimeHelper) Minecraft(net.minecraft.client.Minecraft) PktEngraveGlass(hellfirepvp.astralsorcery.common.network.play.client.PktEngraveGlass) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) TileRefractionTable(hellfirepvp.astralsorcery.common.tile.TileRefractionTable) GL11(org.lwjgl.opengl.GL11) PacketChannel(hellfirepvp.astralsorcery.common.network.PacketChannel) WorldSeedCache(hellfirepvp.astralsorcery.common.util.world.WorldSeedCache) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TexturesAS(hellfirepvp.astralsorcery.client.lib.TexturesAS) DrawnConstellation(hellfirepvp.astralsorcery.common.constellation.DrawnConstellation) LogicalSide(net.minecraftforge.fml.LogicalSide) ResearchHelper(hellfirepvp.astralsorcery.common.data.research.ResearchHelper) World(net.minecraft.world.World) ClientScheduler(hellfirepvp.astralsorcery.client.ClientScheduler) Tuple(net.minecraft.util.Tuple) ITextProperties(net.minecraft.util.text.ITextProperties) ItemInfusedGlass(hellfirepvp.astralsorcery.common.item.ItemInfusedGlass) Collectors(java.util.stream.Collectors) java.awt(java.awt) List(java.util.List) Matrix4f(net.minecraft.util.math.vector.Matrix4f) FontRenderer(net.minecraft.client.gui.FontRenderer) MathHelper(net.minecraft.util.math.MathHelper) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) SpritesAS(hellfirepvp.astralsorcery.client.lib.SpritesAS) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Example 18 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalConstellationDetail method buildRitualText.

private void buildRitualText() {
    if (this.constellation instanceof IMinorConstellation) {
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
            ITextComponent txtRitual = ((IMinorConstellation) this.constellation).getInfoTraitEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual.trait");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
        }
    } else if (this.constellation instanceof IWeakConstellation) {
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.ATTUNEMENT)) {
            ITextComponent txtRitual = ((IWeakConstellation) this.constellation).getInfoRitualEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.ritual");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
            locTextRitual.add(IReorderingProcessor.field_242232_a);
        }
        if (ResearchHelper.getClientProgress().getTierReached().isThisLaterOrEqual(ProgressionTier.TRAIT_CRAFT)) {
            ITextComponent txtCorruptedRitual = ((IWeakConstellation) this.constellation).getInfoCorruptedRitualEffect();
            ITextProperties headTxt = new TranslationTextComponent("astralsorcery.journal.constellation.corruption");
            locTextRitual.add(localize(headTxt));
            locTextRitual.add(IReorderingProcessor.field_242232_a);
            List<IReorderingProcessor> lines = new LinkedList<>();
            for (String segment : txtCorruptedRitual.getString().split("<NL>")) {
                lines.addAll(font.trimStringToWidth(new StringTextComponent(segment), JournalPage.DEFAULT_WIDTH));
                lines.add(IReorderingProcessor.field_242232_a);
            }
            locTextRitual.addAll(lines);
            locTextRitual.add(IReorderingProcessor.field_242232_a);
        }
    }
}
Also used : IReorderingProcessor(net.minecraft.util.IReorderingProcessor) ITextProperties(net.minecraft.util.text.ITextProperties) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) StringTextComponent(net.minecraft.util.text.StringTextComponent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)

Example 19 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class ScreenJournalConstellationDetail method drawPageExtendedInformation.

private void drawPageExtendedInformation(MatrixStack renderStack) {
    ITextProperties info = this.getConstellation().getConstellationTag();
    if (!detailed) {
        info = new TranslationTextComponent("astralsorcery.journal.constellation.unknown");
    }
    int width = font.getStringPropertyWidth(info);
    float chX = 305 - (width / 2F);
    renderStack.push();
    renderStack.translate(guiLeft + chX, guiTop + 44, this.getGuiZLevel());
    RenderingDrawUtils.renderStringAt(font, renderStack, info, 0xFFCCCCCC);
    renderStack.pop();
    if (detailed && !locTextMain.isEmpty()) {
        int offsetX = 220, offsetY = 77;
        renderStack.push();
        renderStack.translate(guiLeft + offsetX, guiTop + offsetY, this.getGuiZLevel());
        for (IReorderingProcessor line : locTextMain) {
            RenderingDrawUtils.renderStringAt(font, renderStack, line, 0xFFCCCCCC);
            renderStack.translate(0, 13, 0);
        }
        renderStack.pop();
    }
}
Also used : IReorderingProcessor(net.minecraft.util.IReorderingProcessor) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 20 with ITextProperties

use of net.minecraft.util.text.ITextProperties in project AstralSorcery by HellFirePvP.

the class RenderingDrawUtils method renderTooltip.

public static void renderTooltip(MatrixStack renderStack, float x, float y, float zLevel, List<Tuple<ItemStack, ITextProperties>> tooltipData, FontRenderer fontRenderer, boolean isFirstLineHeadline, int color, int colorFade, Color strColor) {
    int stackBoxSize = 18;
    if (!tooltipData.isEmpty()) {
        boolean anyItemFound = false;
        int maxWidth = 0;
        for (Tuple<ItemStack, ITextProperties> toolTip : tooltipData) {
            FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
            if (customFR == null) {
                customFR = fontRenderer;
            }
            int width = customFR.getStringPropertyWidth(toolTip.getB());
            if (!toolTip.getA().isEmpty()) {
                anyItemFound = true;
            }
            if (anyItemFound) {
                width += stackBoxSize;
            }
            if (width > maxWidth) {
                maxWidth = width;
            }
        }
        if (x + 15 + maxWidth > Minecraft.getInstance().getMainWindow().getScaledWidth()) {
            x -= maxWidth + 24;
        }
        int formatWidth = anyItemFound ? maxWidth - stackBoxSize : maxWidth;
        List<Tuple<ItemStack, List<IReorderingProcessor>>> lengthLimitedToolTip = new LinkedList<>();
        for (Tuple<ItemStack, ITextProperties> toolTip : tooltipData) {
            FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
            if (customFR == null) {
                customFR = fontRenderer;
            }
            List<IReorderingProcessor> textLines = customFR.trimStringToWidth(toolTip.getB(), formatWidth);
            if (textLines.isEmpty()) {
                textLines = Collections.singletonList(IReorderingProcessor.field_242232_a);
            }
            lengthLimitedToolTip.add(new Tuple<>(toolTip.getA(), textLines));
        }
        float pX = x + 12;
        float pY = y - 12;
        int sumLineHeight = 0;
        if (!lengthLimitedToolTip.isEmpty()) {
            if (lengthLimitedToolTip.size() > 1 && isFirstLineHeadline) {
                sumLineHeight += 2;
            }
            Iterator<Tuple<ItemStack, List<IReorderingProcessor>>> iterator = lengthLimitedToolTip.iterator();
            while (iterator.hasNext()) {
                Tuple<ItemStack, List<IReorderingProcessor>> toolTip = iterator.next();
                int segmentHeight = 0;
                if (!toolTip.getA().isEmpty()) {
                    segmentHeight += 2;
                    segmentHeight += stackBoxSize;
                    segmentHeight += (Math.max(toolTip.getB().size() - 1, 0)) * 10;
                } else {
                    segmentHeight += toolTip.getB().size() * 10;
                }
                if (!iterator.hasNext()) {
                    segmentHeight -= 2;
                }
                sumLineHeight += segmentHeight;
            }
        }
        drawGradientRect(renderStack, zLevel, pX - 3, pY - 4, pX + maxWidth + 3, pY - 3, color, colorFade);
        drawGradientRect(renderStack, zLevel, pX - 3, pY + sumLineHeight + 3, pX + maxWidth + 3, pY + sumLineHeight + 4, color, colorFade);
        drawGradientRect(renderStack, zLevel, pX - 3, pY - 3, pX + maxWidth + 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(renderStack, zLevel, pX - 4, pY - 3, pX - 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(renderStack, zLevel, pX + maxWidth + 3, pY - 3, pX + maxWidth + 4, pY + sumLineHeight + 3, color, colorFade);
        int col = (color & 0x00FFFFFF) | color & 0xFF000000;
        drawGradientRect(renderStack, zLevel, pX - 3, pY - 3 + 1, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, col);
        drawGradientRect(renderStack, zLevel, pX + maxWidth + 2, pY - 3 + 1, pX + maxWidth + 3, pY + sumLineHeight + 3 - 1, color, col);
        drawGradientRect(renderStack, zLevel, pX - 3, pY - 3, pX + maxWidth + 3, pY - 3 + 1, col, col);
        drawGradientRect(renderStack, zLevel, pX - 3, pY + sumLineHeight + 2, pX + maxWidth + 3, pY + sumLineHeight + 3, color, color);
        int offset = anyItemFound ? stackBoxSize : 0;
        renderStack.push();
        renderStack.translate(pX, pY, 0);
        boolean first = true;
        for (Tuple<ItemStack, List<IReorderingProcessor>> toolTip : lengthLimitedToolTip) {
            int minYShift = 10;
            if (!toolTip.getA().isEmpty()) {
                renderStack.push();
                renderStack.translate(0, 0, zLevel);
                RenderingUtils.renderItemStackGUI(renderStack, toolTip.getA(), null);
                renderStack.pop();
                minYShift = stackBoxSize;
                renderStack.translate(0, 2, 0);
            }
            for (IReorderingProcessor text : toolTip.getB()) {
                FontRenderer customFR = toolTip.getA().getItem().getFontRenderer(toolTip.getA());
                if (customFR == null) {
                    customFR = fontRenderer;
                }
                renderStack.push();
                renderStack.translate(offset, 0, zLevel);
                renderStringAt(text, renderStack, customFR, strColor.getRGB(), false);
                renderStack.pop();
                renderStack.translate(0, 10, 0);
                minYShift -= 10;
            }
            if (minYShift > 0) {
                renderStack.translate(0, minYShift, 0);
            }
            if (isFirstLineHeadline && first) {
                renderStack.translate(0, 2, 0);
            }
            first = false;
        }
        renderStack.pop();
    }
}
Also used : ITextProperties(net.minecraft.util.text.ITextProperties) IReorderingProcessor(net.minecraft.util.IReorderingProcessor) List(java.util.List) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Tuple(net.minecraft.util.Tuple)

Aggregations

ITextProperties (net.minecraft.util.text.ITextProperties)36 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)19 StringTextComponent (net.minecraft.util.text.StringTextComponent)13 ArrayList (java.util.ArrayList)9 FontRenderer (net.minecraft.client.gui.FontRenderer)7 IReorderingProcessor (net.minecraft.util.IReorderingProcessor)7 List (java.util.List)6 Matrix4f (net.minecraft.util.math.vector.Matrix4f)6 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 ItemStack (net.minecraft.item.ItemStack)3 RenderTooltipEvent (net.minecraftforge.client.event.RenderTooltipEvent)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 MoonPhase (hellfirepvp.astralsorcery.common.base.MoonPhase)2 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)2 PerkStatistic (hellfirepvp.astralsorcery.common.perk.reader.PerkStatistic)2 LinkedList (java.util.LinkedList)2 Minecraft (net.minecraft.client.Minecraft)2 Lists (com.google.common.collect.Lists)1 LivingData (com.lying.variousoddities.capabilities.LivingData)1