diff options
Diffstat (limited to 'src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Speed.java')
| -rw-r--r-- | src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Speed.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Speed.java b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Speed.java new file mode 100644 index 0000000..fe2b95f --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Speed.java @@ -0,0 +1,58 @@ +package com.arslaancodes.arslaansmagichax.modules.impl; + +import com.arslaancodes.arslaansmagichax.modules.Category; +import com.arslaancodes.arslaansmagichax.modules.Module; +import com.arslaancodes.arslaansmagichax.modules.settings.BooleanSetting; +import com.arslaancodes.arslaansmagichax.modules.settings.NumberSetting; +import net.minecraft.network.chat.Component; + +public class Speed extends Module { + private final NumberSetting speed = new NumberSetting("Speed", 0.1, 2.0, 0.4, 0.05); + private final BooleanSetting enableWhileSneaking = new BooleanSetting("Enable while Sneaking", true); + private final BooleanSetting enableInWater = new BooleanSetting("Enable in Water", true); + private final BooleanSetting enableInLava = new BooleanSetting("Enable in Lava", true); + + public Speed() { + super("Speed", "Makes you faster.", -1, Category.MOVEMENT); + addSetting(speed); + addSetting(enableWhileSneaking); + addSetting(enableInWater); + addSetting(enableInLava); + } + + @Override + protected void onEnable() { + if (mc.player == null) return; + mc.player.displayClientMessage(Component.literal("[Speed] It is recommended to use this hack in combination with NoFall."), false); + } + + @Override + public void tick() { + if (!isEnabled() || mc.player == null) return; + if (!enableWhileSneaking.isEnabled() && mc.player.isShiftKeyDown()) return; + if (!enableInLava.isEnabled() && mc.player.isInLava()) return; + if (!enableInWater.isEnabled() && mc.player.isInWater()) return; + + float forward = mc.player.zza; + float strafe = mc.player.xxa; + float yaw = mc.player.getYRot(); + + if (forward == 0 && strafe == 0) return; + + if (forward != 0) { + if (strafe > 0) yaw += (forward > 0 ? -45 : 45); + else if (strafe < 0) yaw += (forward > 0 ? 45 : -45); + strafe = 0; + forward = forward > 0 ? 1 : -1; + } + + double rad = Math.toRadians(yaw); + double sin = Math.sin(rad); + double cos = Math.cos(rad); + + double x = (forward * -sin + strafe * cos) * speed.getValue(); + double z = (forward * cos - strafe * -sin) * speed.getValue(); + + mc.player.setDeltaMovement(x, mc.player.getDeltaMovement().y, z); + } +} |
