aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt11
4 files changed, 69 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index c0dc1360b..40f55bd83 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -635,6 +635,14 @@ public class Garden {
public List<Integer> moneyPerHourCustomFormat = new ArrayList<>(Arrays.asList(0, 1, 2));
@Expose
+ @ConfigOption(
+ name = "Merge Seeds",
+ desc = "Merge the seeds price with the wheat price.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 13)
+ public boolean moneyPerHourMergeSeeds = true;
+
+ @Expose
public Position moneyPerHourPos = new Position(16, -232, false, true);
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
index e5fe7a056..ea1337e5b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
@@ -31,9 +31,9 @@ enum class CropType(val cropName: String, val toolName: String, val baseDrops: D
fun getByItemName(itemName: String): CropType? {
- if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") {
- return MUSHROOM
- }
+ if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM
+ if (itemName == "Seeds") return WHEAT
+
return getByName(itemName)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
index b8f123d43..63296bace 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.LorenzUtils.moveEntryToTop
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil
@@ -28,7 +29,7 @@ class CropMoneyDisplay {
private var tick = 0
private var loaded = false
private var ready = false
- private val multipliers = mutableMapOf<String, Int>()
+ private var multipliers = mapOf<String, Int>()
private val cropNames = mutableMapOf<String, CropType>() // internalName -> cropName
private var hasCropInHand = false
@@ -113,7 +114,15 @@ class CropMoneyDisplay {
}
try {
- list.add(NEUItems.getItemStack(internalName))
+ if (internalName == "ENCHANTED_SEEDS") {
+ list.add(NEUItems.getItemStack("BOX_OF_SEEDS"))
+ } else {
+ list.add(NEUItems.getItemStack(internalName))
+ }
+
+ if (cropNames[internalName] == CropType.WHEAT && config.moneyPerHourMergeSeeds) {
+ list.add(NEUItems.getItemStack("BOX_OF_SEEDS"))
+ }
} catch (e: NullPointerException) {
e.printStackTrace()
}
@@ -176,26 +185,46 @@ class CropMoneyDisplay {
private fun calculateMoneyPerHour(): Map<String, Array<Double>> {
val moneyPerHours = mutableMapOf<String, Array<Double>>()
- for ((internalName, amount) in multipliers) {
+
+ var seedsPrice: BazaarData? = null
+ var seedsPerHour = 0.0
+
+ for ((internalName, amount) in multipliers.moveEntryToTop { it.key == "ENCHANTED_SEEDS" }) {
val crop = cropNames[internalName]!!
- val speed = crop.getSpeed()
- // No speed data for item in hand
- if (speed == -1) continue
+ var speed = crop.getSpeed().toDouble()
+ if (speed == -1.0) continue
+ val isSeeds = internalName == "ENCHANTED_SEEDS"
+ if (isSeeds) speed *= 1.36
- val speedPerHr = speed.toDouble() * 60 * 60
- val blocksPerHour = speedPerHr / amount.toDouble()
+ val speedPerHour = speed * 60 * 60
+ val cropsPerHour = speedPerHour / amount.toDouble()
val bazaarData = BazaarApi.getBazaarDataForInternalName(internalName) ?: continue
- moneyPerHours[internalName] = formatNumbers(bazaarData, blocksPerHour)
+
+ var npcPrice = bazaarData.npcPrice * cropsPerHour
+ var sellOffer = bazaarData.buyPrice * cropsPerHour
+ var instantSell = bazaarData.sellPrice * cropsPerHour
+
+ if (crop == CropType.WHEAT && config.moneyPerHourMergeSeeds) {
+ if (isSeeds) {
+ seedsPrice = bazaarData
+ seedsPerHour = cropsPerHour
+ continue
+ } else {
+ seedsPrice?.let {
+ npcPrice += it.npcPrice * seedsPerHour
+ sellOffer += it.buyPrice * seedsPerHour
+ instantSell += it.sellPrice * seedsPerHour
+ }
+ }
+ }
+
+ moneyPerHours[internalName] = formatNumbers(sellOffer, instantSell, npcPrice)
}
return moneyPerHours
}
- private fun formatNumbers(bazaarData: BazaarData, blocksPerHour: Double): Array<Double> {
- val npcPrice = bazaarData.npcPrice * blocksPerHour
- val sellOffer = bazaarData.buyPrice * blocksPerHour
- val instantSell = bazaarData.sellPrice * blocksPerHour
-
+ private fun formatNumbers(sellOffer: Double, instantSell: Double, npcPrice: Double): Array<Double> {
return if (config.moneyPerHourUseCustomFormat) {
val map = mapOf(
0 to sellOffer,
@@ -229,21 +258,23 @@ class CropMoneyDisplay {
loaded = true
SkyHanniMod.coroutineScope.launch {
-
+ val map = mutableMapOf<String, Int>()
for ((internalName, _) in NotEnoughUpdates.INSTANCE.manager.itemInformation) {
if (!BazaarApi.isBazaarItem(internalName)) continue
if (internalName == "ENCHANTED_PAPER") continue
+ if (internalName == "ENCHANTED_BREAD") continue
val (newId, amount) = NEUItems.getMultiplier(internalName)
if (amount < 10) continue
val itemName = NEUItems.getItemStack(newId).name?.removeColor() ?: continue
val crop = CropType.getByItemName(itemName)
crop?.let {
- multipliers[internalName] = amount
+ map[internalName] = amount
cropNames[internalName] = it
}
}
+ multipliers = map
ready = true
update()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 552782025..c84710fe0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -213,4 +213,15 @@ object LorenzUtils {
HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§eExecute /$command"))
Minecraft.getMinecraft().thePlayer.addChatMessage(text)
}
+
+ fun <K, V> Map<K, V>.moveEntryToTop(matcher: (Map.Entry<K, V>) -> Boolean): Map<K, V> {
+ val entry = entries.find(matcher)
+ if (entry != null) {
+ val newMap = linkedMapOf(entry.key to entry.value)
+ newMap.putAll(this)
+ return newMap
+ }
+ return this
+ }
+
} \ No newline at end of file