diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
8 files changed, 43 insertions, 37 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 4a8deee36..4c19346b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -24,14 +25,11 @@ import net.minecraft.client.Minecraft import net.minecraft.item.ItemStack import net.minecraft.network.play.client.C09PacketHeldItemChange import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.time.Duration.Companion.seconds object GardenAPI { - private val cropsPerSecond: MutableMap<CropType, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond - var toolInHand: String? = null var itemInHand: ItemStack? = null var cropInHand: CropType? = null @@ -123,15 +121,6 @@ object GardenAPI { return false } - @SubscribeEvent(priority = EventPriority.LOW) - fun onProfileJoin(event: ProfileJoinEvent) { - if (cropsPerSecond.isEmpty()) { - for (cropType in CropType.values()) { - cropType.setSpeed(-1) - } - } - } - fun inGarden() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.GARDEN fun ItemStack.getCropType(): CropType? { @@ -141,21 +130,6 @@ object GardenAPI { fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L - fun CropType.getSpeed(): Int { - val speed = cropsPerSecond[this] - if (speed != null) return speed - - val message = "Set speed for $this to -1!" - println(message) - LorenzUtils.debug(message) - setSpeed(-1) - return -1 - } - - fun CropType.setSpeed(speed: Int) { - cropsPerSecond[this] = speed - } - fun MutableList<Any>.addCropIcon(crop: CropType) { try { add(crop.icon) @@ -164,8 +138,6 @@ object GardenAPI { } } - fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0 - fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory || SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt index a598b6000..fd8d592fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.features.garden.GardenAPI.getSpeed import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted 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 c26fbd278..e6d0edb56 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 @@ -8,8 +8,9 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarData import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.getSpeed import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList @@ -108,7 +109,7 @@ class CropMoneyDisplay { val moneyPerHourData = calculateMoneyPerHour() if (moneyPerHourData.isEmpty()) { - if (!GardenAPI.isSpeedDataEmpty()) { + if (!isSpeedDataEmpty()) { val message = "money/hr empty but speed data not empty, retry" LorenzUtils.debug(message) println(message) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt index c0d2b1ee1..1440449ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.getSpeed +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index 0b9993826..10726fc44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon -import at.hannibal2.skyhanni.features.garden.GardenAPI.getSpeed import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.TimeUtils 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 1fcd91fcf..688d08b19 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 @@ -11,7 +11,8 @@ import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType -import at.hannibal2.skyhanni.features.garden.GardenAPI.setSpeed +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -95,7 +96,7 @@ object GardenCropMilestoneDisplay { innerCrop.setCounter(0) } } - if (GardenAPI.isSpeedDataEmpty()) { + if (isSpeedDataEmpty()) { for (cropType in CropType.values()) { cropType.setSpeed(-1) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 5b61fbc7e..41c743289 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -7,14 +7,20 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter import at.hannibal2.skyhanni.data.MayorElection import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer import kotlin.math.abs object GardenCropSpeed { private val config get() = SkyHanniMod.feature.garden + private val hidden get() = SkyHanniMod.feature.hidden + private val cropsPerSecond: MutableMap<CropType, Int> get() = hidden.gardenCropsPerSecond + var lastBrokenCrop: CropType? = null var averageBlocksPerSecond = 0.0 @@ -89,5 +95,31 @@ object GardenCropSpeed { return forcefullyEnabledAlwaysFinnegan || perkActive } + @SubscribeEvent(priority = EventPriority.LOW) + fun onProfileJoin(event: ProfileJoinEvent) { + if (cropsPerSecond.isEmpty()) { + for (cropType in CropType.values()) { + cropType.setSpeed(-1) + } + } + } + fun isEnabled() = GardenAPI.inGarden() + + fun CropType.getSpeed(): Int { + val speed = cropsPerSecond[this] + if (speed != null) return speed + + val message = "Set speed for $this to -1!" + println(message) + LorenzUtils.debug(message) + setSpeed(-1) + return -1 + } + + fun CropType.setSpeed(speed: Int) { + cropsPerSecond[this] = speed + } + + fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0 }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 6066608ec..a803481b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.getSpeed +import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName |