PrismarineJS mineflayer-pathfinder – Bot ignores movement rules for first few seconds of goal

I am working on a Minecraft bot in JavaScript using Mineflayer-Pathfinder.

I am seeing strange behavior. Before I call bot.pathfinder.setGoal(), I set the movement rules using pathfinder.setMovements(). However, when I do this, it seems like it takes the bot a few seconds for the movement rules to actually update. For the first few seconds as the bot carries out its goal, it sprints and does wild parkour moves to get to the target. This causes the bot to get rubber banded really bad on the server, and throws it off the path. Then, suddenly, it starts following the rules I set. Walking slowly, no parkour, etc.

The temporary workaround I found was to just set a delay before calling setGoal. I’ve found it can take at least 2 seconds for the bot to obey the rules set. However, the fact that I’m using timing for something like this tells me that I’ve likely done something critically wrong.

One thing I tried is to await for a path_update or path_reset after setting the movements, but it never seems to trigger….

await new Promise(res => bot.once('path_reset', res));

Nowhere else in my codebase am I setting the movements to anything different from the rules I set in my buildConstrainedMovments().


// helper to construct Movments
export function buildConstrainedMovements(bot, mcData) {
    const m = new Movements(bot, mcData);
    m.canDig = false;
    m.allowWater = false;
    m.allowSprinting = false;
    m.allow1by1towers = false;
    m.allowParkour = false;
    m.canOpenDoors = true;
    m.maxDropDown = 5;

    if (!m.blocksToAvoid) m.blocksToAvoid = new Set();
    const avoidNames = [
        'cobweb','sweet_berry_bush','powder_snow','campfire','soul_campfire','fire','magma_block','scaffolding',
        ...Object.keys(mcData.blocksByName).filter(n => /trapdoor/.test(n))
    ];
    for (const name of avoidNames) {
        const b = mcData.blocksByName[name];
        if (b) m.blocksToAvoid.add(b.id);
    }
    m.liquidCost = 100;
    return m;
}

// Child functions of makePearlPuller
/**
 * Create a pearl-pulling helper bound to a bot instance.
 * Usage:
 *   const pullPearl = makePearlPuller(bot, cfg, logger);
 *   await pullPearl('Notch', { x: 0, y: 64, z: 0 });
 */
export function makePearlPuller(bot, cfg, logger) {
    
    // Helper functions...
    bot.on('goal_reached', async (goal) => {
        if (!activePull) return;
        // Handle goal reached...
    });

    return async function pullPearl(username, homeCoords) { // <- Problem function
        if (activePull) return Promise.resolve();

        return new Promise(async (resolveOuter) => {
        _resolvePearlRun = resolveOuter; // scope in parent function

        try {
            const moves = await buildConstrainedMovements(bot, mcData);
            await bot.pathfinder.setMovements(moves);
            
            // ... Here I figure out where the coordinates to an active ender pearl is, and populate best with the coordinates

            // For some reason, if I don't wait a couple seconds, the bot ignores the movement rules set and starts sprinting,
            // doing parkour, etc.
            // bot.pathfinder.setGoal(new GoalNear(best.x, best.y, best.z, 2)); <- Won't work
            setTimeout(() => {
                try {
                    bot.pathfinder.setGoal(new GoalNear(best.x, best.y, best.z, 2));
                } catch (e) {
                    logger?.warn?.('[pearl] setGoal failed:', e?.message || e);
                    activePull = null;
                    finishPull();
                }
            }, 3000);

        } catch (err) {
            logger?.error?.('[pearl] unexpected error:', err);
            activePull = null;
            finishPull();
        }
        });
    };
}

Node Version: v18.19.1

Packages:

minecraft-data: 3.99.1

mineflayer: 4.20.0

mineflayer-pathfinder: 2.4.5

Generate a downloadable PDF from a template with HTML in a web client [closed]

I need to create a PDF file for a customer order. The PDF should be downloadable in the web client. The document is about 3 pages long and includes:

  • A colored table with headers

  • Several paragraphs of text

  • A company logo

Ideally, the PDF should be based on a template where I can insert variables dynamically.

Is there a way to create an HTML page as a template and then use a PDF generator to render the HTML into a PDF?

We have 2025 .. there must be a comfortable way of doing that besides compolicated and complex js libraries where I have to set every pixel.

This is the first time in a time where AI is not helping much.

Thanks in advance!

Blazor JSinterop invokeMethodAsync on blur event is affecting js component behavior

I’ve modified a blazor-js component based on QuillJs to enable two-way binding from the text editor to blazor/c# property

I’ve done this by adding a ‘blur’ event listener and invoking a method c# method from js:

(All source code here)
https://github.com/gismofx/TextEditor/blob/3ea6d0705a443d8ea81bdcce46814ef2261e1e26/src/Blazored.TextEditor/wwwroot/Blazored-BlazorQuill.js#L40

//On Blur - we update the object in dotnet
            quillElement.__quill.editor.scroll.domNode.addEventListener('blur',
                () => {
                    if (quillElement.__quill.options.debug === "info") {
                        console.log('info: Quill Editor blur event for ' + quillElement.id);
                    }
                    QuillFunctions.dotNetRefs.get(quillElement.id).invokeMethodAsync('DeltaChanged', QuillFunctions.getQuillContent(quillElement));
                }
            );

The two-way binding works just fine.

Issue:
When interacting with quill’s toolbar, e.g. to change some highligted text’s format, the cursor jumps to start of text and formatting it not applied. If you repeat, it applied the fomatting. This happens every time.

See recording of strange behavior:
strange behavior

If I remove the invokeMethodAsync call, it restores correct functionality and formatting is applied correctly.

Is there different event to use or another way to keep binding and not affect the quill functionality?

how should i clear my npm installation error (The term ‘npm’ is not recognized as the name of a cmdlet, function, script file, or operable program.) [closed]

enter image description here

how can i solve this program?

i just want to install npm in my vscode.
(npm : The term ‘npm’ is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.)

Programming interface with Web Dev Technology [closed]

I am just in beginning to learn JavaScript after HTML AND CSS now. but before I was working python especially PYQT6 python library for GUI applications. But I have experienced limitations and barrier using as New programmer while I was also working on my logic building now I have shift to Web Dev. Not for actually Web Development but for Making GUI interface and I was Amazed when I used HTML CSS. It has so many features and flexibility you get as a new coder that you can’t get this on Pyqt6 or Tkinter. I hope I will learn JavaScript soon as start my programming carrier as soon as possible. If someone know how can I learn JavaScript as fastest and efficiently as possible. I would love to know about it in the comments

WordPress RestAPI in Javascript. How to get array data out of the response

I am working on a Gutenberg block and am modifying the Edit.js file. I want to fetch the root categories in the database. From the reading I have done, it seems a good way to do this is to use the REST API and perform a call like this:

var categories = fetch("http://localhost/wordpress_ttm/wp-json/wp/v2/categories").then(response => response.json())

This all works fine and gives me back a response. Here is the structure of the response.

categories: Promise { "fulfilled" }
​​
<state>: "fulfilled"
​​
<value>: (10) […]
​​​
0: {…}
​​​
1: {…}
​​​
2: {…}
​​​
3: {…}
​​​
4: {…}
​​​
5: {…}
​​​
6: {…}
​​​
7: {…}
​​​
8: {…}
​​​
9: {…}
​​​
length: 10
​​​
<prototype>: []
​​
<prototype>: Promise.prototype

How do I to get the data out of the response? I want to grab the array data and iterate over it, but I’m not sure how to do that. Any help is appreciated.

Not load animation when I click button

I want that When Click on Button. It will start loading an animation untill p.php is fetched values.

HTML CODE

<input type="text" id="myInput" placeholder="Enter something">
<button id="myButton">Send Data</button>
<div id="responseArea"></div>

Javascript code

<script type="text/javascript">
document.getElementById('myButton').addEventListener('click', function() {
    const inputValue = document.getElementById('myInput').value;
    const data = { inputData: inputValue }; // Create an object to send

    fetch('p.php', { // Replace with your PHP script path
        method: 'POST',
        headers: {
            'Content-Type': 'application/json', // Specify content type
        },
        body: JSON.stringify(data), // Convert data to JSON string
    })
    .then(response => response.text()) // Or .json() if PHP returns JSON
    .then(responseText => {
        document.getElementById('responseArea').innerHTML = responseText;
    })
    .catch(error => {
        console.error('Error:', error);
    });
});
    </script>

Can anyone do it?

Axios request fails with error status code 500: Internal Server error

I’m try to create code for downloading template file in my project so after click on button I wand to download file throw this code:

axios({
  url: url,
  method: 'POST',
  responseType: 'blob',
  headers: {
    authorization: `Bearer ${token}`,
  },
//  data: postData
}).then((response) => {
  const href = URL.createObjectURL(response.data);
  const link = document.createElement('a');
  link.href = href;
  link.setAttribute('download', filename);
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
  URL.revokeObjectURL(href);
  //if (onDownloaded) onDownloaded(postData);
}).catch((err) => {
  console.error("Download failed:", err.message);
});

but I face to 500: Internal Server error for axios line.

I check my URL and it was true

Are there linters for TypeScript code that check if all expressions involving a int32 are followed by a bitwise “OR” operator?

I like that JavaScript and TypeScript allow for hardware-accelerated 32-bits integers (instead of the 64-bits floating point that is the default) if one uses the bit-wise “OR” operator like this:

let a: int32 = 1234;

// hardware-accelerated integral division by 3
a = (a / 3) | 0; 

However, the problem is that it’s easy for software developers to overlook that and forget to add the bit-wise operator when required (leading to the loss of the implied 32-bits integer type and it becomes promoted to a 64-bits floating type). It would be convenient if there were linters that would enforce that. Does such a linter exists?

I’m expecting that a tool for enforcing code style (linter) exists but the ones I’m aware of (eslint, rslint) do not seem to have the feature that I expect.

Generating Key & Nonce Pairs from Web Crypto API vs from Word List. Is entropy the same?

I want to find out if the 2 methods shown below achieve the same level of entropy.

For this first secure method, a 32 byte / 256 bit key and a 12 byte / 96 bit nonce are generated using the JavaScript Web Crypto API which is guaranteed to generate cryptographically strong random values.

Therefore we can affirm that the key & nonce contain maximum entropy for their respective sizes.

function generateSecureKeyNoncePair() {

  const keyBytes = new Uint8Array(32); // Buffer for random values
  crypto.getRandomValues(keyBytes);

  const nonceBytes = new Uint8Array(12); // Buffer for random values
  crypto.getRandomValues(nonceBytes);

  return {
    keyBytes,
    nonceBytes
  };

}

const { keyBytes, nonceBytes } = generateSecureKeyNoncePair();

console.log(keyBytes);
console.log(nonceBytes);

Next, inspired by https://developer.blockchaincommons.com/bytewords/, we have another function which selects 11 four letter words from a wordlist and slices the first 8 words for the key and the remaining 3 words for the nonce.

The reason for a wordlist of 256 four letter words is that these words can be converted to Uint8Array and then the Uint8Array can be converted to Uint32Array which can be used in a ChaCha20 state.

// wordList (256 four-letter words)
const wordList = [
  "able", "acid", "also", "apex", "aqua", "arch", "atom", "aunt", "away", "axis",
  "back", "bald", "barn", "belt", "beta", "bias", "blue", "body", "brag", "brew",
  "bulb", "buzz", "calm", "cash", "cats", "chef", "city", "claw", "code", "cola",
  "cook", "cost", "crux", "curl", "cusp", "cyan", "dark", "data", "days", "deli",
  "dice", "diet", "door", "down", "draw", "drop", "drum", "dull", "duty", "each",
  "easy", "echo", "edge", "epic", "even", "exam", "exit", "eyes", "fact", "fair",
  "fern", "figs", "film", "fish", "fizz", "flap", "flew", "flux", "foxy", "free",
  "frog", "fuel", "fund", "gala", "game", "gear", "gems", "gift", "girl", "glow",
  "good", "gray", "grim", "guru", "gush", "gyro", "half", "hang", "hard", "hawk",
  "heat", "help", "high", "hill", "holy", "hope", "horn", "huts", "iced", "idea",
  "idle", "inch", "inky", "into", "iris", "iron", "item", "jade", "jazz", "join",
  "jolt", "jowl", "judo", "jugs", "jump", "junk", "jury", "keep", "keno", "kept",
  "keys", "kick", "kiln", "king", "kite", "kiwi", "knob", "lamb", "lava", "lazy",
  "leaf", "legs", "liar", "limp", "lion", "list", "logo", "loud", "love", "luau",
  "luck", "lung", "main", "many", "math", "maze", "memo", "menu", "meow", "mild",
  "mint", "miss", "monk", "nail", "navy", "need", "news", "next", "noon", "note",
  "numb", "obey", "oboe", "omit", "onyx", "open", "oval", "owls", "paid", "part",
  "peck", "play", "plus", "poem", "pool", "pose", "puff", "puma", "purr", "quad",
  "quiz", "race", "ramp", "real", "redo", "rich", "road", "rock", "roof", "ruby",
  "ruin", "runs", "rust", "safe", "saga", "scar", "sets", "silk", "skew", "slot",
  "soap", "solo", "song", "stub", "surf", "swan", "taco", "task", "taxi", "tent",
  "tied", "time", "tiny", "toil", "tomb", "toys", "trip", "tuna", "twin", "ugly",
  "undo", "unit", "urge", "user", "vast", "very", "veto", "vial", "vibe", "view",
  "visa", "void", "vows", "wall", "wand", "warm", "wasp", "wave", "waxy", "webs",
  "what", "when", "whiz", "wolf", "work", "yank", "yawn", "yell", "yoga", "yurt",
  "zaps", "zero", "zest", "zinc", "zone", "zoom"
];

// Encode String Array to Uint8Array
const enc = new TextEncoder();
const stringArray2bytes = (words) => enc.encode(words.join(""));

function generateAsciiKeyNoncePair() {
  const selected = new Set();
  const randomBytes = new Uint8Array(22); // Buffer for random values
  
  crypto.getRandomValues(randomBytes);
  let byteIndex = 0;
  
  while (selected.size < 11) {
    if (byteIndex >= randomBytes.length) {
      crypto.getRandomValues(randomBytes);
      byteIndex = 0;
    }
    selected.add(randomBytes[byteIndex++]);
  }
  
  const indices = Array.from(selected);
  
  return {
    keyAscii: indices.slice(0, 8).map(i => wordList[i]),
    nonceAscii: indices.slice(8, 11).map(i => wordList[i])
  };
}

const { keyAscii, nonceAscii } = generateAsciiKeyNoncePair();

console.log("Ascii Key:", keyAscii);
console.log("Ascii Nonce:", nonceAscii);

console.log("Ascii Key:", stringArray2bytes(keyAscii));
console.log("Ascii Nonce:", stringArray2bytes(nonceAscii));

My question is, regardless of how user friendly this function is, am I naive to assume it achieves the same level of entropy as the first function? I ask because I can’t help but to think the word list contains words which are part of the English alphabet which is 26 letters in total unlike Uint8Array filled by crypto.getRandomValues() which is 256 bytes long.

Embed YouTube Videos With No Ads

I am attempting to develop a robust, custom client-side LoFi Music player for live-streaming YouTube content (like 24/7 radio streams) that is guaranteed ad-free, without relying on browser extensions like uBlock Origin.
The Challenge
Standard YouTube embeds (youtube-nocookie.com/embed/) are unreliable for 100% ad-free playback, as ads (especially pre-rolls or mid-rolls on live streams) can still be served through the iframe or loaded via the YouTube API.
I have observed a specific implementation—for example, on sites like lofimusic.app (which streams the Lofi Girl channel)—that successfully loads the YouTube stream and plays it in a custom, minimal UI.
My hypothesis is that this approach bypasses the official player entirely by finding and loading the underlying HLS/DASH manifest URL, filtering out the ad segments at the manifest level, and playing the content stream directly in a library like video.js.

What I’ve Tried

  • Standard youtube-nocookie.com embed: This reduces tracking but still allows ads served from the video creator/YouTube.

  • YouTube IFrame Player API: Using the official API gives control but honors all ad settings, making it impossible to block pre-rolls/mid-rolls client-side.

  • Client-Side Stream Sniffing (Developer Console): Attempted to monitor network traffic for the .m3u8 or .mpd manifest files when the stream loads, but the player obscures the URL and the initial manifest request is often signed/ephemeral.
    The Core Question
    For an established live-stream YouTube channel (e.g., Lofi Girl), what is the most reliable, modern client-side technique—primarily using JavaScript and/or a custom media library—to:

  • Retrieve the current, non-expiring video ID (or stream ID) from the live channel page.

  • Generate or retrieve the specific HLS (.m3u8) or DASH (.mpd) manifest URL for the raw media stream.

  • Filter/Proxy this manifest client-side (e.g., in a Service Worker or WebAssembly component) to strip out ad-related segments (SSAI or CSAI markers) before playback begins in a custom player (e.g., Video.js or hls.js)?
    I am specifically looking for insights into the first two steps: how to programmatically get the raw stream URL from a YouTube live video on the client-side without a persistent server-side proxy.