| 1 | /*
|
| 2 | * This file is part of the Combatant Client distribution.
|
| 3 | * Combatant modifications copyright (c) 2026 pivosos2007.
|
| 4 | *
|
| 5 | * Portions of this file are based on LiquidBounce
|
| 6 | * (https://github.com/CCBlueX/LiquidBounce).
|
| 7 | * Copyright (c) 2015-2026 CCBlueX.
|
| 8 | *
|
| 9 | * LiquidBounce portions are licensed under GPLv3-or-later.
|
| 10 | * Combatant modifications are licensed under GPLv3.
|
| 11 | * See THIRD_PARTY_NOTICES.md for details.
|
| 12 | */
|
| 13 |
|
| 14 | package combatant.client.features.module.modules.movement;
|
| 15 |
|
| 16 | import combatant.client.events.impl.*;
|
| 17 | import combatant.client.util.screen.ClientScreen;
|
| 18 | import lombok.Getter;
|
| 19 | import lombok.RequiredArgsConstructor;
|
| 20 | import net.minecraft.client.Minecraft;
|
| 21 | import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
| 22 | import net.minecraft.client.player.LocalPlayer;
|
| 23 | import net.minecraft.core.BlockPos;
|
| 24 | import net.minecraft.core.Direction;
|
| 25 | import net.minecraft.core.Holder;
|
| 26 | import net.minecraft.core.Registry;
|
| 27 | import net.minecraft.core.registries.Registries;
|
| 28 | import net.minecraft.network.Connection;
|
| 29 | import net.minecraft.network.PacketListener;
|
| 30 | import net.minecraft.network.protocol.Packet;
|
| 31 | import net.minecraft.network.protocol.common.ClientboundPingPacket;
|
| 32 | import net.minecraft.network.protocol.common.ServerboundPongPacket;
|
| 33 | import net.minecraft.network.protocol.game.*;
|
| 34 | import net.minecraft.resources.ResourceKey;
|
| 35 | import net.minecraft.util.Mth;
|
| 36 | import net.minecraft.world.InteractionHand;
|
| 37 | import net.minecraft.world.InteractionResult;
|
| 38 | import net.minecraft.world.effect.MobEffects;
|
| 39 | import net.minecraft.world.entity.EquipmentSlot;
|
| 40 | import net.minecraft.world.entity.player.Input;
|
| 41 | import net.minecraft.world.item.ItemStack;
|
| 42 | import net.minecraft.world.item.Items;
|
| 43 | import net.minecraft.world.item.enchantment.Enchantment;
|
| 44 | import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
| 45 | import net.minecraft.world.item.enchantment.Enchantments;
|
| 46 | import net.minecraft.world.level.ClipContext;
|
| 47 | import net.minecraft.world.level.block.*;
|
| 48 | import net.minecraft.world.phys.BlockHitResult;
|
| 49 | import net.minecraft.world.phys.HitResult;
|
| 50 | import net.minecraft.world.phys.Vec3;
|
| 51 | import combatant.client.config.common.CommonSettingSchemas;
|
| 52 | import combatant.client.config.values.BooleanMapValue;
|
| 53 | import combatant.client.config.values.BooleanValue;
|
| 54 | import combatant.client.config.values.EnumValue;
|
| 55 | import combatant.client.config.values.NumberValue;
|
| 56 | import combatant.client.events.EventHandler;
|
| 57 | import combatant.client.events.Events;
|
| 58 | import combatant.client.events.impl.*;
|
| 59 | import combatant.client.features.module.Module;
|
| 60 | import combatant.client.features.module.ModuleCategory;
|
| 61 | import combatant.client.features.module.ModuleInfo;
|
| 62 | import combatant.client.mixins.accessors.ClientboundExplodePacketAccessor;
|
| 63 | import combatant.client.mixins.accessors.ClientboundSetEntityMotionPacketAccessor;
|
| 64 | import combatant.client.util.aiming.RotationManager;
|
| 65 | import combatant.client.util.aiming.data.Rotation;
|
| 66 | import combatant.client.util.network.BlinkManager;
|
| 67 | import combatant.client.util.network.TransferOrigin;
|
| 68 | import combatant.client.util.player.MovementUtil;
|
| 69 |
|
| 70 | import java.util.*;
|
| 71 | import java.util.concurrent.ThreadLocalRandom;
|
| 72 |
|
| 73 | /**
|
| 74 | * Velocity modes ported from LiquidBounce's ModuleVelocity.
|
| 75 | */
|
| 76 | //todo Description
|
| 77 | @ModuleInfo(
|
| 78 | id = "velocity",
|
| 79 | displayName = "Velocity",
|
| 80 | category = ModuleCategory.MOVEMENT
|
| 81 | )
|
| 82 | public final class Velocity extends Module {
|
| 83 |
|
| 84 | private static final double VULCAN_297_SAFE_HORIZONTAL_RATIO = 0.25;
|
| 85 | private static final double VULCAN_297_TINY_HORIZONTAL = 0.01;
|
| 86 | private static final double VULCAN_297_JUMP_LIKE_VERTICAL = 0.41999998688697815;
|
| 87 | private static final double VULCAN_297_PROTECTED_VERTICAL = 0.6;
|
| 88 | private static final int VULCAN_297_WIND_BURST_PENDING_TICKS = 8;
|
| 89 | private static final int VULCAN_297_WIND_BURST_PROTECT_TICKS = 12;
|
| 90 | private static final String VULCAN_EXEMPT_LIQUID = "liquid";
|
| 91 | private static final String VULCAN_EXEMPT_FROZEN = "frozen";
|
| 92 | private static final String VULCAN_EXEMPT_FALL_DAMAGE = "fall_damage";
|
| 93 | private static final String VULCAN_EXEMPT_WEB = "web";
|
| 94 | private static final String VULCAN_EXEMPT_VOID = "void";
|
| 95 | private static final String VULCAN_EXEMPT_SLOW_FALLING = "slow_falling";
|
| 96 | private static final String VULCAN_EXEMPT_TRAPDOOR = "trapdoor";
|
| 97 | private static final String VULCAN_EXEMPT_SOUL_SAND = "soul_sand";
|
| 98 | private static final String VULCAN_EXEMPT_SLIME = "slime";
|
| 99 | private static final String VULCAN_EXEMPT_FLIGHT = "flight";
|
| 100 | private static final String VULCAN_EXEMPT_VEHICLE = "vehicle";
|
| 101 | private static final String VULCAN_EXEMPT_ELYTRA = "elytra";
|
| 102 | private static final String VULCAN_EXEMPT_FENCE = "fence";
|
| 103 | private static final String VULCAN_EXEMPT_WALL = "wall";
|
| 104 | private static final String VULCAN_EXEMPT_SWEET_BERRIES = "sweet_berries";
|
| 105 | private static final String VULCAN_EXEMPT_NETHERITE_ARMOR = "netherite_armor";
|
| 106 | private final Minecraft mc = Minecraft.getInstance();
|
| 107 | private final EnumValue<Mode> mode =
|
| 108 | enumCommon("velocityMode", "velocity_mode", CommonSettingSchemas.ANTICHEAT_MODE, Mode.MODIFY, Mode.values());
|
| 109 | private final NumberValue<Integer> delay = visibleWhen(num("velocityDelay", "delay", 0, 0, 40), this::supportsIncomingVelocity);
|
| 110 | private final NumberValue<Integer> pauseOnFlag = num("velocityPauseOnFlag", "pause_on_flag", 0, 0, 20);
|
| 111 | private final NumberValue<Float> modifyHorizontal = visibleWhen(num("velocityModifyHorizontal", "modify_horizontal", 0.0f, -1.0f, 1.0f), () -> mode.get() == Mode.MODIFY);
|
| 112 | private final NumberValue<Float> modifyVertical = visibleWhen(num("velocityModifyVertical", "modify_vertical", 0.0f, -1.0f, 1.0f), () -> mode.get() == Mode.MODIFY);
|
| 113 | private final NumberValue<Float> modifyMotionHorizontal = visibleWhen(num("velocityModifyMotionHorizontal", "modify_motion_horizontal", 0.0f, 0.0f, 1.0f), () -> mode.get() == Mode.MODIFY);
|
| 114 | private final NumberValue<Float> modifyMotionVertical = visibleWhen(num("velocityModifyMotionVertical", "modify_motion_vertical", 0.0f, 0.0f, 1.0f), () -> mode.get() == Mode.MODIFY);
|
| 115 | private final NumberValue<Integer> modifyChance = visibleWhen(num("velocityModifyChance", "modify_chance", 100, 0, 100), () -> mode.get() == Mode.MODIFY);
|
| 116 | private final EnumValue<Filter> modifyFilter = visibleWhen(enumSetting("velocityModifyFilter", "modify_filter", Filter.ALWAYS, Filter.values()), () -> mode.get() == Mode.MODIFY);
|
| 117 | private final BooleanValue modifyOnlyMove = visibleWhen(bool("velocityModifyOnlyMove", "modify_only_move", false), () -> mode.get() == Mode.MODIFY);
|
| 118 | private final NumberValue<Integer> modifyTransactionBuffer = visibleWhen(num("velocityModifyTransactionBuffer", "modify_transaction_buffer", 0, 0, 3), () -> mode.get() == Mode.MODIFY);
|
| 119 | private final NumberValue<Integer> reversalDelay = visibleWhen(num("velocityReversalDelay", "reversal_delay", 2, 1, 5), () -> mode.get() == Mode.REVERSAL);
|
| 120 | private final NumberValue<Float> reversalXModifier = visibleWhen(num("velocityReversalXModifier", "reversal_x_modifier", 0.5f, 0.0f, 1.0f), () -> mode.get() == Mode.REVERSAL);
|
| 121 | private final NumberValue<Float> reversalZModifier = visibleWhen(num("velocityReversalZModifier", "reversal_z_modifier", 0.5f, 0.0f, 1.0f), () -> mode.get() == Mode.REVERSAL);
|
| 122 | private final BooleanValue reversalOnlyMoving = visibleWhen(bool("velocityReversalOnlyMoving", "reversal_only_moving", false), () -> mode.get() == Mode.REVERSAL);
|
| 123 | private final NumberValue<Integer> strafeDelay = visibleWhen(num("velocityStrafeDelay", "strafe_delay", 2, 0, 10), () -> mode.get() == Mode.STRAFE);
|
| 124 | private final NumberValue<Float> strafeStrength = visibleWhen(num("velocityStrafeStrength", "strafe_strength", 1.0f, 0.1f, 2.0f), () -> mode.get() == Mode.STRAFE);
|
| 125 | private final BooleanValue strafeUntilGround = visibleWhen(bool("velocityStrafeUntilGround", "strafe_until_ground", false), () -> mode.get() == Mode.STRAFE);
|
| 126 | private final NumberValue<Float> jumpResetChance = visibleWhen(num("velocityJumpResetChance", "jump_reset_chance", 100.0f, 0.0f, 100.0f), () -> mode.get() == Mode.JUMP_RESET);
|
| 127 | private final BooleanValue jumpResetByHits = visibleWhen(bool("velocityJumpResetByHits", "jump_reset_by_hits", false), () -> mode.get() == Mode.JUMP_RESET);
|
| 128 | private final NumberValue<Integer> jumpResetHits = visibleWhen(num("velocityJumpResetHits", "jump_reset_hits", 2, 0, 10), () -> mode.get() == Mode.JUMP_RESET);
|
| 129 | private final BooleanValue jumpResetByDelay = visibleWhen(bool("velocityJumpResetByDelay", "jump_reset_by_delay", true), () -> mode.get() == Mode.JUMP_RESET);
|
| 130 | private final NumberValue<Integer> jumpResetTicks = visibleWhen(num("velocityJumpResetTicks", "jump_reset_ticks", 2, 0, 20), () -> mode.get() == Mode.JUMP_RESET);
|
| 131 | private final NumberValue<Integer> lagTime = visibleWhen(num("velocityLagTime", "lag_time", 5, 1, 20), () -> mode.get() == Mode.LAG);
|
| 132 | private final BooleanValue lagJumpReset = visibleWhen(bool("velocityLagJumpReset", "lag_jump_reset", false), () -> mode.get() == Mode.LAG);
|
| 133 | private final NumberValue<Float> dexlandHReduce = visibleWhen(num("velocityDexlandHReduce", "dexland_h_reduce", 0.3f, 0.0f, 1.0f), () -> mode.get() == Mode.DEXLAND);
|
| 134 | private final NumberValue<Integer> dexlandAttacksToWork = visibleWhen(num("velocityDexlandAttacksToWork", "dexland_attacks_to_work", 4, 1, 10), () -> mode.get() == Mode.DEXLAND);
|
| 135 | private final BooleanValue grim2344AlternativeBypass = visibleWhen(bool("velocityGrim2344AlternativeBypass", "grim2344_alternative_bypass", true), () -> mode.get() == Mode.GRIM_2344);
|
| 136 | private final NumberValue<Float> aacReduce = visibleWhen(num("velocityAACReduce", "aac_reduce", 0.62f, 0.0f, 1.0f), () -> mode.get() == Mode.AAC_442);
|
| 137 | private final BooleanValue intaveReduceOnAttack = visibleWhen(bool("velocityIntaveReduceOnAttack", "intave_reduce_on_attack", true), () -> mode.get() == Mode.INTAVE);
|
| 138 | private final NumberValue<Float> intaveReduceFactor = visibleWhen(num("velocityIntaveReduceFactor", "intave_reduce_factor", 0.6f, 0.6f, 1.0f), () -> mode.get() == Mode.INTAVE);
|
| 139 | private final NumberValue<Integer> intaveHurtTimeMin = visibleWhen(num("velocityIntaveHurtTimeMin", "intave_hurt_time_min", 5, 1, 10), () -> mode.get() == Mode.INTAVE);
|
| 140 | private final NumberValue<Integer> intaveHurtTimeMax = visibleWhen(num("velocityIntaveHurtTimeMax", "intave_hurt_time_max", 7, 1, 10), () -> mode.get() == Mode.INTAVE);
|
| 141 | private final NumberValue<Integer> intaveLastAttackTime = visibleWhen(num("velocityIntaveLastAttackTime", "intave_last_attack_time", 2000, 1, 10000), () -> mode.get() == Mode.INTAVE);
|
| 142 | private final BooleanValue intaveJumpReset = visibleWhen(bool("velocityIntaveJumpReset", "intave_jump_reset", true), () -> mode.get() == Mode.INTAVE);
|
| 143 | private final NumberValue<Float> intaveJumpChance = visibleWhen(num("velocityIntaveJumpChance", "intave_jump_chance", 50.0f, 0.0f, 100.0f), () -> mode.get() == Mode.INTAVE);
|
| 144 | private final BooleanValue intaveRandomize = visibleWhen(bool("velocityIntaveRandomize", "intave_randomize", false), () -> mode.get() == Mode.INTAVE);
|
| 145 | private final NumberValue<Integer> intaveRandomDelayTicks = visibleWhen(num("velocityIntaveRandomDelayTicks", "intave_random_delay_ticks", 5, 0, 10), () -> mode.get() == Mode.INTAVE);
|
| 146 | private final NumberValue<Float> vulcan297ExemptRatio = visibleWhen(num("velocityVulcan297ExemptRatio", "vulcan297_exempt_ratio", 0.0f, 0.0f, 1.0f), this::isVulcan297Mode);
|
| 147 | private final BooleanMapValue vulcan297Exempts = visibleWhen(group("velocityVulcan297Exempts", "vulcan297_exempts", vulcan297ExemptDefaults()), this::isVulcan297Mode);
|
| 148 | private final Queue<DelayedPacket> delayedPackets = new ArrayDeque<>();
|
| 149 | private int pause;
|
| 150 | private int transactionBuffer;
|
| 151 | private boolean reversalHandlingVelocity;
|
| 152 | private int reversalVelocityTicks;
|
| 153 | private int strafeTicks = -1;
|
| 154 | private boolean strafeApplyUntilGround;
|
| 155 | private int jumpLimitUntilJump;
|
| 156 | private boolean jumpResetFallDamage;
|
| 157 | private boolean lagShouldLag;
|
| 158 | private int lagTicks;
|
| 159 | private int lagShouldJumpTicks;
|
| 160 | private boolean hypixelAbsorbedVelocity;
|
| 161 | private long dexlandLastAttackTime;
|
| 162 | private int dexlandCount;
|
| 163 | private boolean grim2371CancelNextVelocity;
|
| 164 | private boolean grim2371Delay;
|
| 165 | private boolean grim2371NeedClick;
|
| 166 | private boolean grim2371WaitForPing;
|
| 167 | private boolean grim2371WaitForUpdate;
|
| 168 | private boolean grim2371ShouldSkip;
|
| 169 | private BlockHitResult grim2371HitResult;
|
| 170 | private int grim2371FreezeTicks;
|
| 171 | private boolean grim2344CanCancel;
|
| 172 | private long intaveLastAttack;
|
| 173 | private boolean intaveFallDamage;
|
| 174 | private int intaveCurrentDelay;
|
| 175 | private int intaveDelayCounter;
|
| 176 | private int vulcan297WindBurstPendingTicks;
|
| 177 | private int vulcan297WindBurstProtectTicks;
|
| 178 |
|
| 179 | private static Map<String, Boolean> vulcan297ExemptDefaults() {
|
| 180 | Map<String, Boolean> defaults = new LinkedHashMap<>();
|
| 181 | defaults.put(VULCAN_EXEMPT_LIQUID, true);
|
| 182 | defaults.put(VULCAN_EXEMPT_FROZEN, true);
|
| 183 | defaults.put(VULCAN_EXEMPT_FALL_DAMAGE, true);
|
| 184 | defaults.put(VULCAN_EXEMPT_WEB, true);
|
| 185 | defaults.put(VULCAN_EXEMPT_VOID, true);
|
| 186 | defaults.put(VULCAN_EXEMPT_SLOW_FALLING, true);
|
| 187 | defaults.put(VULCAN_EXEMPT_TRAPDOOR, true);
|
| 188 | defaults.put(VULCAN_EXEMPT_SOUL_SAND, true);
|
| 189 | defaults.put(VULCAN_EXEMPT_SLIME, true);
|
| 190 | defaults.put(VULCAN_EXEMPT_FLIGHT, true);
|
| 191 | defaults.put(VULCAN_EXEMPT_VEHICLE, true);
|
| 192 | defaults.put(VULCAN_EXEMPT_ELYTRA, true);
|
| 193 | defaults.put(VULCAN_EXEMPT_FENCE, true);
|
| 194 | defaults.put(VULCAN_EXEMPT_WALL, true);
|
| 195 | defaults.put(VULCAN_EXEMPT_SWEET_BERRIES, true);
|
| 196 | defaults.put(VULCAN_EXEMPT_NETHERITE_ARMOR, true);
|
| 197 | return defaults;
|
| 198 | }
|
| 199 |
|
| 200 | @Override
|
| 201 | public void onEnable() {
|
| 202 | resetState();
|
| 203 | }
|
| 204 |
|
| 205 | @Override
|
| 206 | public void onDisable() {
|
| 207 | BlinkManager.INSTANCE.flush(TransferOrigin.INCOMING);
|
| 208 | resetState();
|
| 209 | }
|
| 210 |
|
| 211 | @EventHandler(priority = 2)
|
| 212 | private void onPacket(PacketEvent event) {
|
| 213 | if (!isEnabled() || player() == null) return;
|
| 214 |
|
| 215 | Packet<?> packet = event.getPacket();
|
| 216 | if (event.isOriginal()) {
|
| 217 | if (packet instanceof ClientboundPlayerPositionPacket) {
|
| 218 | pause = pauseOnFlag.get();
|
| 219 | return;
|
| 220 | }
|
| 221 | if (pause > 0) return;
|
| 222 | if (event.getOrigin() == TransferOrigin.INCOMING
|
| 223 | && supportsIncomingVelocity()
|
| 224 | && isLocalPlayerVelocity(packet)
|
| 225 | && delay.get() > 0) {
|
| 226 | event.cancel();
|
| 227 | delayedPackets.add(new DelayedPacket(packet, delay.get()));
|
| 228 | return;
|
| 229 | }
|
| 230 | }
|
| 231 |
|
| 232 | switch (mode.get()) {
|
| 233 | case MODIFY -> handleModify(event, packet);
|
| 234 | case REVERSAL -> handleReversal(event, packet);
|
| 235 | case STRAFE -> handleStrafePacket(event, packet);
|
| 236 | case JUMP_RESET -> handleJumpResetPacket(packet);
|
| 237 | case LAG -> handleLagPacket(packet);
|
| 238 | case HYPIXEL -> handleHypixel(event, packet);
|
| 239 | case BLOCKSMC -> handleBlocksMc(event, packet);
|
| 240 | case GRIM_2371 -> handleGrim2371Packet(event, packet);
|
| 241 | case GRIM_2344 -> handleGrim2344(event, packet);
|
| 242 | case INTAVE -> handleIntavePacket(packet);
|
| 243 | case VULCAN_297 -> handleVulcan297(event, packet);
|
| 244 | default -> {
|
| 245 | }
|
| 246 | }
|
| 247 |
|
| 248 | }
|
| 249 |
|
| 250 | @EventHandler
|
| 251 | private void onBlinkPacket(BlinkPacketEvent event) {
|
| 252 | if (!isEnabled() || player() == null) return;
|
| 253 |
|
| 254 | if (mode.get() == Mode.LAG
|
| 255 | && lagShouldLag
|
| 256 | && event.getOrigin() == TransferOrigin.INCOMING
|
| 257 | && !(event.getPacket() instanceof ClientboundPingPacket)) {
|
| 258 | event.setAction(BlinkManager.Action.QUEUE);
|
| 259 | return;
|
| 260 | }
|
| 261 |
|
| 262 | if (mode.get() == Mode.GRIM_2371
|
| 263 | && !grim2371WaitForUpdate
|
| 264 | && grim2371Delay
|
| 265 | && event.getOrigin() == TransferOrigin.INCOMING) {
|
| 266 | event.setAction(BlinkManager.Action.QUEUE);
|
| 267 | }
|
| 268 | }
|
| 269 |
|
| 270 | @EventHandler
|
| 271 | private void onTick(GameTickEvent event) {
|
| 272 | if (!isEnabled()) return;
|
| 273 |
|
| 274 | if (pause > 0) pause--;
|
| 275 | processDelayedPackets();
|
| 276 |
|
| 277 | LocalPlayer player = player();
|
| 278 | if (player == null) return;
|
| 279 |
|
| 280 | switch (mode.get()) {
|
| 281 | case REVERSAL -> tickReversal(player);
|
| 282 | case STRAFE -> tickStrafe(player);
|
| 283 | case LAG -> tickLag(player);
|
| 284 | case HYPIXEL -> {
|
| 285 | if (player.onGround()) hypixelAbsorbedVelocity = false;
|
| 286 | }
|
| 287 | case HYLEX -> tickHylex(player);
|
| 288 | case GRIM_2371 -> tickGrim2371(player);
|
| 289 | case AAC_442 -> {
|
| 290 | if (player.hurtTime > 0 && !player.onGround()) {
|
| 291 | multiplyHorizontal(player, aacReduce.get());
|
| 292 | }
|
| 293 | }
|
| 294 | default -> {
|
| 295 | }
|
| 296 | }
|
| 297 |
|
| 298 | if (vulcan297WindBurstProtectTicks > 0) {
|
| 299 | vulcan297WindBurstProtectTicks--;
|
| 300 | }
|
| 301 | if (vulcan297WindBurstPendingTicks > 0) {
|
| 302 | vulcan297WindBurstPendingTicks--;
|
| 303 | }
|
| 304 | }
|
| 305 |
|
| 306 | @EventHandler
|
| 307 | private void onMovementInput(MovementInputEvent event) {
|
| 308 | if (!isEnabled() || player() == null) return;
|
| 309 |
|
| 310 | if (mode.get() == Mode.JUMP_RESET) {
|
| 311 | handleJumpResetInput(event, player());
|
| 312 | } else if (mode.get() == Mode.LAG) {
|
| 313 | if (lagJumpReset.get() && lagShouldJumpTicks > 0 && player().onGround() && player().isSprinting()) {
|
| 314 | event.setJump(true);
|
| 315 | lagShouldJumpTicks = 0;
|
| 316 | }
|
| 317 | } else if (mode.get() == Mode.INTAVE) {
|
| 318 | handleIntaveJumpReset(event, player());
|
| 319 | }
|
| 320 | }
|
| 321 |
|
| 322 | @EventHandler
|
| 323 | private void onMove(PlayerMoveEvent event) {
|
| 324 | if (!isEnabled() || mode.get() != Mode.STRAFE || !strafeApplyUntilGround || player() == null) return;
|
| 325 |
|
| 326 | if (player().onGround()) {
|
| 327 | strafeApplyUntilGround = false;
|
| 328 | return;
|
| 329 | }
|
| 330 |
|
| 331 | event.setMovement(withStrafe(event.getMovement(), strafeStrength.get()));
|
| 332 | }
|
| 333 |
|
| 334 | @EventHandler
|
| 335 | private void onAttack(AttackEntityEvent event) {
|
| 336 | if (!isEnabled() || player() == null) return;
|
| 337 |
|
| 338 | if (mode.get() == Mode.DEXLAND) {
|
| 339 | long now = System.currentTimeMillis();
|
| 340 | if (player().hurtTime > 0
|
| 341 | && ++dexlandCount % dexlandAttacksToWork.get() == 0
|
| 342 | && now - dexlandLastAttackTime <= 8000L) {
|
| 343 | multiplyHorizontal(player(), dexlandHReduce.get());
|
| 344 | }
|
| 345 | dexlandLastAttackTime = now;
|
| 346 | } else if (mode.get() == Mode.HYLEX) {
|
| 347 | handleHylexAttack(player());
|
| 348 | } else if (mode.get() == Mode.INTAVE && intaveReduceOnAttack.get()) {
|
| 349 | long now = System.currentTimeMillis();
|
| 350 | int min = Math.min(intaveHurtTimeMin.get(), intaveHurtTimeMax.get());
|
| 351 | int max = Math.max(intaveHurtTimeMin.get(), intaveHurtTimeMax.get());
|
| 352 | if (player().hurtTime >= min && player().hurtTime <= max && now - intaveLastAttack <= intaveLastAttackTime.get()) {
|
| 353 | multiplyHorizontal(player(), intaveReduceFactor.get());
|
| 354 | }
|
| 355 | intaveLastAttack = now;
|
| 356 | } else if (mode.get() == Mode.VULCAN_297 && isVulcan297WindBurstMaceAttack(event, player())) {
|
| 357 | armVulcan297MaceVelocityWindow();
|
| 358 | }
|
| 359 | }
|
| 360 |
|
| 361 | private void handleModify(PacketEvent event, Packet<?> packet) {
|
| 362 | if (packet instanceof ClientboundSetEntityMotionPacket velocity && velocity.id() == player().getId()) {
|
| 363 | if (!shouldModifyVelocity()) return;
|
| 364 |
|
| 365 | if (modifyHorizontal.get() == 0.0f && modifyVertical.get() == 0.0f) {
|
| 366 | event.cancel();
|
| 367 | return;
|
| 368 | }
|
| 369 |
|
| 370 | Vec3 packetVelocity = velocity.movement();
|
| 371 | Vec3 currentVelocity = player().getDeltaMovement();
|
| 372 | double x = modifyHorizontal.get() != 0.0f
|
| 373 | ? packetVelocity.x * modifyHorizontal.get()
|
| 374 | : currentVelocity.x * modifyMotionHorizontal.get();
|
| 375 | double y = modifyVertical.get() != 0.0f
|
| 376 | ? packetVelocity.y * modifyVertical.get()
|
| 377 | : currentVelocity.y * modifyMotionVertical.get();
|
| 378 | double z = modifyHorizontal.get() != 0.0f
|
| 379 | ? packetVelocity.z * modifyHorizontal.get()
|
| 380 | : currentVelocity.z * modifyMotionHorizontal.get();
|
| 381 | ((ClientboundSetEntityMotionPacketAccessor) (Object) velocity).combatant$setVelocity(new Vec3(x, y, z));
|
| 382 | transactionBuffer += modifyTransactionBuffer.get();
|
| 383 | return;
|
| 384 | }
|
| 385 |
|
| 386 | if (packet instanceof ClientboundExplodePacket explosion && explosion.playerKnockback().isPresent()) {
|
| 387 | if (!shouldModifyVelocity()) return;
|
| 388 |
|
| 389 | Vec3 knockback = explosion.playerKnockback().get();
|
| 390 | ((ClientboundExplodePacketAccessor) (Object) explosion).combatant$setPlayerKnockback(Optional.of(new Vec3(
|
| 391 | knockback.x * modifyHorizontal.get(),
|
| 392 | knockback.y * modifyVertical.get(),
|
| 393 | knockback.z * modifyHorizontal.get()
|
| 394 | )));
|
| 395 | transactionBuffer += modifyTransactionBuffer.get();
|
| 396 | return;
|
| 397 | }
|
| 398 |
|
| 399 | if (packet instanceof ServerboundPongPacket && transactionBuffer > 0) {
|
| 400 | event.cancel();
|
| 401 | transactionBuffer--;
|
| 402 | }
|
| 403 | }
|
| 404 |
|
| 405 | private boolean shouldModifyVelocity() {
|
| 406 | if (modifyChance.get() != 100 && ThreadLocalRandom.current().nextInt(100) > modifyChance.get()) return false;
|
| 407 | if (modifyOnlyMove.get() && !isMoving()) return false;
|
| 408 |
|
| 409 | return switch (modifyFilter.get()) {
|
| 410 | case ALWAYS -> true;
|
| 411 | case ON_GROUND -> player().onGround();
|
| 412 | case IN_AIR -> !player().onGround();
|
| 413 | };
|
| 414 | }
|
| 415 |
|
| 416 | private void handleReversal(PacketEvent event, Packet<?> packet) {
|
| 417 | if (!isLocalPlayerVelocity(packet)) return;
|
| 418 | if (reversalOnlyMoving.get() && !isMoving()) return;
|
| 419 |
|
| 420 | reversalVelocityTicks = 0;
|
| 421 | reversalHandlingVelocity = true;
|
| 422 | }
|
| 423 |
|
| 424 | private void tickReversal(LocalPlayer player) {
|
| 425 | if (!reversalHandlingVelocity) return;
|
| 426 |
|
| 427 | Vec3 velocity = player.getDeltaMovement();
|
| 428 | if (velocity.lengthSqr() == 0.0) {
|
| 429 | reversalHandlingVelocity = false;
|
| 430 | reversalVelocityTicks = 0;
|
| 431 | return;
|
| 432 | }
|
| 433 |
|
| 434 | if (reversalVelocityTicks++ >= reversalDelay.get()) {
|
| 435 | player.setDeltaMovement(
|
| 436 | velocity.x * -reversalXModifier.get(),
|
| 437 | velocity.y,
|
| 438 | velocity.z * -reversalZModifier.get()
|
| 439 | );
|
| 440 | reversalHandlingVelocity = false;
|
| 441 | reversalVelocityTicks = 0;
|
| 442 | }
|
| 443 | }
|
| 444 |
|
| 445 | private void handleStrafePacket(PacketEvent event, Packet<?> packet) {
|
| 446 | if (!isLocalPlayerVelocity(packet)) return;
|
| 447 |
|
| 448 | strafeTicks = strafeDelay.get();
|
| 449 | if (strafeTicks <= 0) {
|
| 450 | applyStrafe(player());
|
| 451 | }
|
| 452 | }
|
| 453 |
|
| 454 | private void tickStrafe(LocalPlayer player) {
|
| 455 | if (strafeTicks < 0) return;
|
| 456 |
|
| 457 | if (strafeTicks-- <= 0) {
|
| 458 | applyStrafe(player);
|
| 459 | strafeTicks = -1;
|
| 460 | }
|
| 461 | }
|
| 462 |
|
| 463 | private void applyStrafe(LocalPlayer player) {
|
| 464 | if (player == null) return;
|
| 465 |
|
| 466 | player.setDeltaMovement(withStrafe(player.getDeltaMovement(), strafeStrength.get()));
|
| 467 | if (strafeUntilGround.get()) {
|
| 468 | strafeApplyUntilGround = true;
|
| 469 | }
|
| 470 | }
|
| 471 |
|
| 472 | private Vec3 withStrafe(Vec3 currentVelocity, double strength) {
|
| 473 | return MovementUtil.withStrafe(
|
| 474 | currentVelocity,
|
| 475 | movementInput(),
|
| 476 | movementYaw(),
|
| 477 | horizontalSpeed(currentVelocity) * strength,
|
| 478 | 1.0
|
| 479 | );
|
| 480 | }
|
| 481 |
|
| 482 | private void handleJumpResetPacket(Packet<?> packet) {
|
| 483 | if (packet instanceof ClientboundSetEntityMotionPacket(int id, Vec3 v) && id == player().getId()) {
|
| 484 | jumpResetFallDamage = v.x == 0.0 && v.z == 0.0 && v.y < 0.0;
|
| 485 | }
|
| 486 | }
|
| 487 |
|
| 488 | private void handleJumpResetInput(MovementInputEvent event, LocalPlayer player) {
|
| 489 | if (player.hurtTime != 9
|
| 490 | || !player.onGround()
|
| 491 | || !player.isSprinting()
|
| 492 | || jumpResetFallDamage
|
| 493 | || !jumpResetCooldownOver()
|
| 494 | || !rollChance(jumpResetChance.get())) {
|
| 495 | updateJumpResetLimit(player);
|
| 496 | return;
|
| 497 | }
|
| 498 |
|
| 499 | event.setJump(true);
|
| 500 | jumpLimitUntilJump = 0;
|
| 501 | }
|
| 502 |
|
| 503 | private boolean jumpResetCooldownOver() {
|
| 504 | if (jumpResetByHits.get()) return jumpLimitUntilJump >= jumpResetHits.get();
|
| 505 | if (jumpResetByDelay.get()) return jumpLimitUntilJump >= jumpResetTicks.get();
|
| 506 | return true;
|
| 507 | }
|
| 508 |
|
| 509 | private void updateJumpResetLimit(LocalPlayer player) {
|
| 510 | if (jumpResetByHits.get()) {
|
| 511 | if (player.hurtTime == 9) jumpLimitUntilJump++;
|
| 512 | } else {
|
| 513 | jumpLimitUntilJump++;
|
| 514 | }
|
| 515 | }
|
| 516 |
|
| 517 | private void handleLagPacket(Packet<?> packet) {
|
| 518 | if (packet instanceof ClientboundSetEntityMotionPacket velocity && velocity.id() == player().getId()) {
|
| 519 | lagShouldLag = true;
|
| 520 | lagTicks = lagTime.get();
|
| 521 | }
|
| 522 | }
|
| 523 |
|
| 524 | private void tickLag(LocalPlayer player) {
|
| 525 | if (lagShouldLag && --lagTicks <= 0) {
|
| 526 | lagShouldLag = false;
|
| 527 | lagTicks = 0;
|
| 528 | BlinkManager.INSTANCE.flush(TransferOrigin.INCOMING);
|
| 529 | lagShouldJumpTicks = 2;
|
| 530 | }
|
| 531 | if (lagShouldJumpTicks > 0) {
|
| 532 | lagShouldJumpTicks--;
|
| 533 | }
|
| 534 | }
|
| 535 |
|
| 536 | private void handleHypixel(PacketEvent event, Packet<?> packet) {
|
| 537 | if (!(packet instanceof ClientboundSetEntityMotionPacket velocity) || velocity.id() != player().getId()) return;
|
| 538 |
|
| 539 | if (!player().onGround() && !hypixelAbsorbedVelocity) {
|
| 540 | event.cancel();
|
| 541 | hypixelAbsorbedVelocity = true;
|
| 542 | return;
|
| 543 | }
|
| 544 |
|
| 545 | Vec3 current = player().getDeltaMovement();
|
| 546 | Vec3 packetVelocity = velocity.movement();
|
| 547 | ((ClientboundSetEntityMotionPacketAccessor) (Object) velocity).combatant$setVelocity(new Vec3(current.x, packetVelocity.y, current.z));
|
| 548 | }
|
| 549 |
|
| 550 | private void handleBlocksMc(PacketEvent event, Packet<?> packet) {
|
| 551 | if (!(packet instanceof ClientboundSetEntityMotionPacket velocity) || velocity.id() != player().getId()) return;
|
| 552 |
|
| 553 | event.cancel();
|
| 554 | sendSneaking(true);
|
| 555 | sendSneaking(false);
|
| 556 | }
|
| 557 |
|
| 558 | private void handleHylexAttack(LocalPlayer player) {
|
| 559 | if (!isMoving() || !player.isSprinting()) return;
|
| 560 |
|
| 561 | switch (player.hurtTime) {
|
| 562 | case 9 -> multiplyHorizontal(player, 0.8);
|
| 563 | case 8 -> multiplyHorizontal(player, 0.11);
|
| 564 | case 7 -> multiplyHorizontal(player, 0.4);
|
| 565 | case 4 -> multiplyHorizontal(player, 0.37);
|
| 566 | default -> {
|
| 567 | }
|
| 568 | }
|
| 569 | }
|
| 570 |
|
| 571 | private void tickHylex(LocalPlayer player) {
|
| 572 | if (player.hurtTime > 5 && player.onGround()) {
|
| 573 | player.jumpFromGround();
|
| 574 | }
|
| 575 | }
|
| 576 |
|
| 577 | private void handleGrim2371Packet(PacketEvent event, Packet<?> packet) {
|
| 578 | if (packet instanceof ServerboundInteractPacket || packet instanceof ServerboundUseItemOnPacket) {
|
| 579 | grim2371ShouldSkip = true;
|
| 580 | } else if (packet instanceof ServerboundMovePlayerPacket move && move.hasPosition() && grim2371WaitForUpdate) {
|
| 581 | event.cancel();
|
| 582 | return;
|
| 583 | } else if (packet instanceof ServerboundPongPacket && grim2371WaitForPing) {
|
| 584 | grim2371WaitForUpdate = false;
|
| 585 | grim2371WaitForPing = false;
|
| 586 | }
|
| 587 |
|
| 588 | if (packet instanceof ClientboundBlockUpdatePacket block
|
| 589 | && grim2371WaitForUpdate
|
| 590 | && block.getPos().equals(player().blockPosition())) {
|
| 591 | grim2371WaitForPing = true;
|
| 592 | grim2371NeedClick = false;
|
| 593 | }
|
| 594 |
|
| 595 | if (event.isCancelled() || grim2371WaitForUpdate || grim2371Delay) return;
|
| 596 |
|
| 597 | if (isLocalPlayerDamage(packet)) {
|
| 598 | grim2371CancelNextVelocity = true;
|
| 599 | } else if (grim2371CancelNextVelocity && isLocalPlayerVelocity(packet)) {
|
| 600 | event.cancel();
|
| 601 | grim2371Delay = true;
|
| 602 | grim2371CancelNextVelocity = false;
|
| 603 | grim2371NeedClick = true;
|
| 604 | }
|
| 605 | }
|
| 606 |
|
| 607 | private void tickGrim2371(LocalPlayer player) {
|
| 608 | if (grim2371NeedClick && !grim2371ShouldSkip && !player.isUsingItem()) {
|
| 609 | grim2371HitResult = traceDownToPlayerBlock(player);
|
| 610 | }
|
| 611 |
|
| 612 | if (grim2371HitResult != null) {
|
| 613 | grim2371Delay = false;
|
| 614 | BlinkManager.INSTANCE.flush(TransferOrigin.INCOMING);
|
| 615 |
|
| 616 | if (mc.gameMode != null) {
|
| 617 | InteractionResult result = mc.gameMode.useItemOn(player, InteractionHand.MAIN_HAND, grim2371HitResult);
|
| 618 | if (result.consumesAction()) {
|
| 619 | player.swing(InteractionHand.MAIN_HAND);
|
| 620 | }
|
| 621 | }
|
| 622 |
|
| 623 | sendGrim2371Rotation(player);
|
| 624 | grim2371FreezeTicks = 0;
|
| 625 | grim2371WaitForUpdate = true;
|
| 626 | grim2371HitResult = null;
|
| 627 | grim2371NeedClick = false;
|
| 628 | }
|
| 629 |
|
| 630 | if (grim2371WaitForUpdate && ++grim2371FreezeTicks > 20) {
|
| 631 | grim2371WaitForUpdate = false;
|
| 632 | grim2371WaitForPing = false;
|
| 633 | grim2371NeedClick = false;
|
| 634 | }
|
| 635 |
|
| 636 | grim2371ShouldSkip = false;
|
| 637 | }
|
| 638 |
|
| 639 | private void handleGrim2344(PacketEvent event, Packet<?> packet) {
|
| 640 | if (isLocalPlayerDamage(packet)) {
|
| 641 | grim2344CanCancel = true;
|
| 642 | }
|
| 643 |
|
| 644 | if (isLocalPlayerVelocity(packet) && grim2344CanCancel) {
|
| 645 | event.cancel();
|
| 646 | int repeats = grim2344AlternativeBypass.get() ? 4 : 1;
|
| 647 | for (int i = 0; i < repeats; i++) {
|
| 648 | sendFullMovePacket(player());
|
| 649 | }
|
| 650 | sendStopDestroyBlock(player());
|
| 651 | grim2344CanCancel = false;
|
| 652 | }
|
| 653 | }
|
| 654 |
|
| 655 | private void handleIntavePacket(Packet<?> packet) {
|
| 656 | if (packet instanceof ClientboundSetEntityMotionPacket(int id, Vec3 v) && id == player().getId()) {
|
| 657 | intaveFallDamage = v.x == 0.0 && v.z == 0.0 && v.y < 0.0;
|
| 658 | }
|
| 659 | }
|
| 660 |
|
| 661 | private void handleIntaveJumpReset(MovementInputEvent event, LocalPlayer player) {
|
| 662 | if (!intaveJumpReset.get()) return;
|
| 663 |
|
| 664 | boolean shouldJump = rollChance(intaveJumpChance.get()) && player.hurtTime > 5 && !intaveFallDamage;
|
| 665 | boolean canJump = player.onGround() && !(ClientScreen.current() instanceof InventoryScreen);
|
| 666 |
|
| 667 | if (intaveRandomize.get()) {
|
| 668 | intaveDelayCounter++;
|
| 669 | if (intaveDelayCounter >= intaveCurrentDelay) {
|
| 670 | if (shouldJump && canJump) event.setJump(true);
|
| 671 | intaveDelayCounter = 0;
|
| 672 | intaveCurrentDelay = ThreadLocalRandom.current().nextInt(intaveRandomDelayTicks.get() + 1);
|
| 673 | }
|
| 674 | } else if (shouldJump && canJump) {
|
| 675 | event.setJump(true);
|
| 676 | }
|
| 677 | }
|
| 678 |
|
| 679 | private void handleVulcan297(PacketEvent event, Packet<?> packet) {
|
| 680 | LocalPlayer player = player();
|
| 681 | if (player == null) return;
|
| 682 |
|
| 683 | if (event.getOrigin() == TransferOrigin.OUTGOING
|
| 684 | && packet instanceof ServerboundSwingPacket swing
|
| 685 | && isVulcan297MaceSwing(swing, player)) {
|
| 686 | armVulcan297MaceVelocityWindow();
|
| 687 | return;
|
| 688 | }
|
| 689 |
|
| 690 | if (packet instanceof ClientboundSetEntityMotionPacket velocity && velocity.id() == player.getId()) {
|
| 691 | if (vulcan297WindBurstProtectTicks > 0) {
|
| 692 | return;
|
| 693 | }
|
| 694 |
|
| 695 | Vec3 modified = getVulcan297Velocity(player, velocity.movement());
|
| 696 | if (isZeroVelocity(modified)) {
|
| 697 | event.cancel();
|
| 698 | return;
|
| 699 | }
|
| 700 |
|
| 701 | ((ClientboundSetEntityMotionPacketAccessor) (Object) velocity).combatant$setVelocity(modified);
|
| 702 | return;
|
| 703 | }
|
| 704 |
|
| 705 | if (packet instanceof ClientboundExplodePacket explosion && explosion.playerKnockback().isPresent()) {
|
| 706 | if (vulcan297WindBurstPendingTicks > 0) {
|
| 707 | vulcan297WindBurstPendingTicks = 0;
|
| 708 | vulcan297WindBurstProtectTicks = VULCAN_297_WIND_BURST_PROTECT_TICKS;
|
| 709 | }
|
| 710 | }
|
| 711 | }
|
| 712 |
|
| 713 | private void armVulcan297MaceVelocityWindow() {
|
| 714 | vulcan297WindBurstPendingTicks = Math.max(vulcan297WindBurstPendingTicks, VULCAN_297_WIND_BURST_PENDING_TICKS);
|
| 715 | vulcan297WindBurstProtectTicks = Math.max(vulcan297WindBurstProtectTicks, VULCAN_297_WIND_BURST_PROTECT_TICKS);
|
| 716 | }
|
| 717 |
|
| 718 | private boolean isVulcan297MaceSwing(ServerboundSwingPacket packet, LocalPlayer player) {
|
| 719 | return packet.getHand() == InteractionHand.MAIN_HAND && player.getMainHandItem().is(Items.MACE);
|
| 720 | }
|
| 721 |
|
| 722 | private boolean isVulcan297WindBurstMaceAttack(AttackEntityEvent event, LocalPlayer player) {
|
| 723 | if (event.getPlayer() != player || player.isFallFlying() || player.fallDistance < 1.5f) {
|
| 724 | return false;
|
| 725 | }
|
| 726 |
|
| 727 | ItemStack stack = player.getMainHandItem();
|
| 728 | return stack.is(Items.MACE) && getEnchantmentLevel(Enchantments.WIND_BURST, stack) > 0;
|
| 729 | }
|
| 730 |
|
| 731 | private int getEnchantmentLevel(ResourceKey<Enchantment> key, ItemStack stack) {
|
| 732 | Holder<Enchantment> entry = getEnchantmentEntry(key);
|
| 733 | return entry == null ? 0 : EnchantmentHelper.getItemEnchantmentLevel(entry, stack);
|
| 734 | }
|
| 735 |
|
| 736 | private Holder<Enchantment> getEnchantmentEntry(ResourceKey<Enchantment> key) {
|
| 737 | if (mc.level == null) return null;
|
| 738 | Registry<Enchantment> registry = mc.level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
| 739 | Enchantment enchantment = registry.getValue(key);
|
| 740 | return enchantment != null ? registry.wrapAsHolder(enchantment) : null;
|
| 741 | }
|
| 742 |
|
| 743 | private Vec3 getVulcan297Velocity(LocalPlayer player, Vec3 velocity) {
|
| 744 | double horizontal = horizontalSpeed(velocity);
|
| 745 | boolean typeAExempt = isVulcan297TypeAExempt(player);
|
| 746 | boolean typeBExempt = isVulcan297TypeBExempt(player);
|
| 747 |
|
| 748 | if (!typeAExempt && shouldPreserveVulcan297EntityImpulse(velocity)) {
|
| 749 | return velocity;
|
| 750 | }
|
| 751 |
|
| 752 | double exemptRatio = vulcan297ExemptRatio.get();
|
| 753 | double horizontalFactor = typeBExempt ? exemptRatio : VULCAN_297_SAFE_HORIZONTAL_RATIO;
|
| 754 | double verticalFactor = typeAExempt ? exemptRatio : velocity.y > 0.0 ? 1.0 : 0.0;
|
| 755 |
|
| 756 | if (!typeBExempt && horizontal < VULCAN_297_TINY_HORIZONTAL && velocity.y <= VULCAN_297_JUMP_LIKE_VERTICAL) {
|
| 757 | horizontalFactor = 0.0;
|
| 758 | }
|
| 759 |
|
| 760 | return applyVulcan297Budget(velocity, horizontalFactor, verticalFactor);
|
| 761 | }
|
| 762 |
|
| 763 | private Vec3 applyVulcan297Budget(Vec3 velocity, double horizontalFactor, double verticalFactor) {
|
| 764 | return new Vec3(
|
| 765 | velocity.x * horizontalFactor,
|
| 766 | velocity.y * verticalFactor,
|
| 767 | velocity.z * horizontalFactor
|
| 768 | );
|
| 769 | }
|
| 770 |
|
| 771 | private boolean shouldPreserveVulcan297EntityImpulse(Vec3 velocity) {
|
| 772 | double horizontal = horizontalSpeed(velocity);
|
| 773 |
|
| 774 | if (velocity.y >= VULCAN_297_PROTECTED_VERTICAL) {
|
| 775 | return true;
|
| 776 | }
|
| 777 |
|
| 778 | return velocity.y > VULCAN_297_JUMP_LIKE_VERTICAL && horizontal >= VULCAN_297_SAFE_HORIZONTAL_RATIO;
|
| 779 | }
|
| 780 |
|
| 781 | private boolean isVulcan297TypeAExempt(LocalPlayer player) {
|
| 782 | return isVulcan297SharedExempt(player)
|
| 783 | || getVulcan297BlockExempt(player);
|
| 784 | }
|
| 785 |
|
| 786 | private boolean isVulcan297TypeBExempt(LocalPlayer player) {
|
| 787 | return isVulcan297SharedExempt(player)
|
| 788 | || getVulcan297BlockExempt(player)
|
| 789 | || vulcan297Exempts.get(VULCAN_EXEMPT_NETHERITE_ARMOR) && hasVulcan297NetheriteArmor(player);
|
| 790 | }
|
| 791 |
|
| 792 | private boolean isVulcan297SharedExempt(LocalPlayer player) {
|
| 793 | if (vulcan297Exempts.get(VULCAN_EXEMPT_VEHICLE) && player.isPassenger()) return true;
|
| 794 | if (vulcan297Exempts.get(VULCAN_EXEMPT_ELYTRA) && player.isFallFlying()) return true;
|
| 795 | if (vulcan297Exempts.get(VULCAN_EXEMPT_LIQUID) && (player.isInWater()
|
| 796 | || player.isUnderWater()
|
| 797 | || player.isInLava()
|
| 798 | || player.isSwimming())) {
|
| 799 | return true;
|
| 800 | }
|
| 801 | if (vulcan297Exempts.get(VULCAN_EXEMPT_FROZEN) && player.isFullyFrozen()) return true;
|
| 802 | if (vulcan297Exempts.get(VULCAN_EXEMPT_FLIGHT) && player.getAbilities().flying) return true;
|
| 803 | if (vulcan297Exempts.get(VULCAN_EXEMPT_FALL_DAMAGE) && player.fallDistance > 3.0f) return true;
|
| 804 | if (vulcan297Exempts.get(VULCAN_EXEMPT_VOID) && isBelowWorld(player)) return true;
|
| 805 | return vulcan297Exempts.get(VULCAN_EXEMPT_SLOW_FALLING) && player.hasEffect(MobEffects.SLOW_FALLING);
|
| 806 | }
|
| 807 |
|
| 808 | private boolean isBelowWorld(LocalPlayer player) {
|
| 809 | return mc.level != null && player.getY() < mc.level.getMinY();
|
| 810 | }
|
| 811 |
|
| 812 | private boolean getVulcan297BlockExempt(LocalPlayer player) {
|
| 813 | if (mc.level == null) {
|
| 814 | return false;
|
| 815 | }
|
| 816 |
|
| 817 | BlockPos feet = player.blockPosition();
|
| 818 | return isVulcan297ExemptBlock(mc.level.getBlockState(feet).getBlock())
|
| 819 | || isVulcan297ExemptBlock(mc.level.getBlockState(feet.below()).getBlock());
|
| 820 | }
|
| 821 |
|
| 822 | private boolean isVulcan297ExemptBlock(Block block) {
|
| 823 | return vulcan297Exempts.get(VULCAN_EXEMPT_WEB) && (block == Blocks.COBWEB || block == Blocks.POWDER_SNOW)
|
| 824 | || vulcan297Exempts.get(VULCAN_EXEMPT_SOUL_SAND) && block == Blocks.SOUL_SAND
|
| 825 | || vulcan297Exempts.get(VULCAN_EXEMPT_SLIME) && block == Blocks.SLIME_BLOCK
|
| 826 | || vulcan297Exempts.get(VULCAN_EXEMPT_SWEET_BERRIES) && block == Blocks.SWEET_BERRY_BUSH
|
| 827 | || vulcan297Exempts.get(VULCAN_EXEMPT_TRAPDOOR) && block instanceof TrapDoorBlock
|
| 828 | || vulcan297Exempts.get(VULCAN_EXEMPT_FENCE) && block instanceof FenceBlock
|
| 829 | || vulcan297Exempts.get(VULCAN_EXEMPT_WALL) && block instanceof WallBlock;
|
| 830 | }
|
| 831 |
|
| 832 | private boolean hasVulcan297NetheriteArmor(LocalPlayer player) {
|
| 833 | return isNetheriteArmor(player.getItemBySlot(EquipmentSlot.HEAD))
|
| 834 | || isNetheriteArmor(player.getItemBySlot(EquipmentSlot.CHEST))
|
| 835 | || isNetheriteArmor(player.getItemBySlot(EquipmentSlot.LEGS))
|
| 836 | || isNetheriteArmor(player.getItemBySlot(EquipmentSlot.FEET));
|
| 837 | }
|
| 838 |
|
| 839 | private boolean isNetheriteArmor(ItemStack stack) {
|
| 840 | return stack.is(Items.NETHERITE_HELMET)
|
| 841 | || stack.is(Items.NETHERITE_CHESTPLATE)
|
| 842 | || stack.is(Items.NETHERITE_LEGGINGS)
|
| 843 | || stack.is(Items.NETHERITE_BOOTS);
|
| 844 | }
|
| 845 |
|
| 846 | private boolean isZeroVelocity(Vec3 velocity) {
|
| 847 | return velocity.x == 0.0 && velocity.y == 0.0 && velocity.z == 0.0;
|
| 848 | }
|
| 849 |
|
| 850 | private void processDelayedPackets() {
|
| 851 | int size = delayedPackets.size();
|
| 852 | for (int i = 0; i < size; i++) {
|
| 853 | DelayedPacket delayed = delayedPackets.poll();
|
| 854 | if (delayed == null) continue;
|
| 855 |
|
| 856 | delayed.ticks--;
|
| 857 | if (delayed.ticks > 0) {
|
| 858 | delayedPackets.add(delayed);
|
| 859 | continue;
|
| 860 | }
|
| 861 |
|
| 862 | PacketEvent.Receive packetEvent = new PacketEvent.Receive(delayed.packet, false);
|
| 863 | Events.BUS.post(packetEvent);
|
| 864 | if (!packetEvent.isCancelled()) {
|
| 865 | handleIncomingPacket(delayed.packet);
|
| 866 | }
|
| 867 | }
|
| 868 | }
|
| 869 |
|
| 870 | @SuppressWarnings({"rawtypes", "unchecked"})
|
| 871 | private void handleIncomingPacket(Packet<?> packet) {
|
| 872 | Connection connection = mc.getConnection() != null ? mc.getConnection().getConnection() : null;
|
| 873 | PacketListener listener = connection != null ? connection.getPacketListener() : null;
|
| 874 | if (listener != null) {
|
| 875 | ((Packet) packet).handle(listener);
|
| 876 | }
|
| 877 | }
|
| 878 |
|
| 879 | private boolean supportsIncomingVelocity() {
|
| 880 | return mode.get() != Mode.DEXLAND
|
| 881 | && mode.get() != Mode.HYLEX
|
| 882 | && mode.get() != Mode.AAC_442
|
| 883 | && mode.get() != Mode.INTAVE
|
| 884 | && mode.get() != Mode.VULCAN_297;
|
| 885 | }
|
| 886 |
|
| 887 | private boolean isVulcan297Mode() {
|
| 888 | return mode.get() == Mode.VULCAN_297;
|
| 889 | }
|
| 890 |
|
| 891 | private boolean isLocalPlayerVelocity(Packet<?> packet) {
|
| 892 | LocalPlayer player = player();
|
| 893 | if (player == null) return false;
|
| 894 | if (packet instanceof ClientboundSetEntityMotionPacket velocity) {
|
| 895 | return velocity.id() == player.getId();
|
| 896 | }
|
| 897 | return packet instanceof ClientboundExplodePacket explosion && explosion.playerKnockback().isPresent();
|
| 898 | }
|
| 899 |
|
| 900 | private boolean isLocalPlayerDamage(Packet<?> packet) {
|
| 901 | return packet instanceof ClientboundDamageEventPacket damage && player() != null && damage.entityId() == player().getId();
|
| 902 | }
|
| 903 |
|
| 904 | private LocalPlayer player() {
|
| 905 | return mc.player;
|
| 906 | }
|
| 907 |
|
| 908 | private boolean isMoving() {
|
| 909 | return MovementUtil.isMoving();
|
| 910 | }
|
| 911 |
|
| 912 | private Vec3 movementInput() {
|
| 913 | if (player() == null || player().input == null) return Vec3.ZERO;
|
| 914 | var input = player().input.getMoveVector();
|
| 915 | return new Vec3(input.x, 0.0, input.y);
|
| 916 | }
|
| 917 |
|
| 918 | private float movementYaw() {
|
| 919 | Rotation rotation = RotationManager.INSTANCE.getMovementRotation();
|
| 920 | return rotation != null ? rotation.yaw() : player().getYRot();
|
| 921 | }
|
| 922 |
|
| 923 | private double horizontalSpeed(Vec3 velocity) {
|
| 924 | return Math.hypot(velocity.x, velocity.z);
|
| 925 | }
|
| 926 |
|
| 927 | private void multiplyHorizontal(LocalPlayer player, double factor) {
|
| 928 | Vec3 velocity = player.getDeltaMovement();
|
| 929 | player.setDeltaMovement(velocity.x * factor, velocity.y, velocity.z * factor);
|
| 930 | }
|
| 931 |
|
| 932 | private boolean rollChance(float chance) {
|
| 933 | return chance >= 100.0f || ThreadLocalRandom.current().nextDouble(100.0) < chance;
|
| 934 | }
|
| 935 |
|
| 936 | private void sendSneaking(boolean sneaking) {
|
| 937 | if (mc.getConnection() == null) return;
|
| 938 | Input input = player() != null && player().input != null
|
| 939 | ? player().input.keyPresses
|
| 940 | : new Input(false, false, false, false, false, false, false);
|
| 941 | mc.getConnection().send(new ServerboundPlayerInputPacket(new Input(
|
| 942 | input.forward(),
|
| 943 | input.backward(),
|
| 944 | input.left(),
|
| 945 | input.right(),
|
| 946 | input.jump(),
|
| 947 | sneaking,
|
| 948 | input.sprint()
|
| 949 | )));
|
| 950 | }
|
| 951 |
|
| 952 | private BlockHitResult traceDownToPlayerBlock(LocalPlayer player) {
|
| 953 | Rotation server = RotationManager.INSTANCE.getServerRotation();
|
| 954 | float yaw = server != null ? server.yaw() : player.getYRot();
|
| 955 | Vec3 start = player.getEyePosition();
|
| 956 | Vec3 end = start.add(Vec3.directionFromRotation(90.0f, yaw).scale(4.5));
|
| 957 | HitResult hit = player.level().clip(new ClipContext(
|
| 958 | start,
|
| 959 | end,
|
| 960 | ClipContext.Block.OUTLINE,
|
| 961 | ClipContext.Fluid.NONE,
|
| 962 | player
|
| 963 | ));
|
| 964 | if (!(hit instanceof BlockHitResult blockHit) || blockHit.getType() == HitResult.Type.MISS) return null;
|
| 965 |
|
| 966 | BlockPos playerBlock = player.blockPosition();
|
| 967 | return blockHit.getBlockPos().relative(blockHit.getDirection()).equals(playerBlock) ? blockHit : null;
|
| 968 | }
|
| 969 |
|
| 970 | private void sendGrim2371Rotation(LocalPlayer player) {
|
| 971 | if (mc.getConnection() == null) return;
|
| 972 | Rotation server = RotationManager.INSTANCE.getServerRotation();
|
| 973 | if (server == null || Mth.abs(server.pitch() - 90.0f) > 0.001f) {
|
| 974 | mc.getConnection().send(new ServerboundMovePlayerPacket.Rot(
|
| 975 | player.getYRot(),
|
| 976 | 90.0f,
|
| 977 | player.onGround(),
|
| 978 | player.horizontalCollision
|
| 979 | ));
|
| 980 | } else {
|
| 981 | mc.getConnection().send(new ServerboundMovePlayerPacket.StatusOnly(
|
| 982 | player.onGround(),
|
| 983 | player.horizontalCollision
|
| 984 | ));
|
| 985 | }
|
| 986 | }
|
| 987 |
|
| 988 | private void sendFullMovePacket(LocalPlayer player) {
|
| 989 | if (mc.getConnection() == null || player == null) return;
|
| 990 | mc.getConnection().send(new ServerboundMovePlayerPacket.PosRot(
|
| 991 | player.getX(),
|
| 992 | player.getY(),
|
| 993 | player.getZ(),
|
| 994 | player.getYRot(),
|
| 995 | player.getXRot(),
|
| 996 | player.onGround(),
|
| 997 | player.horizontalCollision
|
| 998 | ));
|
| 999 | }
|
| 1000 |
|
| 1001 | private void sendStopDestroyBlock(LocalPlayer player) {
|
| 1002 | if (mc.getConnection() == null || player == null) return;
|
| 1003 | mc.getConnection().send(new ServerboundPlayerActionPacket(
|
| 1004 | ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK,
|
| 1005 | player.blockPosition(),
|
| 1006 | Direction.DOWN
|
| 1007 | ));
|
| 1008 | }
|
| 1009 |
|
| 1010 | private void resetState() {
|
| 1011 | delayedPackets.clear();
|
| 1012 | pause = 0;
|
| 1013 | transactionBuffer = 0;
|
| 1014 | reversalHandlingVelocity = false;
|
| 1015 | reversalVelocityTicks = 0;
|
| 1016 | strafeTicks = -1;
|
| 1017 | strafeApplyUntilGround = false;
|
| 1018 | jumpLimitUntilJump = 0;
|
| 1019 | jumpResetFallDamage = false;
|
| 1020 | lagShouldLag = false;
|
| 1021 | lagTicks = 0;
|
| 1022 | lagShouldJumpTicks = 0;
|
| 1023 | hypixelAbsorbedVelocity = false;
|
| 1024 | dexlandLastAttackTime = 0L;
|
| 1025 | dexlandCount = 0;
|
| 1026 | grim2371CancelNextVelocity = false;
|
| 1027 | grim2371Delay = false;
|
| 1028 | grim2371NeedClick = false;
|
| 1029 | grim2371WaitForPing = false;
|
| 1030 | grim2371WaitForUpdate = false;
|
| 1031 | grim2371ShouldSkip = false;
|
| 1032 | grim2371HitResult = null;
|
| 1033 | grim2371FreezeTicks = 0;
|
| 1034 | grim2344CanCancel = false;
|
| 1035 | intaveLastAttack = 0L;
|
| 1036 | intaveFallDamage = false;
|
| 1037 | intaveCurrentDelay = 0;
|
| 1038 | intaveDelayCounter = 0;
|
| 1039 | vulcan297WindBurstPendingTicks = 0;
|
| 1040 | vulcan297WindBurstProtectTicks = 0;
|
| 1041 | }
|
| 1042 |
|
| 1043 | @Getter
|
| 1044 | @RequiredArgsConstructor
|
| 1045 | public enum Mode implements EnumValue.IdProvider {
|
| 1046 | MODIFY("modify"),
|
| 1047 | REVERSAL("reversal"),
|
| 1048 | STRAFE("strafe"),
|
| 1049 | JUMP_RESET("jump_reset"),
|
| 1050 | LAG("lag"),
|
| 1051 | HYPIXEL("hypixel"),
|
| 1052 | DEXLAND("dexland"),
|
| 1053 | HYLEX("hylex"),
|
| 1054 | BLOCKSMC("blocksmc"),
|
| 1055 | GRIM_2371("grim_2371"),
|
| 1056 | GRIM_2344("grim_2344_117"),
|
| 1057 | AAC_442("aac_4_4_2"),
|
| 1058 | INTAVE("intave"),
|
| 1059 | VULCAN_297("vulcan_297");
|
| 1060 |
|
| 1061 | private final String id;
|
| 1062 | }
|
| 1063 |
|
| 1064 | private enum Filter {
|
| 1065 | ALWAYS,
|
| 1066 | ON_GROUND,
|
| 1067 | IN_AIR
|
| 1068 | }
|
| 1069 |
|
| 1070 | private static final class DelayedPacket {
|
| 1071 | final Packet<?> packet;
|
| 1072 | int ticks;
|
| 1073 |
|
| 1074 | DelayedPacket(Packet<?> packet, int ticks) {
|
| 1075 | this.packet = packet;
|
| 1076 | this.ticks = ticks;
|
| 1077 | }
|
| 1078 | }
|
| 1079 | }
|
| 1080 |
|