diff --git a/src/main/java/dev/coredoes/maple/mixin/ClientPlayerEntityAccessor.java b/src/main/java/dev/coredoes/maple/mixin/ClientPlayerEntityAccessor.java new file mode 100644 index 0000000..091b49d --- /dev/null +++ b/src/main/java/dev/coredoes/maple/mixin/ClientPlayerEntityAccessor.java @@ -0,0 +1,11 @@ +package dev.coredoes.maple.mixin; + +import net.minecraft.client.network.ClientPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ClientPlayerEntity.class) +public interface ClientPlayerEntityAccessor { + @Accessor("ticksSinceLastPositionPacketSent") + void setTicksSinceLastPositionPacketSent(int ticks); +} diff --git a/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketAccessor.java b/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketAccessor.java new file mode 100644 index 0000000..747f853 --- /dev/null +++ b/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketAccessor.java @@ -0,0 +1,16 @@ +package dev.coredoes.maple.mixin; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(PlayerMoveC2SPacket.class) +public interface PlayerMoveC2SPacketAccessor { + @Mutable + @Accessor("y") + void setY(double y); + + @Mutable + @Accessor("onGround") + void setOnGround(boolean onGround); +} diff --git a/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketMixin.java b/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketMixin.java index 141e0db..b31eca5 100644 --- a/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketMixin.java +++ b/src/main/java/dev/coredoes/maple/mixin/PlayerMoveC2SPacketMixin.java @@ -1,6 +1,7 @@ package dev.coredoes.maple.mixin; import dev.coredoes.maple.module.BotMovement; +import dev.coredoes.maple.module.NoFall; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -21,6 +22,9 @@ public class PlayerMoveC2SPacketMixin { @Shadow protected double z; + @Mutable + @Shadow @Final protected boolean onGround; + @Inject(method = "", at = @At("TAIL")) public void constructor(double x, double y, double z, float yaw, float pitch, boolean onGround, boolean changePosition, boolean changeLook, CallbackInfo ci) { if (BotMovement.INSTANCE.isEnabled()) { @@ -29,5 +33,9 @@ public class PlayerMoveC2SPacketMixin { this.x = Math.nextAfter(newX, newX + Math.signum(newX)); // Round x this.z = Math.nextAfter(newZ, newZ + Math.signum(newZ)); // Round z } + + if (NoFall.INSTANCE.isEnabled()) { + this.onGround = true; + } } } diff --git a/src/main/kotlin/dev/coredoes/maple/gui/GuiUtil.kt b/src/main/kotlin/dev/coredoes/maple/gui/GuiUtil.kt new file mode 100644 index 0000000..4567fdc --- /dev/null +++ b/src/main/kotlin/dev/coredoes/maple/gui/GuiUtil.kt @@ -0,0 +1,17 @@ +package dev.coredoes.maple.gui + +import imgui.ImGui + +class GuiUtil { + companion object { + fun helpMarker(desc: String) { + if (ImGui.isItemHovered()) { + ImGui.beginTooltip() + ImGui.pushTextWrapPos(ImGui.getFontSize() * 35f) + ImGui.textUnformatted(desc) + ImGui.popTextWrapPos() + ImGui.endTooltip() + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/coredoes/maple/gui/panel/ConfigPanel.kt b/src/main/kotlin/dev/coredoes/maple/gui/panel/ConfigPanel.kt new file mode 100644 index 0000000..265beee --- /dev/null +++ b/src/main/kotlin/dev/coredoes/maple/gui/panel/ConfigPanel.kt @@ -0,0 +1,24 @@ +package dev.coredoes.maple.gui.panel + +import dev.coredoes.maple.manager.ModuleManager +import imgui.ImGui + +object ConfigPanel : Panel { + override fun draw() { + for (module in ModuleManager.getModules()) { + if (ImGui.treeNode(module.value.stringTitle())) { + module.value.drawConfig() + ImGui.treePop() + } + } + } + + override fun getTitle(): String { + return "Config" + } +} + +// -419284 79 765921 +// -52410 79 95740 + +// -176 128 73 diff --git a/src/main/kotlin/dev/coredoes/maple/manager/GuiManager.kt b/src/main/kotlin/dev/coredoes/maple/manager/GuiManager.kt index 5e13b23..814d63b 100644 --- a/src/main/kotlin/dev/coredoes/maple/manager/GuiManager.kt +++ b/src/main/kotlin/dev/coredoes/maple/manager/GuiManager.kt @@ -4,6 +4,7 @@ import dev.coredoes.maple.Manager import dev.coredoes.maple.Maple import dev.coredoes.maple.event.MapleEvent import dev.coredoes.maple.gui.panel.AboutPanel +import dev.coredoes.maple.gui.panel.ConfigPanel import dev.coredoes.maple.gui.panel.PanelManager import imgui.ImFontConfig import imgui.ImGui @@ -67,6 +68,7 @@ object GuiManager : Manager { override fun init() { PanelManager.registerPanel(AboutPanel) + PanelManager.registerPanel(ConfigPanel) } override fun stringName(): String { diff --git a/src/main/kotlin/dev/coredoes/maple/manager/ModuleManager.kt b/src/main/kotlin/dev/coredoes/maple/manager/ModuleManager.kt index d118554..51deaa6 100644 --- a/src/main/kotlin/dev/coredoes/maple/manager/ModuleManager.kt +++ b/src/main/kotlin/dev/coredoes/maple/manager/ModuleManager.kt @@ -1,14 +1,19 @@ package dev.coredoes.maple.manager import dev.coredoes.maple.Manager +import dev.coredoes.maple.Maple import dev.coredoes.maple.module.BotMovement +import dev.coredoes.maple.module.CreativeFlight import dev.coredoes.maple.module.Module +import dev.coredoes.maple.module.NoFall object ModuleManager : Manager { private val modules: MutableMap = mutableMapOf() override fun init() { registerModule("botmovement", BotMovement) + registerModule("nofall", NoFall) + registerModule("creativeflight", CreativeFlight) } override fun stringName(): String { @@ -17,8 +22,10 @@ object ModuleManager : Manager { fun registerModule(id: String, module: Module) { modules[id] = module + Maple.eventManager.registerClass(module) } fun unregisterModule(id: String) { + Maple.eventManager.unregisterClass(modules[id]!!) modules.remove(id) } fun enableModule(id: String) { @@ -27,4 +34,7 @@ object ModuleManager : Manager { fun disableModule(id: String) { modules[id]?.setEnabled(false) } + fun getModules(): MutableIterator> { + return modules.iterator() + } } \ No newline at end of file diff --git a/src/main/kotlin/dev/coredoes/maple/module/BotMovement.kt b/src/main/kotlin/dev/coredoes/maple/module/BotMovement.kt index b92f013..799b64f 100644 --- a/src/main/kotlin/dev/coredoes/maple/module/BotMovement.kt +++ b/src/main/kotlin/dev/coredoes/maple/module/BotMovement.kt @@ -1,10 +1,21 @@ package dev.coredoes.maple.module -object BotMovement : Module { - private var enabled = true +import imgui.ImGui +import imgui.type.ImBoolean - override fun isEnabled(): Boolean { return enabled } +object BotMovement : Module { + private var enabled = ImBoolean(true) + + override fun isEnabled(): Boolean { return enabled.get() } override fun setEnabled(enabled: Boolean) { - this.enabled = enabled + this.enabled.set(enabled) + } + + override fun stringTitle(): String { + return "BotMovement" + } + + override fun drawConfig() { + ImGui.checkbox("Enabled?", enabled) } } \ No newline at end of file diff --git a/src/main/kotlin/dev/coredoes/maple/module/CreativeFlight.kt b/src/main/kotlin/dev/coredoes/maple/module/CreativeFlight.kt new file mode 100644 index 0000000..6770f56 --- /dev/null +++ b/src/main/kotlin/dev/coredoes/maple/module/CreativeFlight.kt @@ -0,0 +1,82 @@ +package dev.coredoes.maple.module + +import dev.coredoes.maple.event.EventHandler +import dev.coredoes.maple.event.MapleEvent +import dev.coredoes.maple.gui.GuiUtil +import imgui.ImGui +import imgui.type.ImBoolean +import net.minecraft.client.MinecraftClient +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.PositionAndOnGround +import net.minecraft.util.math.Vec3d + + +object CreativeFlight : Module { + + private var antikick = ImBoolean(true) + private var enabled = ImBoolean(true) + private var speed = floatArrayOf(0.1f) + + private var fallingTicks = 0 + private var lastPos: Vec3d? = null + + override fun isEnabled(): Boolean { return enabled.get()} + override fun setEnabled(enabled: Boolean) { + this.enabled.set(enabled) + } + + override fun stringTitle(): String { + return "CreativeFlight" + } + + override fun drawConfig() { + ImGui.checkbox("Enabled?", enabled) + + ImGui.checkbox("Anti-Kick?", antikick) + GuiUtil.helpMarker("Prevent vanilla flykick") + + ImGui.sliderFloat("Speed", speed, 0.0f, 1.0f) + GuiUtil.helpMarker("Your speed when flying") + } + + @EventHandler + fun onPreTick(e: MapleEvent.PreTick) { + if (MinecraftClient.getInstance().player == null) return + + val flySpeed = speed + + if (enabled.get()) { + MinecraftClient.getInstance().player!!.abilities.allowFlying = true + MinecraftClient.getInstance().player!!.abilities.flySpeed = flySpeed[0] + } else { + MinecraftClient.getInstance().player!!.abilities.allowFlying = false + } + } + + @EventHandler + fun onPostTick(e: MapleEvent.PostTick) { + if (MinecraftClient.getInstance().player == null) return + + if (MinecraftClient.getInstance().player!!.abilities.flying) { + fallingTicks++ + + if (fallingTicks >= 20) { + var shouldAntikick = antikick.get() + + if (MinecraftClient.getInstance().player!!.isSneaking) { + if (lastPos != null && MinecraftClient.getInstance().player!!.y < lastPos!!.getY()) shouldAntikick = false + } + + if (shouldAntikick) { + MinecraftClient.getInstance().player!!.networkHandler.sendPacket(PositionAndOnGround( + MinecraftClient.getInstance().player!!.x, + MinecraftClient.getInstance().player!!.y - 0.03126, + MinecraftClient.getInstance().player!!.z, + true + )) + } + + fallingTicks = 0 + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/coredoes/maple/module/Module.kt b/src/main/kotlin/dev/coredoes/maple/module/Module.kt index cb087e4..2549e98 100644 --- a/src/main/kotlin/dev/coredoes/maple/module/Module.kt +++ b/src/main/kotlin/dev/coredoes/maple/module/Module.kt @@ -11,4 +11,6 @@ interface Module { fun isEnabled(): Boolean { return false } fun setEnabled(enabled: Boolean) {} + fun stringTitle(): String + fun drawConfig() } \ No newline at end of file diff --git a/src/main/kotlin/dev/coredoes/maple/module/NoFall.kt b/src/main/kotlin/dev/coredoes/maple/module/NoFall.kt new file mode 100644 index 0000000..64c25fb --- /dev/null +++ b/src/main/kotlin/dev/coredoes/maple/module/NoFall.kt @@ -0,0 +1,21 @@ +package dev.coredoes.maple.module + +import imgui.ImGui +import imgui.type.ImBoolean + +object NoFall : Module { + private var enabled = ImBoolean(true) + + override fun isEnabled(): Boolean { return enabled.get() } + override fun setEnabled(enabled: Boolean) { + this.enabled.set(enabled) + } + + override fun stringTitle(): String { + return "NoFall" + } + + override fun drawConfig() { + ImGui.checkbox("Enabled?", enabled) + } +} \ No newline at end of file diff --git a/src/main/resources/maple.mixins.json b/src/main/resources/maple.mixins.json index 26ba4ce..64f9ac2 100644 --- a/src/main/resources/maple.mixins.json +++ b/src/main/resources/maple.mixins.json @@ -4,6 +4,7 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "ClientConnectionMixin", + "PlayerMoveC2SPacketAccessor", "PlayerMoveC2SPacketMixin" ], "injectors": { @@ -11,6 +12,7 @@ }, "client": [ "ClientBrandRetrieverMixin", + "ClientPlayerEntityAccessor", "InputUtilMixin", "KeyboardMixin", "RenderSystemMixin"