diff options
author | nea <romangraef@gmail.com> | 2022-11-13 01:04:59 +0100 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-11-13 01:04:59 +0100 |
commit | 2ba77d7d840b7fecbbf3825e1f507cd408c04f85 (patch) | |
tree | 64d7b515c6b33b57e82f7e47f57824453c8f5238 /src/main | |
parent | 1e2c632527715472ff5c4f0be80d330e62691fee (diff) | |
download | neuhax-2ba77d7d840b7fecbbf3825e1f507cd408c04f85.tar.gz neuhax-2ba77d7d840b7fecbbf3825e1f507cd408c04f85.tar.bz2 neuhax-2ba77d7d840b7fecbbf3825e1f507cd408c04f85.zip |
fix crash
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/moe/nea/sky/mixin/MixinGenericBlockHighlighter.java (renamed from src/main/java/moe/nea/sky/mixin/MixinGlowingMushroomHighlighter.java) | 17 | ||||
-rw-r--r-- | src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigFishing.java | 65 | ||||
-rw-r--r-- | src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigWorld.java | 6 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/NEUHax.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/config/HaxConfigFishing.kt | 9 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/config/HaxConfigWorld.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/sky/features/world/AutoFishing.kt | 80 | ||||
-rw-r--r-- | src/main/resources/mixins.neuhax.json | 3 |
8 files changed, 176 insertions, 12 deletions
diff --git a/src/main/java/moe/nea/sky/mixin/MixinGlowingMushroomHighlighter.java b/src/main/java/moe/nea/sky/mixin/MixinGenericBlockHighlighter.java index 4b31225..b9d6e33 100644 --- a/src/main/java/moe/nea/sky/mixin/MixinGlowingMushroomHighlighter.java +++ b/src/main/java/moe/nea/sky/mixin/MixinGenericBlockHighlighter.java @@ -1,18 +1,25 @@ package moe.nea.sky.mixin; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.miscfeatures.world.GlowingMushroomHighlighter; +import io.github.moulberry.notenoughupdates.miscfeatures.world.GenericBlockHighlighter; import moe.nea.sky.config.HaxConfigWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(GlowingMushroomHighlighter.class) -public class MixinGlowingMushroomHighlighter { - @Inject(method = "canPlayerSee", at = @At("HEAD"), cancellable = true, remap = false) +@Mixin(GenericBlockHighlighter.class) +public class MixinGenericBlockHighlighter { + @Inject(method = "canPlayerSeeBlock", at = @At("HEAD"), cancellable = true, remap = false) public void onCanPlayerSee(double xCoord, double yCoord, double zCoord, CallbackInfoReturnable<Boolean> cir) { - if (((HaxConfigWorld) NotEnoughUpdates.INSTANCE.config.world).getNeuHaxMushroomWallhacks()) { + if (((HaxConfigWorld) NotEnoughUpdates.INSTANCE.config.world).getNeuHaxWallhacks()) { + cir.setReturnValue(true); + } + } + + @Inject(method = "canPlayerSeeNearBlocks", at = @At("HEAD"), cancellable = true, remap = false) + public void onPlayerCanSeeNearBlocks(double x, double y, double z, CallbackInfoReturnable<Boolean> cir) { + if (((HaxConfigWorld) NotEnoughUpdates.INSTANCE.config.world).getNeuHaxWallhacks()) { cir.setReturnValue(true); } } diff --git a/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigFishing.java b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigFishing.java new file mode 100644 index 0000000..ccdd034 --- /dev/null +++ b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigFishing.java @@ -0,0 +1,65 @@ +package moe.nea.sky.mixin.config; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.*; +import io.github.moulberry.notenoughupdates.options.seperateSections.Fishing; +import moe.nea.sky.config.HaxConfigFishing; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(Fishing.class) +public class MixinHaxConfigFishing implements HaxConfigFishing { + private static final int NEUHAXACCORDIONID = 10000; + @ConfigOption(name = "Auto Fishing", desc = "AutoFishing") + @ConfigEditorAccordion(id = NEUHAXACCORDIONID) + public boolean neuHaxAutoFishing = false; + + @Expose + @ConfigOption( + name = "Enable Auto Fishing", + desc = "Automatically reel in fish") + @ConfigAccordionId(id = NEUHAXACCORDIONID) + @ConfigEditorBoolean() + public boolean neuHaxAutoFishEnable = false; + @Expose + @ConfigOption( + name = "Minimum Delay", + desc = "Minimum delay to wait before reeling in the fish after it gets hooked, in ticks") + @ConfigAccordionId(id = NEUHAXACCORDIONID) + @ConfigEditorSlider(minValue = 0, maxValue = 40, minStep = 1) + public int neuHaxAutoFishMinDelay = 2; + @Expose + @ConfigOption( + name = "Maximum Delay", + desc = "Maximum delay to wait before reeling in the fish after it gets hooked, in ticks") + @ConfigAccordionId(id = NEUHAXACCORDIONID) + @ConfigEditorSlider(minValue = 0, maxValue = 40, minStep = 1) + public int neuHaxAutoFishMaxDelay = 10; + + @Expose + @ConfigOption( + name = "Reextend Fishing Rod", + desc = "Automatically start fishing again after fishing up something") + @ConfigAccordionId(id = NEUHAXACCORDIONID) + @ConfigEditorBoolean() + public boolean neuHaxReengageFishingRod = false; + + @Override + public boolean getNeuHaxAutoFishEnable() { + return neuHaxAutoFishEnable; + } + + @Override + public boolean getNeuHaxReengageFishingRod() { + return neuHaxReengageFishingRod; + } + + @Override + public int getNeuHaxAutoFishDelayMinimum() { + return neuHaxAutoFishMinDelay; + } + + @Override + public int getNeuHaxAutoFishDelayMaximum() { + return neuHaxAutoFishMaxDelay; + } +} diff --git a/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigWorld.java b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigWorld.java index 971d0cd..959ae6e 100644 --- a/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigWorld.java +++ b/src/main/java/moe/nea/sky/mixin/config/MixinHaxConfigWorld.java @@ -16,18 +16,18 @@ public class MixinHaxConfigWorld implements HaxConfigWorld { public boolean neuHaxAccordion = false; @Expose - @ConfigOption(name = "Mushroom Wallhacks", desc = "See glowing mushrooms through walls") + @ConfigOption(name = "Wallhacks", desc = "See highlighted blocks through walls") @ConfigAccordionId(id = 10000) @ConfigEditorBoolean public boolean neuHaxMushroomWallhacks = true; @Override - public boolean getNeuHaxMushroomWallhacks() { + public boolean getNeuHaxWallhacks() { return this.neuHaxMushroomWallhacks; } @Override - public void setNeuHaxMushroomWallhacks(boolean b) { + public void setNeuHaxWallhacks(boolean b) { this.neuHaxMushroomWallhacks = b; } } diff --git a/src/main/kotlin/moe/nea/sky/NEUHax.kt b/src/main/kotlin/moe/nea/sky/NEUHax.kt index b37a619..46d5f88 100644 --- a/src/main/kotlin/moe/nea/sky/NEUHax.kt +++ b/src/main/kotlin/moe/nea/sky/NEUHax.kt @@ -2,6 +2,7 @@ package moe.nea.sky import moe.nea.sky.commands.NEUHaxCommand import moe.nea.sky.features.gui.Enchanting +import moe.nea.sky.features.world.AutoFishing import moe.nea.sky.util.CommandActionRegistry import net.minecraft.launchwrapper.Launch import net.minecraftforge.client.ClientCommandHandler @@ -29,8 +30,9 @@ object NEUHax { @EventHandler fun onInit(event: FMLInitializationEvent) { - listOf<Any>( - Enchanting + listOf( + Enchanting, + AutoFishing, ).forEach { MinecraftForge.EVENT_BUS.register(it) } diff --git a/src/main/kotlin/moe/nea/sky/config/HaxConfigFishing.kt b/src/main/kotlin/moe/nea/sky/config/HaxConfigFishing.kt new file mode 100644 index 0000000..634049b --- /dev/null +++ b/src/main/kotlin/moe/nea/sky/config/HaxConfigFishing.kt @@ -0,0 +1,9 @@ +package moe.nea.sky.config + +interface HaxConfigFishing { + val neuHaxAutoFishEnable: Boolean + // TODO: val neuHaxAutoFishToggleButton: Int + val neuHaxAutoFishDelayMinimum: Int + val neuHaxAutoFishDelayMaximum: Int + val neuHaxReengageFishingRod: Boolean +}
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/sky/config/HaxConfigWorld.kt b/src/main/kotlin/moe/nea/sky/config/HaxConfigWorld.kt index db9a44d..fd48461 100644 --- a/src/main/kotlin/moe/nea/sky/config/HaxConfigWorld.kt +++ b/src/main/kotlin/moe/nea/sky/config/HaxConfigWorld.kt @@ -1,5 +1,5 @@ package moe.nea.sky.config interface HaxConfigWorld { - var neuHaxMushroomWallhacks: Boolean + var neuHaxWallhacks: Boolean }
\ No newline at end of file diff --git a/src/main/kotlin/moe/nea/sky/features/world/AutoFishing.kt b/src/main/kotlin/moe/nea/sky/features/world/AutoFishing.kt new file mode 100644 index 0000000..f3f917c --- /dev/null +++ b/src/main/kotlin/moe/nea/sky/features/world/AutoFishing.kt @@ -0,0 +1,80 @@ +/** + * 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.world + +import cc.polyfrost.oneconfig.utils.dsl.mc +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper +import moe.nea.sky.config.HaxConfigFishing +import net.minecraft.entity.projectile.EntityFishHook +import net.minecraft.init.Items +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import kotlin.random.Random + +/** + * Auto Fishing that integrates with NEUs [FishingHelper] to automatically reel in fish. It waits a random, configurable + * amount before each catch and can automatically start fishing again. + * + * **Config**: [moe.nea.sky.mixin.config.MixinHaxConfigFishing] + */ +object AutoFishing { + + val config get() = NotEnoughUpdates.INSTANCE.config.fishing as HaxConfigFishing + + private fun randomDelay() = Random.Default.nextInt( + config.neuHaxAutoFishDelayMinimum, + config.neuHaxAutoFishDelayMaximum.coerceAtLeast(config.neuHaxAutoFishDelayMinimum) + ) + + private var delay = -1 + private var shouldReengage = false + private var lastFishingHook: EntityFishHook? = null + private fun shouldAutoFish(): Boolean { + if (!config.neuHaxAutoFishEnable) + return false + if (delay == 0) { + delay = -1 + return true + } + if (delay < 0) + delay = randomDelay() + delay -= 1 + return false + } + + @SubscribeEvent + fun onTick(ev: TickEvent.ClientTickEvent) { + if (ev.phase != TickEvent.Phase.END) return + val p = mc.thePlayer ?: return + if (shouldReengage) { + if (p.fishEntity == lastFishingHook) return + if (p.fishEntity != null || p.heldItem?.item != Items.fishing_rod) { + shouldReengage = false + delay = -1 + return + } + if (shouldAutoFish()) { + shouldReengage = false + mc.playerController.sendUseItem(p, p.worldObj, p.heldItem) + } + return + } + if (FishingHelper.getInstance().warningState != FishingHelper.PlayerWarningState.FISH_HOOKED) return + if (lastFishingHook != p.fishEntity && shouldAutoFish()) { + mc.playerController.sendUseItem(p, p.worldObj, p.heldItem) + lastFishingHook = p.fishEntity + if (config.neuHaxReengageFishingRod) { + shouldReengage = true + } + } + } + +}
\ No newline at end of file diff --git a/src/main/resources/mixins.neuhax.json b/src/main/resources/mixins.neuhax.json index 8d80776..73ae30c 100644 --- a/src/main/resources/mixins.neuhax.json +++ b/src/main/resources/mixins.neuhax.json @@ -6,9 +6,10 @@ "mixins": [ "MixinEnchantingSolvers", "MixinFMLHandshakeMessageModList", - "MixinGlowingMushroomHighlighter", + "MixinGenericBlockHighlighter", "MixinUltrasequencerItem", "config.MixinHaxConfigEnchanting", + "config.MixinHaxConfigFishing", "config.MixinHaxConfigWorld" ], "client": [ |