Search in sources :

Example 11 with Color

use of com.simibubi.create.foundation.utility.Color in project Create by Creators-of-Create.

the class UIRenderHelper method streak.

public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, Color c) {
    Color color = c.copy().setImmutable();
    int c1 = color.scaleAlpha(0.625f).getRGB();
    int c2 = color.scaleAlpha(0.5f).getRGB();
    int c3 = color.scaleAlpha(0.0625f).getRGB();
    int c4 = color.scaleAlpha(0f).getRGB();
    ms.pushPose();
    ms.translate(x, y, 0);
    ms.mulPose(Vector3f.ZP.rotationDegrees(angle - 90));
    streak(ms, breadth / 2, length, c1, c2, c3, c4);
    ms.popPose();
}
Also used : Color(com.simibubi.create.foundation.utility.Color)

Example 12 with Color

use of com.simibubi.create.foundation.utility.Color in project Create by Creators-of-Create.

the class NavigatableSimiScreen method renderZeloBreadcrumbs.

protected void renderZeloBreadcrumbs(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
    List<Screen> history = ScreenOpener.getScreenHistory();
    if (history.isEmpty())
        return;
    history.add(0, minecraft.screen);
    int spacing = 20;
    List<String> names = history.stream().map(NavigatableSimiScreen::screenTitle).collect(Collectors.toList());
    int bWidth = names.stream().mapToInt(s -> font.width(s) + spacing).sum();
    MutableInt x = new MutableInt(width - bWidth);
    MutableInt y = new MutableInt(height - 18);
    MutableBoolean first = new MutableBoolean(true);
    if (x.getValue() < 25)
        x.setValue(25);
    ms.pushPose();
    ms.translate(0, 0, 600);
    names.forEach(s -> {
        int sWidth = font.width(s);
        UIRenderHelper.breadcrumbArrow(ms, x.getValue(), y.getValue(), 0, sWidth + spacing, 14, spacing / 2, new Color(0xdd101010), new Color(0x44101010));
        font.draw(ms, s, x.getValue() + 5, y.getValue() + 3, first.getValue() ? 0xffeeffee : 0xffddeeff);
        first.setFalse();
        x.add(sWidth + spacing);
    });
    ms.popPose();
}
Also used : Color(com.simibubi.create.foundation.utility.Color) Theme(com.simibubi.create.foundation.gui.Theme) MutableInt(org.apache.commons.lang3.mutable.MutableInt) Window(com.mojang.blaze3d.platform.Window) Screen(net.minecraft.client.gui.screens.Screen) PonderTooltipHandler(com.simibubi.create.foundation.ponder.PonderTooltipHandler) PonderLocalization(com.simibubi.create.foundation.ponder.PonderLocalization) UIRenderHelper(com.simibubi.create.foundation.gui.UIRenderHelper) Collectors(java.util.stream.Collectors) GLFW(org.lwjgl.glfw.GLFW) PoseStack(com.mojang.blaze3d.vertex.PoseStack) AbstractSimiScreen(com.simibubi.create.foundation.gui.AbstractSimiScreen) List(java.util.List) Minecraft(net.minecraft.client.Minecraft) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) Optional(java.util.Optional) Lang(com.simibubi.create.foundation.utility.Lang) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) ScreenOpener(com.simibubi.create.foundation.gui.ScreenOpener) Mth(net.minecraft.util.Mth) LerpedFloat(com.simibubi.create.foundation.utility.animation.LerpedFloat) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Screen(net.minecraft.client.gui.screens.Screen) AbstractSimiScreen(com.simibubi.create.foundation.gui.AbstractSimiScreen) MutableInt(org.apache.commons.lang3.mutable.MutableInt) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) Color(com.simibubi.create.foundation.utility.Color)

Example 13 with Color

use of com.simibubi.create.foundation.utility.Color in project Create by Creators-of-Create.

the class EjectorTargetHandler method drawArc.

protected static void drawArc() {
    Minecraft mc = Minecraft.getInstance();
    boolean wrench = AllItems.WRENCH.isIn(mc.player.getMainHandItem());
    if (currentSelection == null)
        return;
    if (currentItem == null && !wrench)
        return;
    HitResult objectMouseOver = mc.hitResult;
    if (!(objectMouseOver instanceof BlockHitResult))
        return;
    BlockHitResult blockRayTraceResult = (BlockHitResult) objectMouseOver;
    if (blockRayTraceResult.getType() == Type.MISS)
        return;
    BlockPos pos = blockRayTraceResult.getBlockPos();
    if (!wrench)
        pos = pos.relative(blockRayTraceResult.getDirection());
    int xDiff = currentSelection.getX() - pos.getX();
    int yDiff = currentSelection.getY() - pos.getY();
    int zDiff = currentSelection.getZ() - pos.getZ();
    int validX = Math.abs(zDiff) > Math.abs(xDiff) ? 0 : xDiff;
    int validZ = Math.abs(zDiff) < Math.abs(xDiff) ? 0 : zDiff;
    BlockPos validPos = currentSelection.offset(validX, yDiff, validZ);
    Direction d = getValidTargetDirection(validPos);
    if (d == null)
        return;
    if (launcher == null || lastHoveredBlockPos != pos.asLong()) {
        lastHoveredBlockPos = pos.asLong();
        launcher = new EntityLauncher(Math.abs(validX + validZ), yDiff);
    }
    double totalFlyingTicks = launcher.getTotalFlyingTicks() + 3;
    int segments = (((int) totalFlyingTicks) / 3) + 1;
    double tickOffset = totalFlyingTicks / segments;
    boolean valid = xDiff == validX && zDiff == validZ;
    int intColor = valid ? 0x9ede73 : 0xff7171;
    Vector3f color = new Color(intColor).asVectorF();
    DustParticleOptions data = new DustParticleOptions(color, 1);
    ClientLevel world = mc.level;
    AABB bb = new AABB(0, 0, 0, 1, 0, 1).move(currentSelection.offset(-validX, -yDiff, -validZ));
    CreateClient.OUTLINER.chaseAABB("valid", bb).colored(intColor).lineWidth(1 / 16f);
    for (int i = 0; i < segments; i++) {
        double ticks = ((AnimationTickHolder.getRenderTime() / 3) % tickOffset) + i * tickOffset;
        Vec3 vec = launcher.getGlobalPos(ticks, d, pos).add(xDiff - validX, 0, zDiff - validZ);
        world.addParticle(data, vec.x, vec.y, vec.z, 0, 0, 0);
    }
}
Also used : ClientLevel(net.minecraft.client.multiplayer.ClientLevel) Color(com.simibubi.create.foundation.utility.Color) Minecraft(net.minecraft.client.Minecraft) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) BlockHitResult(net.minecraft.world.phys.BlockHitResult) HitResult(net.minecraft.world.phys.HitResult) DustParticleOptions(net.minecraft.core.particles.DustParticleOptions) Vector3f(com.mojang.math.Vector3f) Vec3(net.minecraft.world.phys.Vec3) BlockPos(net.minecraft.core.BlockPos) BlockHitResult(net.minecraft.world.phys.BlockHitResult) AABB(net.minecraft.world.phys.AABB)

Example 14 with Color

use of com.simibubi.create.foundation.utility.Color in project Create by Creators-of-Create.

the class TextWindowElement method render.

@Override
protected void render(PonderScene scene, PonderUI screen, PoseStack ms, float partialTicks, float fade) {
    if (bakedText == null)
        bakedText = textGetter.get();
    if (fade < 1 / 16f)
        return;
    Vec2 sceneToScreen = vec != null ? scene.getTransform().sceneToScreen(vec, partialTicks) : new Vec2(screen.width / 2, (screen.height - 200) / 2 + y - 8);
    float yDiff = (screen.height / 2f - sceneToScreen.y - 10) / 100f;
    int targetX = (int) (screen.width * Mth.lerp(yDiff * yDiff, 6f / 8, 5f / 8));
    if (nearScene)
        targetX = (int) Math.min(targetX, sceneToScreen.x + 50);
    int textWidth = Math.min(screen.width - targetX, 180);
    List<FormattedText> lines = screen.getFontRenderer().getSplitter().splitLines(bakedText, textWidth, Style.EMPTY);
    int boxWidth = 0;
    for (FormattedText line : lines) boxWidth = Math.max(boxWidth, screen.getFontRenderer().width(line));
    int boxHeight = screen.getFontRenderer().wordWrapHeight(bakedText, boxWidth);
    ms.pushPose();
    ms.translate(0, sceneToScreen.y, 400);
    new BoxElement().withBackground(Theme.c(Theme.Key.PONDER_BACKGROUND_FLAT)).gradientBorder(Theme.p(Theme.Key.TEXT_WINDOW_BORDER)).at(targetX - 10, 3, 100).withBounds(boxWidth, boxHeight - 1).render(ms);
    // PonderUI.renderBox(ms, targetX - 10, 3, boxWidth, boxHeight - 1, 0xaa000000, 0x30eebb00, 0x10eebb00);
    int brighterColor = Color.mixColors(color, 0xFFffffdd, 1 / 2f);
    if (vec != null) {
        ms.pushPose();
        ms.translate(sceneToScreen.x, 0, 0);
        double lineTarget = (targetX - sceneToScreen.x) * fade;
        ms.scale((float) lineTarget, 1, 1);
        Matrix4f model = ms.last().pose();
        GuiUtils.drawGradientRect(model, -100, 0, 0, 1, 1, brighterColor, brighterColor);
        GuiUtils.drawGradientRect(model, -100, 0, 1, 1, 2, 0xFF494949, 0xFF393939);
        ms.popPose();
    }
    ms.translate(0, 0, 400);
    for (int i = 0; i < lines.size(); i++) {
        screen.getFontRenderer().draw(ms, lines.get(i).getString(), targetX - 10, 3 + 9 * i, new Color(brighterColor).scaleAlpha(fade).getRGB());
    }
    ms.popPose();
}
Also used : Matrix4f(com.mojang.math.Matrix4f) BoxElement(com.simibubi.create.foundation.gui.element.BoxElement) Vec2(net.minecraft.world.phys.Vec2) Color(com.simibubi.create.foundation.utility.Color) FormattedText(net.minecraft.network.chat.FormattedText)

Example 15 with Color

use of com.simibubi.create.foundation.utility.Color in project Create by Creators-of-Create.

the class ConfigScreenList method render.

@Override
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
    Color c = new Color(0x60_000000);
    UIRenderHelper.angledGradient(ms, 90, x0 + width / 2, y0, width, 5, c, Color.TRANSPARENT_BLACK);
    UIRenderHelper.angledGradient(ms, -90, x0 + width / 2, y1, width, 5, c, Color.TRANSPARENT_BLACK);
    UIRenderHelper.angledGradient(ms, 0, x0, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
    UIRenderHelper.angledGradient(ms, 180, x1, y0 + height / 2, height, 5, c, Color.TRANSPARENT_BLACK);
    super.render(ms, mouseX, mouseY, partialTicks);
}
Also used : Color(com.simibubi.create.foundation.utility.Color)

Aggregations

Color (com.simibubi.create.foundation.utility.Color)15 Matrix4f (com.mojang.math.Matrix4f)4 Minecraft (net.minecraft.client.Minecraft)4 FormattedText (net.minecraft.network.chat.FormattedText)3 BufferBuilder (com.mojang.blaze3d.vertex.BufferBuilder)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)2 Tesselator (com.mojang.blaze3d.vertex.Tesselator)2 Vector3f (com.mojang.math.Vector3f)2 ScreenOpener (com.simibubi.create.foundation.gui.ScreenOpener)2 Theme (com.simibubi.create.foundation.gui.Theme)2 UIRenderHelper (com.simibubi.create.foundation.gui.UIRenderHelper)2 ArrayList (java.util.ArrayList)2 GameRenderer (net.minecraft.client.renderer.GameRenderer)2 Direction (net.minecraft.core.Direction)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 DustParticleOptions (net.minecraft.core.particles.DustParticleOptions)2 TextComponent (net.minecraft.network.chat.TextComponent)2 Vec3 (net.minecraft.world.phys.Vec3)2 AbstractConfig (com.electronwill.nightconfig.core.AbstractConfig)1 UnmodifiableConfig (com.electronwill.nightconfig.core.UnmodifiableConfig)1