aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt5
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt8
7 files changed, 120 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index bfbdcb81d..ee3bdce7d 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -227,6 +227,7 @@ public class SkyHanniMod {
loadModule(new CropMoneyDisplay());
loadModule(new JacobFarmingContestsInventory());
loadModule(new GardenNextJacobContest());
+ loadModule(new WrongFungiCutterWarning());
Commands.INSTANCE.init();
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 27a131eda..75f934584 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -438,4 +438,9 @@ public class Garden {
@ConfigOption(name = "Desk in Menu", desc = "Show a Desk button in the SkyBlock Menu. Opens the /desk command on click.")
@ConfigEditorBoolean
public boolean deskInSkyBlockMenu = true;
+
+ @Expose
+ @ConfigOption(name = "Fungi Cutter Warning", desc = "Warn when breaking mushroom with the wrong Fungi Cutter mode.")
+ @ConfigEditorBoolean
+ public boolean fungiCutterWarn = true;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
index eca74c707..b256113a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
@@ -1,7 +1,10 @@
package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
import at.hannibal2.skyhanni.utils.LorenzVec
import net.minecraft.item.ItemStack
-class BlockClickEvent(val clickType: ClickType, val position: LorenzVec, val itemInHand: ItemStack?) : LorenzEvent() \ No newline at end of file
+class BlockClickEvent(val clickType: ClickType, val position: LorenzVec, val itemInHand: ItemStack?) : LorenzEvent() {
+ val getBlockState by lazy { position.getBlockStateAt() }
+} \ No newline at end of file
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
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
index 776ba7f6c..5138ebf35 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.utils
import net.minecraft.block.Block
+import net.minecraft.block.state.IBlockState
import net.minecraft.client.Minecraft
import net.minecraft.tileentity.TileEntitySkull
import net.minecraft.util.BlockPos
@@ -9,7 +10,10 @@ import net.minecraftforge.common.util.Constants
object BlockUtils {
fun LorenzVec.getBlockAt(): Block =
- Minecraft.getMinecraft().theWorld.getBlockState(toBlocPos()).block
+ getBlockStateAt().block
+
+ fun LorenzVec.getBlockStateAt(): IBlockState =
+ Minecraft.getMinecraft().theWorld.getBlockState(toBlocPos())
fun LorenzVec.isInLoadedChunk(): Boolean =
Minecraft.getMinecraft().theWorld.chunkProvider.provideChunk(toBlocPos()).isLoaded
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
index 1fb107375..26f06df29 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
@@ -14,6 +14,14 @@ object SoundUtils {
try {
Minecraft.getMinecraft().soundHandler.playSound(this)
} catch (e: Exception) {
+ if (e is IllegalArgumentException) {
+ e.message?.let {
+ if (it.startsWith("value already present:")) {
+ println("SkyHanni Sound error: $it")
+ return
+ }
+ }
+ }
e.printStackTrace()
}
gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel)