Search in sources :

Example 1 with TextRenderer

use of net.minecraft.client.font.TextRenderer in project Skyblocker by LifeIsAParadox.

the class DummyInventory method renderPreview.

public static boolean renderPreview(MatrixStack matrices, int index, int mouseX, int mouseY) {
    if (index >= 9 && index < 18)
        index -= 9;
    else if (index >= 27 && index < 45)
        index -= 18;
    else
        return false;
    if (storage[index] == null)
        return false;
    int rows = (storage[index].size() - 9) / 9;
    Screen screen = MinecraftClient.getInstance().currentScreen;
    int x = mouseX + 184 >= screen.width ? mouseX - 188 : mouseX + 8;
    int y = Math.max(0, mouseY - 16);
    RenderSystem.disableDepthTest();
    RenderSystem.setShaderTexture(0, TEXTURE);
    instance.drawTexture(matrices, x, y, 0, 0, 176, 7);
    for (int i = 0; i < rows; ++i) instance.drawTexture(matrices, x, y + i * 18 + 7, 0, 7, 176, 18);
    instance.drawTexture(matrices, x, y + rows * 18 + 7, 0, 25, 176, 7);
    RenderSystem.enableDepthTest();
    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
    TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
    for (int i = 9; i < storage[index].size(); ++i) {
        int itemX = x + (i - 9) % 9 * 18 + 8;
        int itemY = y + (i - 9) / 9 * 18 + 8;
        itemRenderer.zOffset = 200.0F;
        itemRenderer.renderInGui(storage[index].getStack(i), itemX, itemY);
        itemRenderer.renderGuiItemOverlay(textRenderer, storage[index].getStack(i), itemX, itemY);
        itemRenderer.zOffset = 0.0F;
    }
    return true;
}
Also used : Screen(net.minecraft.client.gui.screen.Screen) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 2 with TextRenderer

use of net.minecraft.client.font.TextRenderer in project Skyblocker by LifeIsAParadox.

the class FancyStatusBars method renderText.

private void renderText(MatrixStack matrices, int value, int left, int top, int color) {
    TextRenderer textRenderer = client.textRenderer;
    String text = Integer.toString(value);
    int x = left + (33 - textRenderer.getWidth(text)) / 2;
    int y = top - 3;
    // for i in [-1, 1]
    for (int i = -1; i < 2; i += 2) {
        textRenderer.draw(matrices, text, (float) (x + i), (float) y, 0);
        textRenderer.draw(matrices, text, (float) x, (float) (y + i), 0);
    }
    textRenderer.draw(matrices, text, (float) x, (float) y, color);
}
Also used : TextRenderer(net.minecraft.client.font.TextRenderer)

Example 3 with TextRenderer

use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.

the class AbstractGuiDropdownMenu method draw.

@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);
    TextRenderer fontRenderer = MCVer.getFontRenderer();
    if (renderInfo.layer == 0) {
        int width = size.getWidth();
        int height = size.getHeight();
        // Draw box
        renderer.drawRect(0, 0, width, height, OUTLINE_COLOR);
        renderer.drawRect(1, 1, width - 2, height - 2, ReadableColor.BLACK);
        renderer.drawRect(width - height, 0, 1, height, OUTLINE_COLOR);
        // Draw triangle
        int base = height - 6;
        int tHeight = base / 2;
        int x = width - 3 - base / 2;
        int y = height / 2 - 2;
        for (int layer = tHeight; layer > 0; layer--) {
            renderer.drawRect(x - layer, y + (tHeight - layer), layer * 2 - 1, 1, OUTLINE_COLOR);
        }
        renderer.drawString(3, height / 2 - fontRenderer.fontHeight / 2, ReadableColor.WHITE, toString.apply(getSelectedValue()));
    } else if (renderInfo.layer == 1) {
        ReadablePoint offsetPoint = new Point(0, size.getHeight());
        ReadableDimension offsetSize = new Dimension(size.getWidth(), (fontRenderer.fontHeight + 5) * values.length);
        OffsetGuiRenderer offsetRenderer = new OffsetGuiRenderer(renderer, offsetPoint, offsetSize);
        offsetRenderer.startUsing();
        try {
            dropdown.draw(offsetRenderer, offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
        } finally {
            offsetRenderer.stopUsing();
        }
    }
}
Also used : ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) OffsetGuiRenderer(de.johni0702.minecraft.gui.OffsetGuiRenderer) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) Dimension(de.johni0702.minecraft.gui.utils.lwjgl.Dimension) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 4 with TextRenderer

use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.

the class AbstractGuiDropdownMenu method calcMinSize.

@Override
protected ReadableDimension calcMinSize() {
    TextRenderer fontRenderer = MCVer.getFontRenderer();
    int maxWidth = 0;
    for (V value : values) {
        int width = fontRenderer.getWidth(toString.apply(value));
        if (width > maxWidth) {
            maxWidth = width;
        }
    }
    return new Dimension(11 + maxWidth + fontRenderer.fontHeight, fontRenderer.fontHeight + 4);
}
Also used : Dimension(de.johni0702.minecraft.gui.utils.lwjgl.Dimension) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 5 with TextRenderer

use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.

the class AbstractGuiDropdownMenu method layout.

@Override
public void layout(ReadableDimension size, RenderInfo renderInfo) {
    super.layout(size, renderInfo);
    TextRenderer fontRenderer = MCVer.getFontRenderer();
    if (renderInfo.layer == 1) {
        ReadablePoint offsetPoint = new Point(0, size.getHeight());
        ReadableDimension offsetSize = new Dimension(size.getWidth(), (fontRenderer.fontHeight + 5) * values.length);
        dropdown.layout(offsetSize, renderInfo.offsetMouse(0, offsetPoint.getY()).layer(0));
    }
}
Also used : ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) Dimension(de.johni0702.minecraft.gui.utils.lwjgl.Dimension) ReadableDimension(de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension) ReadablePoint(de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint) TextRenderer(net.minecraft.client.font.TextRenderer)

Aggregations

TextRenderer (net.minecraft.client.font.TextRenderer)40 Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)9 ReadablePoint (de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint)9 LiteralText (net.minecraft.text.LiteralText)7 Dimension (de.johni0702.minecraft.gui.utils.lwjgl.Dimension)6 ReadableDimension (de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension)6 MinecraftClient (net.minecraft.client.MinecraftClient)5 TranslatableText (net.minecraft.text.TranslatableText)4 ReadableColor (de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 InGameHud (net.minecraft.client.gui.hud.InGameHud)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 Sprite (net.minecraft.client.texture.Sprite)2 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)2 MatrixStack (net.minecraft.client.util.math.MatrixStack)2 StatusEffect (net.minecraft.entity.effect.StatusEffect)2 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)2 Text (net.minecraft.text.Text)2 Redirect (org.spongepowered.asm.mixin.injection.Redirect)2 GsonBuilder (com.google.gson.GsonBuilder)1