aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-30 10:19:30 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-30 10:22:52 +0200
commit7a09f5e6b78680719977d4e0e7f71a31a2b031f1 (patch)
tree30a53c86e5c86c9255e287a90f3b3e6368cb7df8 /src/main
parente801db2c44f4840806da58d0879779b1812c4fd2 (diff)
downloadskyhanni-7a09f5e6b78680719977d4e0e7f71a31a2b031f1.tar.gz
skyhanni-7a09f5e6b78680719977d4e0e7f71a31a2b031f1.tar.bz2
skyhanni-7a09f5e6b78680719977d4e0e7f71a31a2b031f1.zip
Added and used CropClickEvent to fix wrong cactus blocks per second values
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt16
9 files changed, 72 insertions, 49 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index eca13920f..f35f08c96 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -38,7 +38,7 @@ class ConfigManager {
configFile = File(configDirectory, "config.json")
- fixedRateTimer(name = "config-auto-save", period = 60_000L, initialDelay = 60_000L) {
+ fixedRateTimer(name = "skyhanni-config-auto-save", period = 60_000L, initialDelay = 60_000L) {
saveConfig("auto-save-60s")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt
new file mode 100644
index 000000000..848004262
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt
@@ -0,0 +1,13 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.features.garden.CropType
+import net.minecraft.block.state.IBlockState
+import net.minecraft.item.ItemStack
+
+class CropClickEvent(
+ val crop: CropType,
+ val blockState: IBlockState,
+ val clickType: ClickType,
+ val itemInHand: ItemStack?
+): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
index 2e40a363b..5bdc812fc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
@@ -30,7 +30,7 @@ class DungeonMilestonesDisplay {
}
init {
- fixedRateTimer(name = "dungeon-milestone-display", period = 200) {
+ fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 200) {
if (!isEnabled()) return@fixedRateTimer
checkVisibility()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 1f2f32115..ae1c61564 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel
import at.hannibal2.skyhanni.events.*
-import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop
import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
@@ -51,9 +50,8 @@ class FarmingFortuneDisplay {
}
@SubscribeEvent
- fun onBlockBreak(event: BlockClickEvent) {
- if (!GardenAPI.inGarden()) return
- val cropBroken = event.getBlockState.getCropType() ?: return
+ fun onBlockBreak(event: CropClickEvent) {
+ val cropBroken = event.crop
if (cropBroken != currentCrop) {
currentCrop = cropBroken
updateToolFortune(event.itemInHand)
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 31cfa4b49..4a8deee36 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -4,13 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.*
+import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
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.inventory.SkyMartCopperPrice
+import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.MinecraftDispatcher
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter
@@ -164,7 +167,7 @@ object GardenAPI {
fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0
fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory ||
- SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory
+ SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory
fun clearCropSpeed() {
for (type in CropType.values()) {
@@ -179,4 +182,25 @@ object GardenAPI {
val brokenCrop = if (toolInHand != null) GardenCropSpeed.lastBrokenCrop else null
return cropInHand ?: brokenCrop
}
+
+ private var lastLocation: LorenzVec? = null
+
+ @SubscribeEvent
+ fun onBlockBreak(event: BlockClickEvent) {
+ if (!inGarden()) return
+
+ val blockState = event.getBlockState
+ val cropBroken = blockState.getCropType() ?: return
+ if (cropBroken.multiplier == 1) {
+ if (blockState.isBabyCrop()) return
+ }
+
+ val position = event.position
+ if (lastLocation == position) {
+ return
+ }
+
+ lastLocation = position
+ CropClickEvent(cropBroken, blockState, event.clickType, event.itemInHand).postAndCatch()
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
index a1551fa52..70e6791b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt
@@ -2,13 +2,11 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
-import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.CropMilestoneUpdateEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.features.garden.CropType
-import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
@@ -24,18 +22,13 @@ class CropSpeedMeter {
private var snapshot = listOf<String>()
@SubscribeEvent
- fun onBlockBreak(event: BlockClickEvent) {
+ fun onBlockBreak(event: CropClickEvent) {
if (!isEnabled()) return
if (startCrops.isEmpty()) return
- val blockState = event.getBlockState
- val cropBroken = blockState.getCropType() ?: return
- if (cropBroken.multiplier == 1) {
- if (blockState.isBabyCrop()) return
- }
-
- if (currentCrop != cropBroken) {
- currentCrop = cropBroken
+ val crop = event.crop
+ if (currentCrop != crop) {
+ currentCrop = crop
currentBlocks = 0
snapshot = emptyList()
}
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 a7b1846d7..5b61fbc7e 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
@@ -5,12 +5,10 @@ import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter
import at.hannibal2.skyhanni.data.MayorElection
-import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.features.garden.CropType
-import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
import kotlin.math.abs
@@ -51,17 +49,11 @@ object GardenCropSpeed {
}
@SubscribeEvent
- fun onBlockClick(event: BlockClickEvent) {
+ fun onBlockClick(event: CropClickEvent) {
if (!GardenAPI.inGarden()) return
if (event.clickType != ClickType.LEFT_CLICK) return
- val blockState = event.getBlockState
-
- val cropType = blockState.getCropType() ?: return
- if (cropType.multiplier == 1) {
- if (blockState.isBabyCrop()) return
- }
- lastBrokenCrop = cropType
+ lastBrokenCrop = event.crop
blocksBroken++
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt
index 3aa4da422..76a5b50ad 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt
@@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.TitleUtils
-import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.garden.CropType
@@ -28,18 +28,19 @@ class WrongFungiCutterWarning {
}
@SubscribeEvent
- fun onBlockClick(event: BlockClickEvent) {
- if (event.clickType == ClickType.LEFT_CLICK) {
- val toString = event.getBlockState.toString()
- if (toString == "minecraft:red_mushroom") {
- if (mode == FungiMode.BROWN) {
- notifyWrong()
- }
+ fun onBlockClick(event: CropClickEvent) {
+ if (event.clickType != ClickType.LEFT_CLICK) return
+ if (event.crop != CropType.MUSHROOM) return
+
+ val toString = event.blockState.toString()
+ if (toString == "minecraft:red_mushroom") {
+ if (mode == FungiMode.BROWN) {
+ notifyWrong()
}
- if (toString == "minecraft:brown_mushroom") {
- if (mode == FungiMode.RED) {
- notifyWrong()
- }
+ }
+ if (toString == "minecraft:brown_mushroom") {
+ if (mode == FungiMode.RED) {
+ notifyWrong()
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
index 3535c31cd..4250ddfb3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
@@ -1,11 +1,10 @@
package at.hannibal2.skyhanni.features.garden.visitor
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.events.VisitorArrivalEvent
-import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -24,7 +23,9 @@ class GardenVisitorTimer {
private var visitorJustArrived: Boolean = false
private var visitorInterval
get() = SkyHanniMod.feature.hidden.visitorInterval
- set(value) { SkyHanniMod.feature.hidden.visitorInterval = value }
+ set(value) {
+ SkyHanniMod.feature.hidden.visitorInterval = value
+ }
@SubscribeEvent
fun onVisitorArrival(event: VisitorArrivalEvent) {
@@ -88,8 +89,8 @@ class GardenVisitorTimer {
val formatDuration = TimeUtils.formatDuration(millis)
val next = if (queueFull && (!isSixthVisitorEnabled() || millis < 0)) "§cQueue Full!" else {
- "Next in §$formatColor$formatDuration$extraSpeed"
- }
+ "Next in §$formatColor$formatDuration$extraSpeed"
+ }
val visitorLabel = if (visitorsAmount == 1) "visitor" else "visitors"
render = "§b$visitorsAmount $visitorLabel §7($next§7)"
}
@@ -108,14 +109,15 @@ class GardenVisitorTimer {
}
@SubscribeEvent
- fun onBlockBreak(event: BlockClickEvent) {
- if (!isEnabled() || event.getBlockState.getCropType() == null) return
+ fun onBlockBreak(event: CropClickEvent) {
+ if (!isEnabled()) return
sixthVisitorArrivalTime -= 100
}
private fun updateSixthVisitorArrivalTime() {
sixthVisitorArrivalTime = System.currentTimeMillis() + visitorInterval
}
+
private fun isSixthVisitorEnabled() = SkyHanniMod.feature.garden.visitorTimerSixthVisitorEnabled
private fun isEnabled() = GardenAPI.inGarden() && SkyHanniMod.feature.garden.visitorTimerEnabled
} \ No newline at end of file