npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nxg-org/mineflayer-smooth-look

v1.0.1

Published

Interpolated looking for mineflayer

Downloads

25

Readme

mineflayer-smooth-look

Example:

const {loader} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");
const {Vec3} = require("vec3");


const bot = createBot({...});
bot.loadPlugin(loader);


bot.smoothLook.lookAt(target /* entity position */)
bot.smoothLook.lookTowards(new Vec3(0, 0, 0) /* direction */)
bot.smoothLook.look(yaw, pitch)

Notes:

"Why is force default to true?"

Well, The alternative is to append the latest tween to the list of tweens that have not completed yet. Naturally, most tweening will occur over the span than more than one tick. Yet someone will definitely look at an entity every tick. If force is false, the bot will take duration * # of calls to complete the look. If force is true, it will only take duration ms to complete.

If you want to use this plugin while also retaining the ability to instantly snap to look at something, do not monkeypatch this plugin in and call bot.smoothLook.look or bot.smoothLook.lookAt instead.

API:

smoothLook.setEasing(func)

  • func: A function for interpolating movements. These are provided by @tweenjs/tween.js. I highly recommend you look at those instead. The default is TWEEN.Easing.Elastic.Out.

Example:

const {loader} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");
const {Vec3} = require("vec3");
const TWEEN = require("@tweenjs/tween.js");

const bot = createBot({...});
bot.loadPlugin(loader);

bot.smoothLook.setEasing(TWEEN.Easing.Quadratic.InOut);
smoothLook.lookAt(target, force = true, goodEnoughDot = 1)
  • target: A Vec3 instance, giving the location of whatever you want to look at.

    • For entities: do entity.position
  • force: Whether or not to start the tween immediately, or after all others finish.

  • goodEnoughDot: The dot product of the current look direction and the target direction. If the dot product is greater than this value, the tween will not start. This is to prevent the bot from looking at the target if it is already looking at it.

  • Returns Promise<void>.

    • Resolves when the tween is finished.

Example:

const {loader} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");
const {Vec3} = require("vec3");

const bot = createBot({...});
bot.loadPlugin(loader);

await bot.smoothLook.lookAt(new Vec3(0, 0, 0), true, 0.99);

smoothLook.lookTowards(direction, force = true, goodEnoughDot = 1)

  • direction: A Vec3 instance, indicating x, y, and z.

  • force: Whether or not to start the tween immediately, or after all others finish.

  • goodEnoughDot: The dot product of the current look direction and the target direction. If the dot product is greater than this value, the tween will not start. This is to prevent the bot from looking at the target if it is already looking at it.

  • Returns Promise<void>.

    • Resolves when the tween is finished.

Example:


const {loader} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");

const bot = createBot({...});
bot.loadPlugin(loader);

const entity = bot.nearestEntity();

const direction = entity.position.clone().minus(bot.entity.position);

await bot.smoothLook.lookTowards(direction, true, 0.99);

smoothLook.look(yaw, pitch, force = true, goodEnoughDot = 1)

  • yaw: A number.

  • pitch: A number.

  • force: Whether or not to start the tween immediately, or after all others finish.

  • goodEnoughDot: The dot product of the current look direction and the target direction. If the dot product is greater than this value, the tween will not start. This is to prevent the bot from looking at the target if it is already looking at it.

  • Returns Promise<void>.

    • Resolves when the tween is finished.

Example:

const {loader} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");

const bot = createBot({...});
bot.loadPlugin(loader);

await bot.smoothLook.look(0, 0, true, 0.99);

monkeyPatch(bot)

  • bot: The mineflayer bot. Monkey patches the bot's current look and lookAt to use the smoothLook plugin automatically.

Example:

const {monkeyPatch} = require("@nxg-org/mineflayer-smooth-look");
const {createBot} = require("mineflayer");

const bot = createBot({...});
monkeyPatch(bot);