diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
18 files changed, 181 insertions, 44 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 5e7f06aac..e4fb1055b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -9,12 +9,13 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQu import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.UnknownQuest import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import com.google.gson.JsonObject import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.* class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { @@ -24,7 +25,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { var repoData: JsonObject = JsonObject() - private val display = mutableListOf<String>() + private val display = mutableListOf<List<Any>>() private var dirty = true private var loaded = false @@ -64,7 +65,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { private fun updateRender() { display.clear() - display.add("Reputation Helper:") + display.add(Collections.singletonList("Reputation Helper:")) questHelper.render(display) miniBossHelper.render(display) //TODO check if mage @@ -79,7 +80,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { if (!HyPixelData.skyBlock) return if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return - SkyHanniMod.feature.misc.crimsonIsleReputationHelperPos.renderStrings(display) + SkyHanniMod.feature.misc.crimsonIsleReputationHelperPos.renderStringsAndItems(display) } fun update() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt index d9e6b2499..169603784 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt @@ -7,7 +7,9 @@ import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.* import java.util.regex.Pattern class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -18,8 +20,10 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH val repoData = reputationHelper.repoData val jsonElement = repoData["KUUDRA"] var tier = 1 - for ((displayName, value) in jsonElement.asJsonObject.entrySet()) { - kuudraTiers.add(KuudraTier(displayName, tier)) + for ((displayName, extraData) in jsonElement.asJsonObject.entrySet()) { + val data = extraData.asJsonObject + val displayItem = data["item"]?.asString + kuudraTiers.add(KuudraTier(displayName, displayItem, tier)) tier++ } } @@ -51,15 +55,24 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH reputationHelper.update() } - fun render(display: MutableList<String>) { + fun render(display: MutableList<List<Any>>) { val done = kuudraTiers.count { it.doneToday } - display.add("") - display.add("Daily Kuudra ($done/2 killed)") + display.add(Collections.singletonList("")) + display.add(Collections.singletonList("Daily Kuudra ($done/2 killed)")) if (done != 2) { for (tier in kuudraTiers) { val result = if (tier.doneToday) "§7Done" else "§bTodo" val displayName = tier.getDisplayName() - display.add(" $displayName: $result") + val displayItem = tier.displayItem + if (displayItem == null) { + display.add(Collections.singletonList(" $displayName: $result")) + } else { + val lineList = mutableListOf<Any>() + lineList.add(" ") + lineList.add(NEUItems.readItemFromRepo(displayItem)) + lineList.add("$displayName: $result") + display.add(lineList) + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/KuudraTier.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/KuudraTier.kt index 88d9e1e78..f938ab1fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/KuudraTier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/KuudraTier.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra -class KuudraTier(val name: String, val tierNumber: Int, var doneToday: Boolean = false) { +class KuudraTier(val name: String, val displayItem: String?, val tierNumber: Int, var doneToday: Boolean = false) { fun getDisplayName() = "Tier $tierNumber ($name)" }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index dfe8eb3a3..7400b4347 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -15,12 +15,14 @@ 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.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.* class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { @@ -201,16 +203,16 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { update() } - fun render(display: MutableList<String>) { + fun render(display: MutableList<List<Any>>) { val done = quests.count { it.state == QuestState.COLLECTED } - display.add("") - display.add("Daily Quests ($done/5 collected)") + display.add(Collections.singletonList("")) + display.add(Collections.singletonList("Daily Quests ($done/5 collected)")) if (done != 5) { - quests.mapTo(display) { " " + renderQuest(it) } + quests.mapTo(display) { renderQuest(it) } } } - private fun renderQuest(quest: Quest): String { + private fun renderQuest(quest: Quest): List<Any> { val type = quest.category.displayName val state = quest.state.displayName val stateColor = quest.state.color @@ -245,7 +247,16 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { "" } - return "$stateText$type: §f$displayName$multipleText$sacksText" + val result = mutableListOf<Any>() + val item = quest.displayItem + if (item == null) { + result.add(" $stateText$type: §f$displayName$multipleText$sacksText") + } else { + result.add(" $stateText$type: ") + result.add(NEUItems.readItemFromRepo(item)) + result.add("§f$displayName$multipleText$sacksText") + } + return result } fun finishMiniBoss(miniBoss: CrimsonMiniBoss) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index dee5071c8..61a1c4d77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -82,19 +82,22 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { for (entry in dailyQuestHelper.reputationHelper.repoData.entrySet()) { val categoryName = entry.key val category = entry.value.asJsonObject - for ((entryName, value) in category.entrySet()) { + for ((entryName, extraData) in category.entrySet()) { + val data = extraData.asJsonObject + val displayItem = data["item"]?.asString + if (name.startsWith("$entryName Rank ")) { val split = name.split(" Rank ") val dojoName = split[0] val dojoRankGoal = split[1] - return DojoQuest(dojoName, dojoRankGoal, state) + return DojoQuest(dojoName,displayItem, dojoRankGoal, state) } if (name == entryName) { when (categoryName) { - "FISHING" -> return TrophyFishQuest(name, state, needAmount) - "RESCUE" -> return RescueMissionQuest(state) - "FETCH" -> return FetchQuest(name, state, needAmount) + "FISHING" -> return TrophyFishQuest(name, displayItem, state, needAmount) + "RESCUE" -> return RescueMissionQuest(displayItem, state) + "FETCH" -> return FetchQuest(name, displayItem, state, needAmount) } } } @@ -158,8 +161,13 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) { val needAmount = split[2].toInt() val quest = addQuest(name, state, needAmount) if (quest is ProgressQuest) { - val haveAmount = split[3].toInt() - quest.haveAmount = haveAmount + try { + val haveAmount = split[3].toInt() + quest.haveAmount = haveAmount + } catch (e: IndexOutOfBoundsException) { + println("text: '$text'") + e.printStackTrace() + } } dailyQuestHelper.quests.add(quest) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/DojoQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/DojoQuest.kt index 69353de07..c8bc1a2c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/DojoQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/DojoQuest.kt @@ -2,8 +2,9 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest import at.hannibal2.skyhanni.utils.LorenzUtils -class DojoQuest(public val dojoName: String, dojoRankGoal: String, state: QuestState) : +class DojoQuest(val dojoName: String, displayItem: String?, dojoRankGoal: String, state: QuestState) : Quest( + displayItem, QuestCategory.DOJO, "$dojoName Rank $dojoRankGoal", state, diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/FetchQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/FetchQuest.kt index d815f9a76..115cbcb32 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/FetchQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/FetchQuest.kt @@ -1,4 +1,4 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -class FetchQuest(val itemName: String, state: QuestState, needAmount: Int) : - ProgressQuest(QuestCategory.FETCH, itemName, state, needAmount)
\ No newline at end of file +class FetchQuest(val itemName: String, displayItem: String?, state: QuestState, needAmount: Int) : + ProgressQuest(displayItem, QuestCategory.FETCH, itemName, state, needAmount)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt index 3ef08e400..79085a6f1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/KuudraQuest.kt @@ -3,4 +3,10 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.KuudraTier class KuudraQuest(val kuudraTier: KuudraTier, state: QuestState) : - Quest(QuestCategory.KUUDRA, "Kill Kuudra ${kuudraTier.name} Tier", state, displayName = kuudraTier.getDisplayName())
\ No newline at end of file + Quest( + kuudraTier.displayItem, + QuestCategory.KUUDRA, + "Kill Kuudra ${kuudraTier.name} Tier", + state, + displayName = kuudraTier.getDisplayName() + )
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt index 6b0faeb53..a36b32131 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/MiniBossQuest.kt @@ -3,4 +3,4 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss class MiniBossQuest(val miniBoss: CrimsonMiniBoss, state: QuestState, needAmount: Int) : - ProgressQuest(QuestCategory.MINIBOSS, miniBoss.displayName, state, needAmount)
\ No newline at end of file + ProgressQuest(miniBoss.displayItem, QuestCategory.MINIBOSS, miniBoss.displayName, state, needAmount)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/ProgressQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/ProgressQuest.kt index 938afb483..eac078cc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/ProgressQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/ProgressQuest.kt @@ -1,9 +1,10 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest abstract class ProgressQuest( + displayItem: String?, questCategory: QuestCategory, displayName: String, state: QuestState, val needAmount: Int, var haveAmount: Int = 0 -) : Quest(questCategory, displayName, state)
\ No newline at end of file +) : Quest(displayItem, questCategory, displayName, state)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/Quest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/Quest.kt index 95bf91cd9..5a6bf3f89 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/Quest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/Quest.kt @@ -1,4 +1,10 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -abstract class Quest(val category: QuestCategory, val internalName: String, var state: QuestState, val displayName: String = internalName) { +abstract class Quest( + val displayItem: String?, + val category: QuestCategory, + val internalName: String, + var state: QuestState, + val displayName: String = internalName +) { }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/RescueMissionQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/RescueMissionQuest.kt index 71b201047..ccc9d3c25 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/RescueMissionQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/RescueMissionQuest.kt @@ -1,3 +1,4 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -class RescueMissionQuest(state: QuestState): Quest(QuestCategory.RESCUE, "Rescue Mission", state, "Rescue the NPC")
\ No newline at end of file +class RescueMissionQuest(displayItem: String?, state: QuestState) : + Quest(displayItem, QuestCategory.RESCUE, "Rescue Mission", state, "Rescue the NPC")
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt index 3ecd80912..4a8a453c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/TrophyFishQuest.kt @@ -1,4 +1,4 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -class TrophyFishQuest(val fishName: String, state: QuestState, needAmount: Int) : - ProgressQuest(QuestCategory.FISHING, fishName, state, needAmount)
\ No newline at end of file +class TrophyFishQuest(val fishName: String, displayItem: String?, state: QuestState, needAmount: Int) : + ProgressQuest(displayItem, QuestCategory.FISHING, fishName, state, needAmount)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/UnknownQuest.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/UnknownQuest.kt index 197ee3bce..1c1269c57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/UnknownQuest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/quest/UnknownQuest.kt @@ -1,4 +1,4 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest -class UnknownQuest(unknownName: String): Quest(QuestCategory.UNKNOWN, unknownName, QuestState.NOT_ACCEPTED) { +class UnknownQuest(unknownName: String) : Quest(null, QuestCategory.UNKNOWN, unknownName, QuestState.NOT_ACCEPTED) { }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt index a9d4fb871..e2ac6ddb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt @@ -2,4 +2,9 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss import java.util.regex.Pattern -class CrimsonMiniBoss(val displayName: String, val pattern: Pattern, var doneToday: Boolean = false)
\ No newline at end of file +class CrimsonMiniBoss( + val displayName: String, + val displayItem: String?, + val pattern: Pattern, + var doneToday: Boolean = false +)
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 6933e01c6..e05e300d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -6,7 +6,9 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.* import java.util.regex.Pattern class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -16,9 +18,11 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel fun init() { val repoData = reputationHelper.repoData val jsonElement = repoData["MINIBOSS"] - for ((displayName, value) in jsonElement.asJsonObject.entrySet()) { + for ((displayName, extraData) in jsonElement.asJsonObject.entrySet()) { + val data = extraData.asJsonObject + val displayItem = data["item"]?.asString val patterns = " *§r§6§l${displayName.uppercase()} DOWN!" - miniBosses.add(CrimsonMiniBoss(displayName, Pattern.compile(patterns))) + miniBosses.add(CrimsonMiniBoss(displayName, displayItem, Pattern.compile(patterns))) } } @@ -43,15 +47,24 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel reputationHelper.update() } - fun render(display: MutableList<String>) { + fun render(display: MutableList<List<Any>>) { val done = miniBosses.count { it.doneToday } - display.add("") - display.add("Daily Bosses ($done/5 killed)") + display.add(Collections.singletonList("")) + display.add(Collections.singletonList("Daily Bosses ($done/5 killed)")) if (done != 5) { for (miniBoss in miniBosses) { val result = if (miniBoss.doneToday) "§7Done" else "§bTodo" val displayName = miniBoss.displayName - display.add(" $displayName: $result") + val displayItem = miniBoss.displayItem + if (displayItem == null) { + display.add(Collections.singletonList(" $displayName: $result")) + } else { + val lineList = mutableListOf<Any>() + lineList.add(" ") + lineList.add(NEUItems.readItemFromRepo(displayItem)) + lineList.add("$displayName: $result") + display.add(lineList) + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt new file mode 100644 index 000000000..46c9c6fea --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.utils + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.init.Items +import net.minecraft.item.ItemStack + +object NEUItems { + + private val itemCache = mutableMapOf<String, ItemStack>() + + fun readItemFromRepo(internalName: String): ItemStack { + if (itemCache.contains(internalName)) { + return itemCache[internalName]!! + } + val itemStack = NotEnoughUpdates.INSTANCE.manager.jsonToStack( + NotEnoughUpdates.INSTANCE.manager.itemInformation[internalName] + ) + if (itemStack != null) { + itemCache[internalName] = itemStack + } + return itemStack + } + + fun ItemStack.renderOnScreen(x: Float, y: Float) { + GlStateManager.pushMatrix() + GlStateManager.translate(x, y, 0f) + + val scale = if (item === Items.skull) 0.8f else 0.6f + GlStateManager.scale(scale, scale, 1f) + Utils.drawItemStack(this, 0, 0) + GlStateManager.popMatrix() + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index e3052874f..a4e550f65 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.core.util.render.TextRenderUtils.drawStringScaled +import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.client.gui.FontRenderer @@ -12,6 +13,7 @@ import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.entity.Entity import net.minecraft.inventory.Slot +import net.minecraft.item.ItemStack import net.minecraft.util.AxisAlignedBB import net.minecraft.util.MathHelper import net.minecraft.util.ResourceLocation @@ -424,7 +426,7 @@ object RenderUtils { return lastValue + (currentValue - lastValue) * multiplier } - fun Position.renderString(string: String?, offsetY: Int = 0, center: Boolean = true) { + fun Position.renderString(string: String?, extraOffsetX: Int = 0, offsetY: Int = 0, center: Boolean = true) { val minecraft = Minecraft.getMinecraft() if (minecraft.gameSettings.keyBindPlayerList.isKeyDown) return @@ -441,7 +443,7 @@ object RenderUtils { (200 - renderer.getStringWidth(display.removeColor())) / 2 } else { 0 - } + } + extraOffsetX val x = getAbsX(resolution, 200) + offsetX val y = getAbsY(resolution, 16) + offsetY @@ -462,6 +464,40 @@ object RenderUtils { } } + /** + * Accepts a list of lines to print. + * Each line is a list of things to print. Can print String or ItemStack objects. + */ + fun Position.renderStringsAndItems(list: List<List<Any>>, extraSpace: Int = 0) { + if (list.isEmpty()) return + + var offsetY = 0 + for (line in list) { + renderLine(line, offsetY) + offsetY += 10 + extraSpace + 2 + } + } + + private fun Position.renderLine(line: List<Any>, offsetY: Int) { + val renderer = Minecraft.getMinecraft().fontRendererObj + val resolution = ScaledResolution(Minecraft.getMinecraft()) + var offsetX = 0 + for (any in line) { + if (any is String) { + renderString(any, offsetX, offsetY, center = false) + val width = renderer.getStringWidth(any.removeColor()) + offsetX += width + } + if (any is ItemStack) { + val isX = getAbsX(resolution, 0) + offsetX + val isY = getAbsY(resolution, 0) + offsetY + + any.renderOnScreen(isX.toFloat(), isY.toFloat()) + offsetX += 12 + } + } + } + // totally not modified Autumn Client's TargetStrafe fun drawCircle(entity: Entity, partialTicks: Float, rad: Double, color: Color) { GlStateManager.pushMatrix() |