aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-21 20:08:26 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-21 20:08:26 +0100
commit415c54df96ba46744a524715f10ff26962929903 (patch)
tree6def645d1ca21ae355487d4007b20108f8ab41cd /src/main/java/at/hannibal2/skyhanni/features/garden
parent8dcd991f418b8027b9e42b3afb87f28fbbe9c19a (diff)
downloadskyhanni-415c54df96ba46744a524715f10ff26962929903.tar.gz
skyhanni-415c54df96ba46744a524715f10ff26962929903.tar.bz2
skyhanni-415c54df96ba46744a524715f10ff26962929903.zip
Added wrong fungi cutter mode warning
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt96
2 files changed, 97 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
index 1faa8e3e7..c3c1f724d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt
@@ -31,6 +31,7 @@ class GardenCropMilestoneDisplay {
attenuationType = ISound.AttenuationType.NONE
}
}
+
private var lastPlaySoundTime = 0L
private var needsInventory = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt
new file mode 100644
index 000000000..e012b60c3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt
@@ -0,0 +1,96 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.data.SendTitleHelper
+import at.hannibal2.skyhanni.events.BlockClickEvent
+import at.hannibal2.skyhanni.events.GardenToolChangeEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.SoundUtils.playSound
+import net.minecraft.client.audio.ISound
+import net.minecraft.client.audio.PositionedSound
+import net.minecraft.item.ItemStack
+import net.minecraft.util.ResourceLocation
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class WrongFungiCutterWarning {
+ private var mode = FungiMode.UNKNOWN
+
+ private var lastPlaySoundTime = 0L
+ private val sound = object : PositionedSound(ResourceLocation("random.orb")) {
+ init {
+ volume = 50f
+ repeat = false
+ repeatDelay = 0
+ attenuationType = ISound.AttenuationType.NONE
+ }
+ }
+
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ val message = event.message
+ if (message == "§eFungi Cutter Mode: §r§cRed Mushrooms") {
+ mode = FungiMode.RED
+ }
+ if (message == "§eFungi Cutter Mode: §r§cBrown Mushrooms") {
+ mode = FungiMode.BROWN
+ }
+ }
+
+ @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()
+ }
+ }
+ if (toString == "minecraft:brown_mushroom") {
+ if (mode == FungiMode.RED) {
+ notifyWrong()
+ }
+ }
+ }
+ }
+
+ private fun notifyWrong() {
+ if (!SkyHanniMod.feature.garden.fungiCutterWarn) return
+
+ SendTitleHelper.sendTitle("§cWrong Fungi Cutter Mode!", 2_000)
+ if (System.currentTimeMillis() > lastPlaySoundTime + 3_00) {
+ lastPlaySoundTime = System.currentTimeMillis()
+ sound.playSound()
+ }
+ }
+
+ @SubscribeEvent
+ fun onGardenToolChange(event: GardenToolChangeEvent) {
+ val crop = event.crop ?: ""
+ if (crop == "Mushroom") {
+ readItem(event.heldItem!!)
+ } else {
+ mode = FungiMode.UNKNOWN
+ }
+ }
+
+ private fun readItem(item: ItemStack) {
+ for (line in item.getLore()) {
+ if (line == "§eMode: §cRed Mushrooms") {
+ mode = FungiMode.RED
+ }
+
+ if (line == "§eMode: §cBrown Mushrooms") {
+ mode = FungiMode.BROWN
+ }
+ }
+ }
+
+ enum class FungiMode {
+ RED,
+ BROWN,
+ UNKNOWN
+ }
+} \ No newline at end of file