Search in sources :

Example 1 with Color

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

the class FluidStackParticle method tick.

@Override
public void tick() {
    super.tick();
    if (!canEvaporate())
        return;
    if (onGround)
        remove();
    if (!removed)
        return;
    if (!onGround && level.random.nextFloat() < 1 / 8f)
        return;
    Color color = new Color(fluid.getFluid().getAttributes().getColor(fluid));
    level.addParticle(ParticleTypes.ENTITY_EFFECT, x, y, z, color.getRedAsFloat(), color.getGreenAsFloat(), color.getBlueAsFloat());
}
Also used : Color(com.simibubi.create.foundation.utility.Color)

Example 2 with Color

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

the class GoggleOverlayRenderer method renderOverlay.

public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height) {
    HitResult objectMouseOver = Minecraft.getInstance().hitResult;
    if (!(objectMouseOver instanceof BlockHitResult)) {
        lastHovered = null;
        hoverTicks = 0;
        return;
    }
    for (OutlineEntry entry : outlines.values()) {
        if (!entry.isAlive())
            continue;
        Outline outline = entry.getOutline();
        if (outline instanceof ValueBox && !((ValueBox) outline).isPassive)
            return;
    }
    BlockHitResult result = (BlockHitResult) objectMouseOver;
    Minecraft mc = Minecraft.getInstance();
    ClientLevel world = mc.level;
    BlockPos pos = result.getBlockPos();
    ItemStack headSlot = mc.player.getItemBySlot(EquipmentSlot.HEAD);
    BlockEntity te = world.getBlockEntity(pos);
    if (lastHovered == null || lastHovered.equals(pos))
        hoverTicks++;
    else
        hoverTicks = 0;
    lastHovered = pos;
    boolean wearingGoggles = AllItems.GOGGLES.isIn(headSlot);
    for (Supplier<Boolean> supplier : customGogglePredicates) wearingGoggles |= supplier.get();
    boolean hasGoggleInformation = te instanceof IHaveGoggleInformation;
    boolean hasHoveringInformation = te instanceof IHaveHoveringInformation;
    boolean goggleAddedInformation = false;
    boolean hoverAddedInformation = false;
    List<Component> tooltip = new ArrayList<>();
    if (hasGoggleInformation && wearingGoggles) {
        IHaveGoggleInformation gte = (IHaveGoggleInformation) te;
        goggleAddedInformation = gte.addToGoggleTooltip(tooltip, mc.player.isShiftKeyDown());
    }
    if (hasHoveringInformation) {
        if (!tooltip.isEmpty())
            tooltip.add(TextComponent.EMPTY);
        IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
        hoverAddedInformation = hte.addToTooltip(tooltip, mc.player.isShiftKeyDown());
        if (goggleAddedInformation && !hoverAddedInformation)
            tooltip.remove(tooltip.size() - 1);
    }
    if (te instanceof IDisplayAssemblyExceptions) {
        boolean exceptionAdded = ((IDisplayAssemblyExceptions) te).addExceptionToTooltip(tooltip);
        if (exceptionAdded) {
            hasHoveringInformation = true;
            hoverAddedInformation = true;
        }
    }
    // break early if goggle or hover returned false when present
    if ((hasGoggleInformation && !goggleAddedInformation) && (hasHoveringInformation && !hoverAddedInformation))
        return;
    // check for piston poles if goggles are worn
    BlockState state = world.getBlockState(pos);
    if (wearingGoggles && AllBlocks.PISTON_EXTENSION_POLE.has(state)) {
        Direction[] directions = Iterate.directionsInAxis(state.getValue(PistonExtensionPoleBlock.FACING).getAxis());
        int poles = 1;
        boolean pistonFound = false;
        for (Direction dir : directions) {
            int attachedPoles = PistonExtensionPoleBlock.PlacementHelper.get().attachedPoles(world, pos, dir);
            poles += attachedPoles;
            pistonFound |= world.getBlockState(pos.relative(dir, attachedPoles + 1)).getBlock() instanceof MechanicalPistonBlock;
        }
        if (!pistonFound)
            return;
        if (!tooltip.isEmpty())
            tooltip.add(TextComponent.EMPTY);
        tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy().append(Lang.translate("gui.goggles.pole_length")).append(new TextComponent(" " + poles)));
    }
    if (tooltip.isEmpty())
        return;
    poseStack.pushPose();
    int tooltipTextWidth = 0;
    for (FormattedText textLine : tooltip) {
        int textLineWidth = mc.font.width(textLine);
        if (textLineWidth > tooltipTextWidth)
            tooltipTextWidth = textLineWidth;
    }
    int tooltipHeight = 8;
    if (tooltip.size() > 1) {
        // gap between title lines and next lines
        tooltipHeight += 2;
        tooltipHeight += (tooltip.size() - 1) * 10;
    }
    CClient cfg = AllConfigs.CLIENT;
    int posX = width / 2 + cfg.overlayOffsetX.get();
    int posY = height / 2 + cfg.overlayOffsetY.get();
    posX = Math.min(posX, width - tooltipTextWidth - 20);
    posY = Math.min(posY, height - tooltipHeight - 20);
    float fade = Mth.clamp((hoverTicks + partialTicks) / 12f, 0, 1);
    Boolean useCustom = cfg.overlayCustomColor.get();
    Color colorBackground = useCustom ? new Color(cfg.overlayBackgroundColor.get()) : Theme.c(Theme.Key.VANILLA_TOOLTIP_BACKGROUND).scaleAlpha(.75f);
    Color colorBorderTop = useCustom ? new Color(cfg.overlayBorderColorTop.get()) : Theme.c(Theme.Key.VANILLA_TOOLTIP_BORDER, true).copy();
    Color colorBorderBot = useCustom ? new Color(cfg.overlayBorderColorBot.get()) : Theme.c(Theme.Key.VANILLA_TOOLTIP_BORDER, false).copy();
    if (fade < 1) {
        poseStack.translate((1 - fade) * Math.signum(cfg.overlayOffsetX.get() + .5f) * 4, 0, 0);
        colorBackground.scaleAlpha(fade);
        colorBorderTop.scaleAlpha(fade);
        colorBorderBot.scaleAlpha(fade);
    }
    RemovedGuiUtils.drawHoveringText(poseStack, tooltip, posX, posY, width, height, -1, colorBackground.getRGB(), colorBorderTop.getRGB(), colorBorderBot.getRGB(), mc.font);
    ItemStack item = AllItems.GOGGLES.asStack();
    GuiGameElement.of(item).at(posX + 10, posY - 16, 450).render(poseStack);
    poseStack.popPose();
}
Also used : ArrayList(java.util.ArrayList) IDisplayAssemblyExceptions(com.simibubi.create.content.contraptions.components.structureMovement.IDisplayAssemblyExceptions) Direction(net.minecraft.core.Direction) BlockHitResult(net.minecraft.world.phys.BlockHitResult) HitResult(net.minecraft.world.phys.HitResult) OutlineEntry(com.simibubi.create.foundation.utility.outliner.Outliner.OutlineEntry) CClient(com.simibubi.create.foundation.config.CClient) BlockPos(net.minecraft.core.BlockPos) BlockHitResult(net.minecraft.world.phys.BlockHitResult) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) TextComponent(net.minecraft.network.chat.TextComponent) ClientLevel(net.minecraft.client.multiplayer.ClientLevel) MechanicalPistonBlock(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock) Color(com.simibubi.create.foundation.utility.Color) Outline(com.simibubi.create.foundation.utility.outliner.Outline) FormattedText(net.minecraft.network.chat.FormattedText) Minecraft(net.minecraft.client.Minecraft) BlockState(net.minecraft.world.level.block.state.BlockState) ValueBox(com.simibubi.create.foundation.tileEntity.behaviour.ValueBox) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with Color

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

the class AllIcons method render.

@OnlyIn(Dist.CLIENT)
public void render(PoseStack ms, MultiBufferSource buffer, int color) {
    VertexConsumer builder = buffer.getBuffer(RenderType.textSeeThrough(ICON_ATLAS));
    Matrix4f matrix = ms.last().pose();
    Color rgb = new Color(color);
    int light = LightTexture.FULL_BRIGHT;
    Vec3 vec1 = new Vec3(0, 0, 0);
    Vec3 vec2 = new Vec3(0, 1, 0);
    Vec3 vec3 = new Vec3(1, 1, 0);
    Vec3 vec4 = new Vec3(1, 0, 0);
    float u1 = iconX * 1f / ICON_ATLAS_SIZE;
    float u2 = (iconX + 16) * 1f / ICON_ATLAS_SIZE;
    float v1 = iconY * 1f / ICON_ATLAS_SIZE;
    float v2 = (iconY + 16) * 1f / ICON_ATLAS_SIZE;
    vertex(builder, matrix, vec1, rgb, u1, v1, light);
    vertex(builder, matrix, vec2, rgb, u1, v2, light);
    vertex(builder, matrix, vec3, rgb, u2, v2, light);
    vertex(builder, matrix, vec4, rgb, u2, v1, light);
}
Also used : Matrix4f(com.mojang.math.Matrix4f) Color(com.simibubi.create.foundation.utility.Color) Vec3(net.minecraft.world.phys.Vec3) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with Color

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

the class Theme method init.

/*
	 * Small note to addons: if you also want to make use of Theme,
	 * and add new Keys, please do not use mixins. Instead make a Theme
	 * subclass, override init and apply it via the static #addTheme
	 *
	 **/
protected void init() {
    put(Key.BUTTON_IDLE, new Color(0xdd_8ab6d6, true), new Color(0x90_8ab6d6, true));
    put(Key.BUTTON_HOVER, new Color(0xff_9ABBD3, true), new Color(0xd0_9ABBD3, true));
    put(Key.BUTTON_CLICK, new Color(0xff_ffffff), new Color(0xee_ffffff));
    put(Key.BUTTON_DISABLE, new Color(0x80_909090, true), new Color(0x60_909090, true));
    put(Key.BUTTON_SUCCESS, new Color(0xcc_88f788, true), new Color(0xcc_20cc20, true));
    put(Key.BUTTON_FAIL, new Color(0xcc_f78888, true), new Color(0xcc_cc2020, true));
    put(Key.TEXT, new Color(0xff_eeeeee), new Color(0xff_a3a3a3));
    put(Key.TEXT_DARKER, new Color(0xff_a3a3a3), new Color(0xff_808080));
    put(Key.TEXT_ACCENT_STRONG, new Color(0xff_8ab6d6), new Color(0xff_8ab6d6));
    put(Key.TEXT_ACCENT_SLIGHT, new Color(0xff_ddeeff), new Color(0xff_a0b0c0));
    put(Key.STREAK, new Color(0x101010, false));
    put(Key.VANILLA_TOOLTIP_BORDER, new Color(0x50_5000ff, true), new Color(0x50_28007f, true));
    put(Key.VANILLA_TOOLTIP_BACKGROUND, new Color(0xf0_100010, true));
    put(Key.PONDER_BUTTON_IDLE, new Color(0x60_c0c0ff, true), new Color(0x30_c0c0ff, true));
    put(Key.PONDER_BUTTON_HOVER, new Color(0xf0_c0c0ff, true), new Color(0xa0_c0c0ff, true));
    put(Key.PONDER_BUTTON_CLICK, new Color(0xff_ffffff), new Color(0xdd_ffffff));
    put(Key.PONDER_BUTTON_DISABLE, new Color(0x80_909090, true), new Color(0x20_909090, true));
    put(Key.PONDER_BACKGROUND_TRANSPARENT, new Color(0xdd_000000, true));
    put(Key.PONDER_BACKGROUND_FLAT, new Color(0xff_000000, false));
    put(Key.PONDER_IDLE, new Color(0x40ffeedd, true), new Color(0x20ffeedd, true));
    put(Key.PONDER_HOVER, new Color(0x70ffffff, true), new Color(0x30ffffff, true));
    put(Key.PONDER_HIGHLIGHT, new Color(0xf0ffeedd, true), new Color(0x60ffeedd, true));
    put(Key.TEXT_WINDOW_BORDER, new Color(0x607a6000, true), new Color(0x207a6000, true));
    put(Key.PONDER_BACK_ARROW, new Color(0xf0aa9999, true), new Color(0x30aa9999, true));
    put(Key.PONDER_PROGRESSBAR, new Color(0x80ffeedd, true), new Color(0x50ffeedd, true));
    put(Key.PONDER_MISSING_CREATE, new Color(0x70_984500, true), new Color(0x70_692400, true));
    // put(Key.PONDER_MISSING_VANILLA, new Color(0x50_5000ff, true), new Color(0x50_300077, true));
    lookup(Key.PONDER_MISSING_VANILLA, Key.VANILLA_TOOLTIP_BORDER);
    put(Key.CONFIG_TITLE_A, new Color(0xffc69fbc, true), new Color(0xfff6b8bb, true));
    put(Key.CONFIG_TITLE_B, new Color(0xfff6b8bb, true), new Color(0xfffbf994, true));
// put(Key., new Color(0x, true), new Color(0x, true));
}
Also used : Color(com.simibubi.create.foundation.utility.Color)

Example 5 with Color

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

the class UIRenderHelper method breadcrumbArrow.

private static void breadcrumbArrow(PoseStack ms, int width, int height, int indent, Color c1, Color c2) {
    /*
		 * 0,0       x1,y1 ********************* x4,y4 ***** x7,y7
		 *       ****                                     ****
		 *   ****                                     ****
		 * x0,y0     x2,y2                       x5,y5
		 *   ****                                     ****
		 *       ****                                     ****
		 *           x3,y3 ********************* x6,y6 ***** x8,y8
		 *
		 */
    float x0 = 0, y0 = height / 2f;
    float x1 = indent, y1 = 0;
    float x2 = indent, y2 = height / 2f;
    float x3 = indent, y3 = height;
    float x4 = width, y4 = 0;
    float x5 = width, y5 = height / 2f;
    float x6 = width, y6 = height;
    float x7 = indent + width, y7 = 0;
    float x8 = indent + width, y8 = height;
    indent = Math.abs(indent);
    width = Math.abs(width);
    Color fc1 = Color.mixColors(c1, c2, 0);
    Color fc2 = Color.mixColors(c1, c2, (indent) / (width + 2f * indent));
    Color fc3 = Color.mixColors(c1, c2, (indent + width) / (width + 2f * indent));
    Color fc4 = Color.mixColors(c1, c2, 1);
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.disableCull();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    Tesselator tessellator = Tesselator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuilder();
    Matrix4f model = ms.last().pose();
    bufferbuilder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR);
    bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x2, y2, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x1, y1, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x3, y3, 0).color(fc2.getRed(), fc2.getGreen(), fc2.getBlue(), fc2.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x4, y4, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x7, y7, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x6, y6, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x5, y5, 0).color(fc3.getRed(), fc3.getGreen(), fc3.getBlue(), fc3.getAlpha()).endVertex();
    bufferbuilder.vertex(model, x8, y8, 0).color(fc4.getRed(), fc4.getGreen(), fc4.getBlue(), fc4.getAlpha()).endVertex();
    tessellator.end();
    RenderSystem.enableCull();
    RenderSystem.disableBlend();
    RenderSystem.enableTexture();
}
Also used : Matrix4f(com.mojang.math.Matrix4f) Color(com.simibubi.create.foundation.utility.Color) BufferBuilder(com.mojang.blaze3d.vertex.BufferBuilder) GameRenderer(net.minecraft.client.renderer.GameRenderer) Tesselator(com.mojang.blaze3d.vertex.Tesselator)

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