Download Adam/control_primitives/shoot.js from OpenCausaLab/ADAM: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/OpenCausaLab/ADAM/resolve/main/Adam/control_primitives/shoot.js
- Command line
-
hf download hf://OpenCausaLab/ADAM/Adam/control_primitives/shoot.js
-
curl -L -o shoot.js https://huggingface.co/OpenCausaLab/ADAM/resolve/main/Adam/control_primitives/shoot.js
896 Bytes
| // shoot 1 pig with a bow: shoot(bot, "bow", "pig"); | |
| async function shoot(bot, weapon, target) { | |
| const validWeapons = [ | |
| "bow", | |
| "crossbow", | |
| "snowball", | |
| "ender_pearl", | |
| "egg", | |
| "splash_potion", | |
| "trident", | |
| ]; | |
| if (!validWeapons.includes(weapon)) { | |
| bot.chat(`${weapon} is not a valid weapon for shooting`); | |
| return; | |
| } | |
| const weaponItem = mcData.itemsByName[weapon]; | |
| if (!bot.inventory.findInventoryItem(weaponItem.id, null)) { | |
| bot.chat(`No ${weapon} in inventory for shooting`); | |
| return; | |
| } | |
| const targetEntity = bot.nearestEntity( | |
| (entity) => | |
| entity.name === target | |
| ); | |
| if (!targetEntity) { | |
| bot.chat(`No ${target} nearby`); | |
| return; | |
| } | |
| bot.hawkEye.autoAttack(targetEntity, "bow"); | |
| bot.on('auto_shot_stopped', (target) => { | |
| }) | |
| } | |