aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-22 19:46:57 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-01-22 19:46:57 +0100
commit7c0c1b2935b7edaabd5efa12ef23ede0365c1d5b (patch)
tree56368862648a7788c55cdf4abf5035c70671aa46 /src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
parent8a255ddfcaec09ce31f12c7412f889b34e209768 (diff)
downloadskyhanni-7c0c1b2935b7edaabd5efa12ef23ede0365c1d5b.tar.gz
skyhanni-7c0c1b2935b7edaabd5efa12ef23ede0365c1d5b.tar.bz2
skyhanni-7c0c1b2935b7edaabd5efa12ef23ede0365c1d5b.zip
Adding green line around items that are clickable.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
index 1576ff4ca..bdbb86c31 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemRenderBackground.kt
@@ -12,16 +12,27 @@ class ItemRenderBackground {
companion object {
- private val mapColor = mutableMapOf<ItemStack, Int>()
+ private val backgroundColor = mutableMapOf<ItemStack, Int>()
+ private val borderLineColor = mutableMapOf<ItemStack, Int>()
private val mapTime = mutableMapOf<ItemStack, Long>()
var ItemStack.background: Int
get() {
- if (System.currentTimeMillis() > mapTime.getOrDefault(this, 0) + 200) return -1
- return mapColor.getOrDefault(this, -1)
+ if (System.currentTimeMillis() > mapTime.getOrDefault(this, 0) + 60) return -1
+ return backgroundColor.getOrDefault(this, -1)
}
set(value) {
- mapColor[this] = value
+ backgroundColor[this] = value
+ mapTime[this] = System.currentTimeMillis()
+ }
+
+ var ItemStack.borderLine: Int
+ get() {
+ if (System.currentTimeMillis() > mapTime.getOrDefault(this, 0) + 60) return -1
+ return borderLineColor.getOrDefault(this, -1)
+ }
+ set(value) {
+ borderLineColor[this] = value
mapTime[this] = System.currentTimeMillis()
}
}
@@ -30,18 +41,32 @@ class ItemRenderBackground {
@SubscribeEvent
fun renderOverlayLol(event: RenderRealOverlayEvent) {
val stack = event.stack
- if (LorenzUtils.inSkyBlock) {
- if (stack != null) {
- val color = stack.background
- if (color != -1) {
- GlStateManager.pushMatrix()
- GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
- val x = event.x
- val y = event.y
- Gui.drawRect(x, y, x + 16, y + 16, color)
- GlStateManager.popMatrix()
- }
- }
+ if (!LorenzUtils.inSkyBlock) return
+ if (stack == null) return
+
+ val backgroundColor = stack.background
+ if (backgroundColor != -1) {
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
+ val x = event.x
+ val y = event.y
+ Gui.drawRect(x, y, x + 16, y + 16, backgroundColor)
+ GlStateManager.popMatrix()
+ }
+
+ val borderLineColor = stack.borderLine
+ if (borderLineColor != -1) {
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(0f, 0f, 110 + Minecraft.getMinecraft().renderItem.zLevel)
+ val x = event.x
+ val y = event.y
+
+ Gui.drawRect(x, y, x + 1, y + 16, borderLineColor)
+ Gui.drawRect(x, y, x + 16, y + 1, borderLineColor)
+
+ Gui.drawRect(x, y + 15, x + 16, y + 16, borderLineColor)
+ Gui.drawRect(x + 15, y, x + 16, y + 16, borderLineColor)
+ GlStateManager.popMatrix()
}
}
} \ No newline at end of file