This commit is contained in:
core 2023-07-22 14:30:35 -04:00
parent 166d04c3ba
commit 4416018d05
Signed by: core
GPG Key ID: FDBF740DADDCEECF
12 changed files with 210 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 = "<init>", 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;
}
}
}

View File

@ -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()
}
}
}
}

View File

@ -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

View File

@ -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 {

View File

@ -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<String, Module> = 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<MutableMap.MutableEntry<String, Module>> {
return modules.iterator()
}
}

View File

@ -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)
}
}

View File

@ -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
}
}
}
}

View File

@ -11,4 +11,6 @@ interface Module {
fun isEnabled(): Boolean { return false }
fun setEnabled(enabled: Boolean) {}
fun stringTitle(): String
fun drawConfig()
}

View File

@ -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)
}
}

View File

@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"ClientConnectionMixin",
"PlayerMoveC2SPacketAccessor",
"PlayerMoveC2SPacketMixin"
],
"injectors": {
@ -11,6 +12,7 @@
},
"client": [
"ClientBrandRetrieverMixin",
"ClientPlayerEntityAccessor",
"InputUtilMixin",
"KeyboardMixin",
"RenderSystemMixin"