From 605ab992f5a951c076e5bfeee9ef3d5654962601 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 4 Jan 2022 19:33:40 +0700 Subject: [PATCH] Bring back progress bar red flash --- .../mc/otm/client/screen/panels/EditablePanel.kt | 4 ++++ .../ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index 788d8af84..9f6f4d8b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -908,7 +908,11 @@ open class EditablePanel @JvmOverloads constructor( return mouse_x >= pos.x && mouse_x <= pos.x + width && mouse_y >= pos.y && mouse_y + height <= pos.y } + protected var tick = 0 + open fun tick() { + tick++ + for (child in children) { child.tick() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt index 5203ee91a..2a06ac187 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget +import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component @@ -166,6 +167,10 @@ open class ProgressGaugePanel @JvmOverloads constructor( } override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) { + if (widget.isStuck() && tick % 40 <= 20) { + RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) + } + if (flop) { GAUGE_BACKGROUND.render(stack, winding = UVWindingOrder.U1_V0_U0_V1) val width = this.width * widget.percentage() @@ -175,6 +180,10 @@ open class ProgressGaugePanel @JvmOverloads constructor( val width = this.width * widget.percentage() GAUGE_FOREGROUND.renderPartial(stack, width = width) } + + if (widget.isStuck() && tick % 40 <= 20) { + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + } } override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {