aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-24 17:28:33 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-24 17:28:33 +0100
commit2567f766c7ec5df02adcabfacd02974c83c9c72a (patch)
tree5d8c304da55940429b2361cec264220261ea3763 /src/main/java/at/hannibal2/skyhanni
parent0ef18631efce1a17b7397e3fcf835b11b9cfad9b (diff)
downloadskyhanni-2567f766c7ec5df02adcabfacd02974c83c9c72a.tar.gz
skyhanni-2567f766c7ec5df02adcabfacd02974c83c9c72a.tar.bz2
skyhanni-2567f766c7ec5df02adcabfacd02974c83c9c72a.zip
Used new neu method.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt35
9 files changed, 36 insertions, 42 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt
index 0612faaf7..096683798 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextPlotPrice.kt
@@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -34,9 +33,7 @@ class GardenNextPlotPrice {
if (next) {
val (itemName, amount) = ItemUtils.readItemAmount(line)
if (itemName != null) {
- val internalName = NEUItems.getInternalNameByName(itemName)
- val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager
- val lowestBin = auctionManager.getBazaarOrBin(internalName, false)
+ val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName))
val price = lowestBin * amount
val format = NumberUtil.format(price)
list[i] = list[i] + " §f(§6$format§f)"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
index b20c699cd..3f3784951 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenVisitorFeatures.kt
@@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
import net.minecraft.network.play.client.C02PacketUseEntity
@@ -126,9 +125,7 @@ class GardenVisitorFeatures {
if (i > 1) {
val (itemName, amount) = ItemUtils.readItemAmount(line)
if (itemName != null) {
- val internalName = NEUItems.getInternalNameByName(itemName)
- val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager
- val lowestBin = auctionManager.getBazaarOrBin(internalName, false)
+ val lowestBin = NEUItems.getPrice(NEUItems.getInternalName(itemName))
val price = lowestBin * amount
totalPrice += price
val format = NumberUtil.format(price)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
index 83d46e1ff..2623b63a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SkyMartBestProfit.kt
@@ -9,10 +9,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
+import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import net.minecraft.client.Minecraft
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -33,14 +33,13 @@ class SkyMartBestProfit {
val priceMap = mutableMapOf<Pair<String, String>, Double>()
- val auctionManager = NotEnoughUpdates.INSTANCE.manager.auctionManager
for (stack in inventory.items.values) {
for (line in stack.getLore()) {
val matcher = pattern.matcher(line)
if (!matcher.matches()) continue
val internalName = stack.getInternalName()
- val lowestBin = auctionManager.getBazaarOrBin(internalName, false)
+ val lowestBin = NEUItems.getPrice(internalName)
if (lowestBin == -1.0) continue
val amount = matcher.group(1).replace(",", "").toInt()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt
index 898c7f34c..742a665f9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCraftHelper.kt
@@ -1,12 +1,13 @@
package at.hannibal2.skyhanni.features.minion
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import net.minecraft.client.Minecraft
@@ -49,9 +50,7 @@ class MinionCraftHelper {
for (item in mainInventory) {
val name = item?.name?.removeColor() ?: continue
- val rawId = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
- .withItemStack(item)
- .resolveInternalName() ?: continue
+ val rawId = item.getInternalName()
if (name.contains(" Minion ")) {
minions[name] = rawId
} else {
@@ -79,7 +78,7 @@ class MinionCraftHelper {
) {
val nextNumber = minionNumber + 1
display.add("$minionName Minion $minionNumber -> $nextNumber")
- val recipes: List<NeuRecipe> = NotEnoughUpdates.INSTANCE.manager.getAvailableUsagesFor(minionId)
+ val recipes: List<NeuRecipe> = NEUItems.manager.getAvailableUsagesFor(minionId)
for (recipe in recipes) {
if (recipe !is CraftingRecipe) continue
val output = recipe.output
@@ -100,9 +99,7 @@ class MinionCraftHelper {
val needAmount = need * multiplier
val have = otherItems.getOrDefault(itemId, 0)
val percentage = have.toDouble() / needAmount
- val itemName = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery()
- .withKnownInternalName(rawId)
- .resolveToItemStack()?.name ?: "§cName??§f"
+ val itemName = NEUItems.getItemStack(rawId).name ?: "§cName??§f"
if (percentage >= 1) {
display.add(" $itemName§8: §aDONE")
display.add(" ")
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 e5754e1a7..f93a57551 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
@@ -79,7 +79,7 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH
} else {
val lineList = mutableListOf<Any>()
lineList.add(" ")
- lineList.add(NEUItems.readItemFromRepo(displayItem))
+ lineList.add(NEUItems.getItemStack(displayItem))
lineList.add("$displayName: $result")
display.add(lineList)
}
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 2d7092b1c..abac83c25 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
@@ -271,7 +271,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) {
result.add(" $stateText$type: §f$displayName$multipleText$sacksText")
} else {
result.add(" $stateText$type: ")
- result.add(NEUItems.readItemFromRepo(item))
+ result.add(NEUItems.getItemStack(item))
result.add("§f$displayName$multipleText$sacksText")
}
return result
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 24aeefdf1..f52d038ab 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
@@ -87,7 +87,7 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel
} else {
val lineList = mutableListOf<Any>()
lineList.add(" ")
- lineList.add(NEUItems.readItemFromRepo(displayItem))
+ lineList.add(NEUItems.getItemStack(displayItem))
lineList.add("$displayName: $result")
display.add(lineList)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 714adcec4..62546ee81 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -4,8 +4,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
-import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
@@ -115,12 +113,7 @@ object ItemUtils {
return false
}
- fun ItemStack.getInternalName(): String {
- return ItemResolutionQuery(NotEnoughUpdates.INSTANCE.manager)
- .withCurrentGuiContext()
- .withItemStack(this)
- .resolveInternalName() ?: ""
- }
+ fun ItemStack.getInternalName() = NEUItems.getInternalName(this)
fun ItemStack.getSkullTexture(): String? {
if (item != Items.skull) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index ecbcc9c93..c826ac1f6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.utils
+import io.github.moulberry.notenoughupdates.NEUManager
import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
import io.github.moulberry.notenoughupdates.util.Utils
@@ -8,24 +9,34 @@ import net.minecraft.init.Items
import net.minecraft.item.ItemStack
object NEUItems {
-
+ val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager
private val itemCache = mutableMapOf<String, ItemStack>()
- fun getInternalNameByName(rawName: String): String? {
- return ItemResolutionQuery.findInternalNameByDisplayName(rawName, false)
+ fun getInternalName(itemName: String): String {
+ return ItemResolutionQuery.findInternalNameByDisplayName(itemName, false)
+ }
+
+ fun getInternalName(itemStack: ItemStack): String {
+ return ItemResolutionQuery(manager)
+ .withCurrentGuiContext()
+ .withItemStack(itemStack)
+ .resolveInternalName() ?: ""
}
- fun readItemFromRepo(internalName: String): ItemStack {
+ fun getPrice(internalName: String, useSellingPrice: Boolean = false): Double {
+ return manager.auctionManager.getBazaarOrBin(internalName, useSellingPrice)
+ }
+
+ fun getItemStack(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 itemCache[internalName]!!.copy()
}
- return itemStack
+
+ val itemStack = ItemResolutionQuery(manager)
+ .withKnownInternalName(internalName)
+ .resolveToItemStack()!!
+ itemCache[internalName] = itemStack
+ return itemStack.copy()
}
fun ItemStack.renderOnScreen(x: Float, y: Float) {