aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-12-21 23:40:10 +0100
committernea <romangraef@gmail.com>2022-12-21 23:40:10 +0100
commit6c631fbb4304acfd6d450ce462063e8a58a1b088 (patch)
tree8cfe9ddce42125e40577ee7bc22bea66f49745ec /src/main/kotlin
parent2e47f139aa5a6df25e30e266c009a51f7daec3c0 (diff)
downloadneuhax-6c631fbb4304acfd6d450ce462063e8a58a1b088.tar.gz
neuhax-6c631fbb4304acfd6d450ce462063e8a58a1b088.tar.bz2
neuhax-6c631fbb4304acfd6d450ce462063e8a58a1b088.zip
Auto Melody
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/moe/nea/sky/NEUHax.kt6
-rw-r--r--src/main/kotlin/moe/nea/sky/config/HaxConfigNeuConfig.kt15
-rw-r--r--src/main/kotlin/moe/nea/sky/config/HaxConfigNeuHax.kt28
-rw-r--r--src/main/kotlin/moe/nea/sky/features/gui/Melody.kt50
4 files changed, 99 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/sky/NEUHax.kt b/src/main/kotlin/moe/nea/sky/NEUHax.kt
index 2448bf1..27cd2cd 100644
--- a/src/main/kotlin/moe/nea/sky/NEUHax.kt
+++ b/src/main/kotlin/moe/nea/sky/NEUHax.kt
@@ -10,8 +10,11 @@
package moe.nea.sky
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import moe.nea.sky.commands.NEUHaxCommand
+import moe.nea.sky.config.HaxConfigNeuConfig
import moe.nea.sky.features.gui.Enchanting
+import moe.nea.sky.features.gui.Melody
import moe.nea.sky.features.world.AutoFishing
import moe.nea.sky.util.CommandActionRegistry
import net.minecraft.launchwrapper.Launch
@@ -31,6 +34,8 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
)
object NEUHax {
+ val neuHaxConfig get() = (NotEnoughUpdates.INSTANCE.config as HaxConfigNeuConfig).neuHax
+
val deobf by lazy { Launch.blackboard["fml.deobfuscatedEnvironment"] == true }
@EventHandler
@@ -43,6 +48,7 @@ object NEUHax {
listOf(
Enchanting,
AutoFishing,
+ Melody,
).forEach {
MinecraftForge.EVENT_BUS.register(it)
}
diff --git a/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuConfig.kt b/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuConfig.kt
new file mode 100644
index 0000000..31eda8b
--- /dev/null
+++ b/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuConfig.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NEUHax.
+ *
+ * NEUHax is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * NEUHax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License along with NEUHax. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package moe.nea.sky.config
+
+interface HaxConfigNeuConfig {
+ val neuHax: HaxConfigNeuHax
+} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuHax.kt b/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuHax.kt
new file mode 100644
index 0000000..ef342c4
--- /dev/null
+++ b/src/main/kotlin/moe/nea/sky/config/HaxConfigNeuHax.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NEUHax.
+ *
+ * NEUHax is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * NEUHax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License along with NEUHax. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package moe.nea.sky.config
+
+import com.google.gson.annotations.Expose
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption
+
+class HaxConfigNeuHax {
+
+ @Expose
+ @ConfigOption(
+ name = "Auto Melody",
+ desc = "Automatically play back melody songs"
+ )
+ @ConfigEditorBoolean
+ @JvmField
+ var autoMelody: Boolean = false
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/sky/features/gui/Melody.kt b/src/main/kotlin/moe/nea/sky/features/gui/Melody.kt
new file mode 100644
index 0000000..033d0e1
--- /dev/null
+++ b/src/main/kotlin/moe/nea/sky/features/gui/Melody.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NEUHax.
+ *
+ * NEUHax is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * NEUHax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License along with NEUHax. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package moe.nea.sky.features.gui
+
+import cc.polyfrost.oneconfig.utils.dsl.mc
+import moe.nea.sky.LOGGER
+import moe.nea.sky.NEUHax
+import moe.nea.sky.util.middleClickOn
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.init.Blocks
+import net.minecraft.inventory.ContainerChest
+import net.minecraft.item.Item
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
+
+
+object Melody {
+
+ var lastInventoryHashCode = 0
+
+ @SubscribeEvent
+ fun onGuiTick(event: ClientTickEvent) {
+ if (!NEUHax.neuHaxConfig.autoMelody) return
+ if (event.phase == TickEvent.Phase.START) return
+ val guiChest = mc.currentScreen as? GuiChest ?: return
+ val content = guiChest.inventorySlots as? ContainerChest ?: return
+ if (!content.lowerChestInventory.displayName.unformattedText.startsWith("Harp ")) return
+ val inventoryHashCode = content.inventory.hashCode()
+ if (inventoryHashCode == lastInventoryHashCode) return
+ lastInventoryHashCode = inventoryHashCode
+ for (i in 0 until content.lowerChestInventory.sizeInventory) {
+ val s = content.lowerChestInventory.getStackInSlot(i) ?: continue
+ if (s.item == Item.getItemFromBlock(Blocks.quartz_block)) {
+ content.middleClickOn(i)
+ break
+ }
+ }
+ }
+
+
+} \ No newline at end of file