aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-09-08 19:55:39 +1000
committerGitHub <noreply@github.com>2023-09-08 11:55:39 +0200
commit1447426be65a3ce29cef36395cd47603c9539e00 (patch)
tree482fddcc336a9b09b5e8fad0eb46de723f56f26b /src/main
parent62ebd2a830490ab921c94819e1d24ff4494f00ec (diff)
downloadskyhanni-1447426be65a3ce29cef36395cd47603c9539e00.tar.gz
skyhanni-1447426be65a3ce29cef36395cd47603c9539e00.tar.bz2
skyhanni-1447426be65a3ce29cef36395cd47603c9539e00.zip
Feature: Contest rank Icon (#450)
Contest rank Icon #450
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt23
6 files changed, 83 insertions, 56 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
index 571a9a15b..2091f7f4d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java
@@ -131,6 +131,20 @@ public class InventoryConfig {
public boolean jacobFarmingContestRealTime = true;
@Expose
+ @ConfigOption(name = "Medal Icon", desc = "Adds a symbol that shows what medal you received in this contest. " +
+ "§eIf you use a texture pack this may cause conflicting icons.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ @FeatureToggle
+ public boolean jacobFarmingContestMedalIcon = true;
+
+ @Expose
+ @ConfigOption(name = "Finnegan Icon", desc = "Uses a different indicator for when the contest happened during Mayor Finnegan.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean jacobFarmingContestFinneganIcon = true;
+
+ @Expose
@ConfigOption(name = "Sack Items Display", desc = "")
@Accordion
public SackDisplay sackDisplay = new SackDisplay();
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
index ee699b161..a8ecdfc52 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.renderer.GlStateManager
@@ -26,20 +27,13 @@ class ItemTipHelper {
if (itemTipEvent.renderObjects.isEmpty()) return
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
-
for (renderObject in itemTipEvent.renderObjects) {
- val fontRenderer = event.fontRenderer
val text = renderObject.text
- val x = event.x + 17 - fontRenderer.getStringWidth(text) + renderObject.offsetX
+ val x = event.x + 17 + renderObject.offsetX
val y = event.y + 9 + renderObject.offsetY
- fontRenderer.drawStringWithShadow(text, x.toFloat(), y.toFloat(), 16777215)
- }
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
+ RenderUtils.drawSlotText(x, y, text, 1f)
+ }
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
index 61bd56198..b62f86d85 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
@@ -1,15 +1,13 @@
package at.hannibal2.skyhanni.features.garden.contest
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.GuiContainerEvent
-import at.hannibal2.skyhanni.events.InventoryCloseEvent
-import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
-import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.inventory.ContainerChest
@@ -18,7 +16,6 @@ import java.text.SimpleDateFormat
import java.util.*
class JacobFarmingContestsInventory {
-
private val duplicateSlots = mutableListOf<Int>()
private val realTime = mutableMapOf<Int, String>()
@@ -28,6 +25,7 @@ class JacobFarmingContestsInventory {
// Render the contests a tick delayed to feel smoother
private var hideEverything = true
+ private val contestEarnedPattern = "§7You earned a §(?<medalColour>.*)§l.* §7medal!".toPattern()
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
@@ -142,4 +140,37 @@ class JacobFarmingContestsInventory {
}
}
}
+
+ @SubscribeEvent
+ fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.jacobFarmingContestMedalIcon) return
+ if (!InventoryUtils.openInventoryName().contains("Your Contests")) return
+
+ val stack = event.stack ?: return
+ var finneganContest = false
+
+ for (line in stack.getLore()) {
+ if (line.contains("Contest boosted by Finnegan!")) finneganContest = true
+
+ val matcher = contestEarnedPattern.matcher(line)
+ if (matcher.matches()) {
+ val medalEarned = ContestBracket.entries.find { it.color == matcher.group("medalColour") } ?: return
+
+ var stackTip = "§${medalEarned.color}✦"
+ var x = event.x + 9
+ var y = event.y + 1
+ var scale = .7f
+
+ if (finneganContest && config.jacobFarmingContestFinneganIcon) {
+ stackTip = "§${medalEarned.color}▲"
+ x = event.x + 5
+ y = event.y - 2
+ scale = 1.3f
+ }
+
+ RenderUtils.drawSlotText(x, y, stackTip, scale)
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
index 5cfcd881d..ea3246ac5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
@@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetCandyUsed
-import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PetCandyUsedDisplay {
@@ -20,26 +20,9 @@ class PetCandyUsedDisplay {
if (petCandyUsed == 0) return
val stackTip = "§c$petCandyUsed"
-
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
-
- val fontRenderer = event.fontRenderer
- val x = event.x + 13 - fontRenderer.getStringWidth(stackTip)
+ val x = event.x + 13
val y = event.y + 1
- val scale = 0.9
- GlStateManager.pushMatrix()
- GlStateManager.translate(x.toFloat(), y.toFloat(), 0f)
- GlStateManager.scale(scale, scale, scale)
- fontRenderer.drawStringWithShadow(stackTip, 0f, 0f, 16777215)
- val reverseScale = 1 / 0.7
- GlStateManager.scale(reverseScale, reverseScale, reverseScale)
- GlStateManager.popMatrix()
-
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
+ RenderUtils.drawSlotText(x, y, stackTip, .9f)
}
-
-}
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt
index 0ed156362..a1c780199 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt
@@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack
-import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PocketSackInASackDisplay {
@@ -22,26 +22,10 @@ class PocketSackInASackDisplay {
val pocketSackInASackApplied = stack.getAppliedPocketSackInASack() ?: return
val stackTip = "§a$pocketSackInASackApplied"
-
- GlStateManager.disableLighting()
- GlStateManager.disableDepth()
- GlStateManager.disableBlend()
-
- val fontRenderer = event.fontRenderer
- val x = event.x + 13 - fontRenderer.getStringWidth(stackTip)
+ val x = event.x + 13
val y = event.y + 1
- val scale = 0.9
- GlStateManager.pushMatrix()
- GlStateManager.translate(x.toFloat(), y.toFloat(), 0f)
- GlStateManager.scale(scale, scale, scale)
- fontRenderer.drawStringWithShadow(stackTip, 0f, 0f, 16777215)
- val reverseScale = 1 / 0.7
- GlStateManager.scale(reverseScale, reverseScale, reverseScale)
- GlStateManager.popMatrix()
-
- GlStateManager.enableLighting()
- GlStateManager.enableDepth()
+ RenderUtils.drawSlotText(x, y, stackTip, .9f)
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 7544e7934..157ecb90f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -970,4 +970,25 @@ object RenderUtils {
)
)
}
-}
+
+ fun drawSlotText(xPos: Int, yPos: Int, text: String, scale: Float) {
+ val fontRenderer = Minecraft.getMinecraft().fontRendererObj
+
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
+ GlStateManager.disableBlend()
+
+ GlStateManager.pushMatrix()
+ GlStateManager.translate((xPos - fontRenderer.getStringWidth(text)).toFloat(), yPos.toFloat(), 0f)
+ GlStateManager.scale(scale, scale, 1f)
+ fontRenderer.drawStringWithShadow(text, 0f, 0f, 16777215)
+
+ val reverseScale = 1 / scale
+
+ GlStateManager.scale(reverseScale, reverseScale, 1f)
+ GlStateManager.popMatrix()
+
+ GlStateManager.enableLighting()
+ GlStateManager.enableDepth()
+ }
+} \ No newline at end of file