Vectorized Velocity
-
Changes the velocity direction or strength based on the incoming packet or minecraft player's facing direction. Usually not useful unless you need to be flying sideways or your facing direction.
Released js for LiquidBounce Nextgen 0.28.1, Licensed under GPLv3
function __require(path) { if (path.startsWith("@embedded")) { return globalThis } if (path.startsWith("@minecraft-yarn-definitions/types/")) { return { [path.substring(path.lastIndexOf("/") + 1)]: Java.type(path .replaceAll("@minecraft-yarn-definitions/types/", "") .replaceAll("/", ".") ) } } return require(path); } var exports = {} "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // imports /* eslint-disable unused-imports/no-unused-imports */ const _embedded_1 = __require("@embedded"); const EntityVelocityUpdateS2CPacket_1 = __require("@minecraft-yarn-definitions/types/net/minecraft/network/packet/s2c/play/EntityVelocityUpdateS2CPacket"); /* eslint-enable unused-imports/no-unused-imports */ // DO NOT TOUCH ANYTHING ABOVE THIS LINE, also not sure why it didn't work const script = _embedded_1.registerScript.apply({ name: "vectorized-velocity-xz", version: "1.0.0", authors: ["commandblock2"] }); script.registerModule({ name: "vectorized-velocity-xz", description: "Port of the old script for legacy, for those anticheat that doesn't have proper velocity detection", category: "Combat", settings: { offsetBasedOnPlayerOrIncomingVelocity: _embedded_1.Setting.choose({ name: "OffsetBasedOnPlayerOrIncomingVelocity", choices: ["player", "incoming"], default: "player" }), offset: _embedded_1.Setting.float({ name: "AngleOffset", default: 0, range: [-180, 180] }), amplitude: _embedded_1.Setting.float({ name: "Amplitude", default: 1, range: [-100, 100] }) } }, (mod) => { mod.on("packet", (event) => { if (!_embedded_1.mc.player) return; const packet = event.packet; if (packet instanceof EntityVelocityUpdateS2CPacket_1.EntityVelocityUpdateS2CPacket && packet.entityId == _embedded_1.mc.player.id) { const yaw = mod.settings.offset.get() + (mod.settings.offsetBasedOnPlayerOrIncomingVelocity.getValue() == "player" ? -_embedded_1.mc.player.yaw : (Math.atan2(packet.getVelocityX(), packet.getVelocityZ()) * 180 / Math.PI)); const velocity = Math.sqrt(packet.getVelocityX() * packet.getVelocityX() + packet.getVelocityZ() * packet.getVelocityZ()) * 8000 * mod.settings.amplitude.get(); // graaljs traps here: // 1. it eats error here when we have loss in precision and does not update the value // 2. packet.velocityX and packet.getVelocityX() is very different (public double getVelocityX() { return (double)this.velocityX / 8000.0; }) // and when reading velocityX graaljs calls getVelocityX() and when writing velocityX it directly writes that packet.velocityX = Math.round(velocity * Math.sin(yaw / 180 * Math.PI)); packet.velocityZ = Math.round(velocity * Math.cos(yaw / 180 * Math.PI)); } }); });
original typescript script, won't run directly in LiquidBounce, for more info, see https://github.com/commandblock2/minecraft-LBNG-types
// imports /* eslint-disable unused-imports/no-unused-imports */ import { Setting, Vec3i, Vec3d, MathHelper, BlockPos, Hand, RotationAxis, mc, Client, RotationUtil, ItemUtil, NetworkUtil, InteractionUtil, BlockUtil, MovementUtil, ReflectionUtil, ParameterValidator, UnsafeThread, registerScript } from "@embedded"; import { EntityVelocityUpdateS2CPacket } from "@minecraft-yarn-definitions/types/net/minecraft/network/packet/s2c/play/EntityVelocityUpdateS2CPacket"; /* eslint-enable unused-imports/no-unused-imports */ // DO NOT TOUCH ANYTHING ABOVE THIS LINE, also not sure why it didn't work const script = registerScript.apply({ name: "vectorized-velocity-xz", version: "1.0.0", authors: ["commandblock2"] }); script.registerModule({ name: "vectorized-velocity-xz", description: "Port of the old script for legacy, for those anticheat that doesn't have proper velocity detection", category: "Combat", settings: { offsetBasedOnPlayerOrIncomingVelocity: Setting.choose({ name: "OffsetBasedOnPlayerOrIncomingVelocity", choices: ["player", "incoming"], default: "player" }), offset: Setting.float({ name: "AngleOffset", default: 0, range: [-180, 180] }), amplitude: Setting.float({ name: "Amplitude", default: 1, range: [-100, 100] }) } }, (mod) => { mod.on("packet", (event) => { if (!mc.player) return; const packet = event.packet if (packet instanceof EntityVelocityUpdateS2CPacket && packet.entityId == mc.player.id) { const yaw = mod.settings.offset.get() + (mod.settings.offsetBasedOnPlayerOrIncomingVelocity.getValue() == "player" ? -mc.player.yaw : (Math.atan2(packet.getVelocityX(), packet.getVelocityZ()) * 180 / Math.PI)); const velocity = Math.sqrt(packet.getVelocityX() * packet.getVelocityX() + packet.getVelocityZ() * packet.getVelocityZ()) * 8000 * mod.settings.amplitude.get(); // graaljs traps here: // 1. it eats error here when we have loss in precision and does not update the value // 2. packet.velocityX and packet.getVelocityX() is very different (public double getVelocityX() { return (double)this.velocityX / 8000.0; }) // and when reading velocityX graaljs calls getVelocityX() and when writing velocityX it directly writes that packet.velocityX = Math.round(velocity * Math.sin(yaw / 180 * Math.PI)) packet.velocityZ = Math.round(velocity * Math.cos(yaw / 180 * Math.PI)) } }) })
1/1