Bloxd.io Scaffold (Auto-Place Block Under Player) with Toggle + Status

Auto-place blocks under player in Bloxd.io using NoaHook, toggle with Z key, with visible status text on screen.

目前為 2025-05-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bloxd.io Scaffold (Auto-Place Block Under Player) with Toggle + Status
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Auto-place blocks under player in Bloxd.io using NoaHook, toggle with Z key, with visible status text on screen.
// @author       zNxrd
// @match        *://*.bloxd.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    let scaffoldEnabled = false;
    let gameLoaded = false;

    // Add status display
    const statusDiv = document.createElement('div');
    statusDiv.style.position = 'fixed';
    statusDiv.style.top = '10px';
    statusDiv.style.left = '10px';
    statusDiv.style.padding = '5px 10px';
    statusDiv.style.background = 'rgba(0, 0, 0, 0.5)';
    statusDiv.style.color = '#0f0';
    statusDiv.style.fontSize = '16px';
    statusDiv.style.fontFamily = 'monospace';
    statusDiv.style.zIndex = '9999';
    statusDiv.style.pointerEvents = 'none';
    statusDiv.textContent = 'Scaffold Status: Disabled';
    document.body.appendChild(statusDiv);

    function updateStatusText() {
        statusDiv.textContent = `Scaffold Status: ${scaffoldEnabled ? 'Enabled' : 'Disabled'}`;
        statusDiv.style.color = scaffoldEnabled ? '#0f0' : '#f00';
    }

    // Toggle scaffold with "Z" key
    document.addEventListener('keydown', function (e) {
        if (e.key.toLowerCase() === 'z') {
            scaffoldEnabled = !scaffoldEnabled;
            updateStatusText();
            console.log(`[Scaffold] ${scaffoldEnabled ? 'Enabled' : 'Disabled'}`);
        }
    });

    const waitForGame = () => {
        const interval = setInterval(() => {
            if (window.noa && window.SendPacket && noa.entities) {
                gameLoaded = true;
                clearInterval(interval);
                console.log('[Scaffold] Game detected. Ready.');
                startScaffold();
            }
        }, 250);
    };

    function isBlockBelow(pos) {
        const x = Math.floor(pos[0]);
        const y = Math.floor(pos[1]) - 1;
        const z = Math.floor(pos[2]);
        const blockId = noa.world.getBlock(x, y, z);
        return blockId !== 0;
    }

    function placeBlockBelow(pos) {
        const x = Math.floor(pos[0]);
        const y = Math.floor(pos[1]) - 1;
        const z = Math.floor(pos[2]);

        // Set your block type here (e.g., dirt = 1)
        const blockType = 1;

        SendPacket(2, `place|${x},${y},${z},${blockType}`);
    }

    function startScaffold() {
        function tick() {
            if (scaffoldEnabled) {
                const playerId = noa.playerEntity;
                const pos = noa.entities.getPosition(playerId);

                if (pos && !isBlockBelow(pos)) {
                    placeBlockBelow(pos);
                }
            }
            requestAnimationFrame(tick);
        }

        requestAnimationFrame(tick);
    }

    updateStatusText();
    waitForGame();
})();