diff options
-rw-r--r-- | build.gradle.kts | 2 | ||||
-rw-r--r-- | src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigNeuConfig.java | 36 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/NEUHax.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/config/HaxConfigNeuConfig.kt | 15 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/config/HaxConfigNeuHax.kt | 28 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/features/gui/Melody.kt | 50 | ||||
-rw-r--r-- | src/main/resources/mixins.neuhax.json | 1 |
7 files changed, 137 insertions, 1 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 3d816e5..c06cbd7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,7 +60,7 @@ dependencies { // If you don't want to log in with your real minecraft account, remove this line runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") - modCompileOnly(runtimeMod("com.github.notenoughupdates:notenoughupdates:9d0d62d6:all")!!) + modCompileOnly(runtimeMod("com.github.notenoughupdates:notenoughupdates:4a9e1c4:all")!!) } // Minecraft configuration: diff --git a/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigNeuConfig.java b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigNeuConfig.java new file mode 100644 index 0000000..2b37f06 --- /dev/null +++ b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigNeuConfig.java @@ -0,0 +1,36 @@ +/* + * 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.mixin.config; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.Category; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import moe.nea.sky.config.HaxConfigNeuConfig; +import moe.nea.sky.config.HaxConfigNeuHax; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(NEUConfig.class) +public class MixinHaxConfigNeuConfig implements HaxConfigNeuConfig { + + @Expose + @Category( + name = "NEU Hax", + desc = "NEU Hax specific settings" + ) + public HaxConfigNeuHax neuHax = new HaxConfigNeuHax(); + + @NotNull + @Override + public HaxConfigNeuHax getNeuHax() { + return neuHax; + } +} 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 diff --git a/src/main/resources/mixins.neuhax.json b/src/main/resources/mixins.neuhax.json index 73ae30c..802f834 100644 --- a/src/main/resources/mixins.neuhax.json +++ b/src/main/resources/mixins.neuhax.json @@ -10,6 +10,7 @@ "MixinUltrasequencerItem", "config.MixinHaxConfigEnchanting", "config.MixinHaxConfigFishing", + "config.MixinHaxConfigNeuConfig", "config.MixinHaxConfigWorld" ], "client": [ |