const script = registerScript({ name: "TriggerBot", version: "1.3.2", authors: ["Qwen3.8", "AlternativePutin"] }); script.registerModule({ name: "TriggerBot", category: "Combat", description: "Raycast-based TriggerBot with human reaction simulation and smart crits.", settings: { // --- Reaction settings --- minReaction: Setting.int({ name: "Min Reaction (ms)", default: 90, range: [1, 700] }), maxReaction: Setting.int({ name: "Max Reaction (ms)", default: 180, range: [1, 700] }), // --- Targets --- players: Setting.boolean({ name: "Players", default: true }), mobs: Setting.boolean({ name: "Mobs", default: false }), animals: Setting.boolean({ name: "Animals", default: false }), invisibles: Setting.boolean({ name: "Invisibles", default: true }), ignoreTeams: Setting.boolean({ name: "Ignore Teammates", default: true }), ignoreNaked: Setting.boolean({ name: "Ignore Naked Players", default: false }), // --- Combat / Crits --- onlyCrits: Setting.boolean({ name: "Only Critical Hits", default: false }), smartCrits: Setting.boolean({ name: "Smart Critical Hits", default: true }), onlyWeapon: Setting.boolean({ name: "Only Sword/Axe", default: false }), breakShield: Setting.boolean({ name: "Shield Disable (Axe)", default: true }), debug: Setting.boolean({ name: "Debug Logs", default: false }) } }, (mod) => { const S = mod.settings; // Если true — разрешать крит даже при спринте. // Если хочешь максимально строгую ванильную проверку — поставь false. const ALLOW_SPRINT_CRITS = true; function T(n) { try { return Java.type(n); } catch (e) { return null; } } const PlayerE = T("net.minecraft.world.entity.player.Player"); const Monster = T("net.minecraft.world.entity.monster.Monster"); const Animal = T("net.minecraft.world.entity.animal.Animal"); const SwordItem = T("net.minecraft.world.item.SwordItem"); const AxeItem = T("net.minecraft.world.item.AxeItem"); const Hand = T("net.minecraft.world.InteractionHand"); let currentTarget = null; let lookStartTime = 0; let reactionDelay = 0; let attackTickDelay = 0; let lastDebugTime = 0; function log(msg) { if (getBool(S.debug)) { Client.displayChatMessage("§8[§bTriggerBot§8] §f" + msg); } } function throttledLog(msg) { const now = Date.now(); if (now - lastDebugTime > 700) { lastDebugTime = now; log(msg); } } function asBool(v) { if (v === null || v === undefined) return false; if (typeof v === "boolean") return v; if (typeof v === "number") return v !== 0; try { const s = String(v).toLowerCase(); return s === "true" || s === "1"; } catch (e) { return false; } } function asNumber(v, def) { if (v === null || v === undefined) return def; try { const n = Number(v); return isNaN(n) ? def : n; } catch (e) { return def; } } function clamp(v, min, max) { const n = asNumber(v, min); if (n < min) return min; if (n > max) return max; return n; } function getBool(setting) { try { if (setting == null) return false; if (typeof setting.getValue === "function") return asBool(setting.getValue()); if (typeof setting.get === "function") return asBool(setting.get()); if (setting.value !== undefined) return asBool(setting.value); return asBool(setting); } catch (e) { return false; } } function getNum(setting, def) { try { if (setting == null) return def; if (typeof setting.getValue === "function") return asNumber(setting.getValue(), def); if (typeof setting.get === "function") return asNumber(setting.get(), def); if (setting.value !== undefined) return asNumber(setting.value, def); return asNumber(setting, def); } catch (e) { return def; } } function getReactionDelay() { let min = Math.floor(clamp(getNum(S.minReaction, 90), 1, 700)); let max = Math.floor(clamp(getNum(S.maxReaction, 180), 1, 700)); // Если пользователь случайно поставил Min больше Max — меняем местами. if (min > max) { const temp = min; min = max; max = temp; } if (min === max) { return min; } return Math.random() * (max - min) + min; } function propBool(obj, name) { try { if (obj == null) return false; const v = obj[name]; if (typeof v === "function") return asBool(v.call(obj)); return asBool(v); } catch (e) { return false; } } function propNum(obj, name) { try { if (obj == null) return 0; const v = obj[name]; if (typeof v === "function") return asNumber(v.call(obj), 0); return asNumber(v, 0); } catch (e) { return 0; } } function isOnGround(p) { try { if (typeof p.onGround !== "undefined") { const v = p.onGround; if (typeof v === "function") return asBool(v.call(p)); return asBool(v); } } catch (e) {} try { if (typeof p.isOnGround === "function") return asBool(p.isOnGround()); } catch (e) {} try { if (typeof p.onGround === "function") return asBool(p.onGround()); } catch (e) {} return false; } function hasArmor(entity) { try { const it = entity.getArmorSlots().iterator(); while (it.hasNext()) { const stack = it.next(); if (stack != null && !stack.isEmpty()) return true; } } catch (e) {} return false; } function isTeammate(entity) { if (!getBool(S.ignoreTeams) || !PlayerE || !(entity instanceof PlayerE)) { return false; } try { const pTeam = mc.player.getTeam(); const eTeam = entity.getTeam(); if (pTeam && eTeam && pTeam.getName() === eTeam.getName()) { return true; } } catch (e) {} try { const pName = mc.player.getDisplayName().getString(); const eName = entity.getDisplayName().getString(); const pColor = pName.match(/§[0-9a-fk-or]/i); const eColor = eName.match(/§[0-9a-fk-or]/i); if ( pColor && eColor && pColor[0] === eColor[0] && pColor[0] !== "§f" && pColor[0] !== "§7" ) { return true; } } catch (e) {} return false; } function isValidEntity(entity) { try { if (!entity || entity === mc.player) return false; if (!entity.isAlive() || entity.isSpectator()) return false; } catch (e) { return false; } if (isTeammate(entity)) return false; if (PlayerE && entity instanceof PlayerE) { if (!getBool(S.players)) return false; try { if (entity.isCreative()) return false; } catch (e) {} if (getBool(S.ignoreNaked) && !hasArmor(entity)) return false; try { if (entity.isInvisible() && !getBool(S.invisibles)) return false; } catch (e) {} return true; } if (Monster && entity instanceof Monster) return getBool(S.mobs); if (Animal && entity instanceof Animal) return getBool(S.animals); return false; } function hasWeapon() { try { const item = mc.player.getMainHandItem(); if (!item || item.isEmpty()) return false; const it = item.getItem(); return ( (SwordItem && it instanceof SwordItem) || (AxeItem && it instanceof AxeItem) ); } catch (e) { return false; } } function getCritInfo(p) { const info = { onGround: false, fallDistance: 0, water: false, lava: false, passenger: false, climbing: false, blind: false, elytra: false, flying: false, sprinting: false, crit: false }; info.onGround = isOnGround(p); info.fallDistance = propNum(p, "fallDistance"); try { info.water = asBool(p.isInWater()); } catch (e) {} try { info.lava = asBool(p.isInLava()); } catch (e) {} try { info.passenger = asBool(p.isPassenger()); } catch (e) {} info.climbing = propBool(p, "onClimbable"); try { const Blindness = T("net.minecraft.world.effect.MobEffects").BLINDNESS; if (Blindness) { info.blind = asBool(p.hasEffect(Blindness)); } } catch (e) {} try { info.elytra = asBool(p.isFallFlying()); } catch (e) {} try { const abilities = p.getAbilities(); if (abilities) { info.flying = propBool(abilities, "flying"); } } catch (e) {} try { if (typeof p.isSprinting === "function") { info.sprinting = asBool(p.isSprinting()); } else { info.sprinting = propBool(p, "sprinting"); } } catch (e) {} const sprintBlocked = !ALLOW_SPRINT_CRITS && info.sprinting; info.crit = !info.onGround && info.fallDistance > 0 && !info.water && !info.lava && !info.passenger && !info.climbing && !info.blind && !info.elytra && !info.flying && !sprintBlocked; return info; } function logCritBlock(info) { const reasons = []; if (info.onGround) reasons.push("onGround"); if (!(info.fallDistance > 0)) reasons.push("fall=" + info.fallDistance.toFixed(3)); if (!ALLOW_SPRINT_CRITS && info.sprinting) reasons.push("sprint"); if (info.water) reasons.push("water"); if (info.lava) reasons.push("lava"); if (info.passenger) reasons.push("passenger"); if (info.climbing) reasons.push("climbing"); if (info.blind) reasons.push("blind"); if (info.elytra) reasons.push("elytra"); if (info.flying) reasons.push("flying"); if (reasons.length > 0) { throttledLog("No crit: " + reasons.join(", ")); } } function attack(entity) { if (!mc.gameMode) return; try { mc.gameMode.attack(mc.player, entity); mc.player.swing(Hand ? Hand.MAIN_HAND : null); log("Hit: " + entity.getName().getString()); } catch (e) { log("Attack failed: " + e); } } mod.on("playerTick", () => { const p = mc.player; if (!p || !mc.level || !mc.gameMode) return; if (getBool(S.onlyWeapon) && !hasWeapon()) return; if (p.isUsingItem()) return; if (mc.screen != null) return; let target = null; try { const hitResult = mc.hitResult; if (hitResult) { let isEntityHit = false; try { isEntityHit = String(hitResult.getType().name()) === "ENTITY"; } catch (e) { try { const HitResultType = T("net.minecraft.world.phys.HitResult$Type"); isEntityHit = HitResultType && hitResult.getType() == HitResultType.ENTITY; } catch (e2) {} } if (isEntityHit) { target = hitResult.getEntity(); } } } catch (e) {} if (target && isValidEntity(target)) { if (target !== currentTarget) { currentTarget = target; lookStartTime = Date.now(); reactionDelay = getReactionDelay(); attackTickDelay = Math.floor(Math.random() * 2); } const timeLooked = Date.now() - lookStartTime; if (timeLooked < reactionDelay) return; const cooldown = p.getAttackStrengthScale(0.5); if (cooldown < 0.95) return; if (attackTickDelay > 0) { attackTickDelay--; return; } const onlyCrits = getBool(S.onlyCrits); const smartCrits = getBool(S.smartCrits); const critInfo = getCritInfo(p); // Only Critical Hits: бить только при реальном крите. if (onlyCrits) { if (!critInfo.crit) { logCritBlock(critInfo); return; } } // Smart Critical Hits: // - на земле разрешаем обычные удары; // - в воздухе ждём крит, если крит вообще возможен; // - если крит невозможен из-за воды/лестницы/транспорта/полёта и т.п., не блокируем удар. if (!onlyCrits && smartCrits) { if (!critInfo.onGround) { const critImpossible = critInfo.water || critInfo.lava || critInfo.passenger || critInfo.climbing || critInfo.blind || critInfo.elytra || critInfo.flying || (!ALLOW_SPRINT_CRITS && critInfo.sprinting); if (!critInfo.crit && !critImpossible) { throttledLog("SmartCrit: airborne, waiting for crit/fall"); return; } } } // Axe shield disable. if (getBool(S.breakShield) && AxeItem) { try { const main = p.getMainHandItem(); if (main && !main.isEmpty() && main.getItem() instanceof AxeItem) { if (target.isBlocking()) { attack(target); return; } } } catch (e) {} } attack(target); attackTickDelay = Math.floor(Math.random() * 2); } else { currentTarget = null; lookStartTime = 0; } }); mod.on("enable", () => { currentTarget = null; lookStartTime = 0; reactionDelay = 0; attackTickDelay = 0; log("Enabled."); }); mod.on("disable", () => { currentTarget = null; log("Disabled."); }); });