diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-20 01:20:24 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-20 01:20:24 +0200 |
commit | 317fcbd610df900401b534db06b899d837413725 (patch) | |
tree | eebc08fddea43f6418d1c86809709a2db36ae8c6 /src/main/java | |
parent | 1e52428d3939d0b579cbc156b4e30fb4e8cdc342 (diff) | |
download | skyhanni-317fcbd610df900401b534db06b899d837413725.tar.gz skyhanni-317fcbd610df900401b534db06b899d837413725.tar.bz2 skyhanni-317fcbd610df900401b534db06b899d837413725.zip |
Added support for hoe counter and cultivating ove 1b
Diffstat (limited to 'src/main/java')
3 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index d6ffa41ab..46f7c1fe1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -109,7 +109,7 @@ object GardenAPI { return CropType.values().firstOrNull { internalName.startsWith(it.toolName) } } - fun readCounter(itemStack: ItemStack): Int = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1 + fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L fun CropType.getSpeed(): Int { val speed = cropsPerSecond[this] diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 7b644578a..fbefe574a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -29,7 +29,7 @@ import kotlin.concurrent.fixedRateTimer class GardenCropMilestoneDisplay { private var progressDisplay = listOf<List<Any>>() private var mushroomCowPerkDisplay = listOf<List<Any>>() - private val cultivatingData = mutableMapOf<CropType, Int>() + private val cultivatingData = mutableMapOf<CropType, Long>() private val config get() = SkyHanniMod.feature.garden private val bestCropTime = GardenBestCropTime() // val cropMilestoneLevelUpPattern = Pattern.compile(" §r§b§lGARDEN MILESTONE §3(.*) §8XXIII➜§3(.*)") @@ -117,11 +117,11 @@ class GardenCropMilestoneDisplay { try { val item = event.itemStack val counter = GardenAPI.readCounter(item) - if (counter == -1) return + if (counter == -1L) return val crop = item.getCropType() ?: return if (cultivatingData.containsKey(crop)) { val old = cultivatingData[crop]!! - val addedCounter = counter - old + val addedCounter = (counter - old).toInt() if (GardenCropMilestones.cropCounter.isEmpty()) { for (innerCrop in CropType.values()) { @@ -283,7 +283,7 @@ class GardenCropMilestoneDisplay { lineMap[2] = Collections.singletonList("§e$haveFormat§8/§e$needFormat") lastItemInHand?.let { - if (GardenAPI.readCounter(it) == -1) { + if (GardenAPI.readCounter(it) == -1L) { lineMap[3] = Collections.singletonList("§cWarning: You need Cultivating!") return formatDisplay(lineMap) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index 25cae741c..60d2d9860 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -11,9 +11,9 @@ object SkyBlockItemModifierUtils { fun ItemStack.getFarmingForDummiesCount() = getAttributeInt("farming_for_dummies_count") - fun ItemStack.getCultivatingCounter() = getAttributeInt("farmed_cultivating") + fun ItemStack.getCultivatingCounter() = getAttributeLong("farmed_cultivating") - fun ItemStack.getHoeCounter() = getAttributeInt("mined_crops") + fun ItemStack.getHoeCounter() = getAttributeLong("mined_crops") fun ItemStack.getSilexCount() = getEnchantments()?.get("efficiency")?.let { it - 5 - if (getInternalName() == "STONK_PICKAXE") 1 else 0 @@ -141,6 +141,9 @@ object SkyBlockItemModifierUtils { private fun ItemStack.getAttributeInt(label: String) = getExtraAttributes()?.getInteger(label)?.takeUnless { it == 0 } + private fun ItemStack.getAttributeLong(label: String) = + getExtraAttributes()?.getLong(label)?.takeUnless { it == 0L } + private fun ItemStack.getAttributeBoolean(label: String): Boolean { return getExtraAttributes()?.hasKey(label) ?: false } |