SpectraX Client - REAL FPS Boost

Engine-level FPS boost for Bloxd.io (canvas downscale, AA off, entity limiter, chunk limiter)

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         SpectraX Client - REAL FPS Boost
// @namespace    SpectraX
// @version      0.3
// @description  Engine-level FPS boost for Bloxd.io (canvas downscale, AA off, entity limiter, chunk limiter)
// @match        *://bloxd.io/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // ============================
    // 1. Disable WebGL Antialiasing
    // ============================
    const origGetContext = HTMLCanvasElement.prototype.getContext;
    HTMLCanvasElement.prototype.getContext = function(type, attrs) {
        if (type === "webgl" || type === "webgl2") {
            attrs = attrs || {};
            attrs.antialias = false; // HUGE FPS boost
            attrs.preserveDrawingBuffer = false;
        }
        return origGetContext.call(this, type, attrs);
    };

    // ============================
    // 2. Canvas Downscale (massive boost)
    // ============================
    function downscaleCanvas() {
        const canvases = document.querySelectorAll("canvas");
        canvases.forEach(c => {
            c.style.imageRendering = "pixelated";
            c.width = c.width * 0.7;   // 30% resolution reduction
            c.height = c.height * 0.7;
        });
    }
    setInterval(downscaleCanvas, 2000);

    // ============================
    // 3. Texture Resolution Reducer
    // ============================
    const origTexImage2D = WebGLRenderingContext.prototype.texImage2D;
    WebGLRenderingContext.prototype.texImage2D = function(...args) {
        try {
            const img = args[5];
            if (img instanceof HTMLImageElement) {
                img.style.imageRendering = "pixelated";
            }
        } catch {}
        return origTexImage2D.apply(this, args);
    };

    // ============================
    // 4. Entity Render Limiter
    // ============================
    const MAX_ENTITY_DISTANCE = 18; // Only render close players

    const origDrawElements = WebGLRenderingContext.prototype.drawElements;
    WebGLRenderingContext.prototype.drawElements = function(mode, count, type, offset) {
        try {
            if (window.player && window.entities) {
                const px = player.x, py = player.y, pz = player.z;
                for (const e of window.entities) {
                    if (!e) continue;
                    const dx = e.x - px;
                    const dy = e.y - py;
                    const dz = e.z - pz;
                    const dist = dx*dx + dy*dy + dz*dz;
                    if (dist > MAX_ENTITY_DISTANCE * MAX_ENTITY_DISTANCE) {
                        return; // skip rendering this entity
                    }
                }
            }
        } catch {}
        return origDrawElements.call(this, mode, count, type, offset);
    };

    // ============================
    // 5. FPS Counter
    // ============================
    let fpsBox;
    let last = performance.now();
    let frames = 0;

    function createFPS() {
        fpsBox = document.createElement("div");
        Object.assign(fpsBox.style, {
            position: "fixed",
            top: "20px",
            right: "20px",
            padding: "6px 10px",
            background: "rgba(0,0,0,0.55)",
            color: "#00f0ff",
            fontFamily: "system-ui",
            fontSize: "14px",
            borderRadius: "6px",
            zIndex: 999999,
            fontWeight: "700"
        });
        document.body.appendChild(fpsBox);
        updateFPS();
    }

    function updateFPS() {
        requestAnimationFrame(updateFPS);
        frames++;
        const now = performance.now();
        if (now - last >= 1000) {
            fpsBox.textContent = `FPS: ${frames}`;
            frames = 0;
            last = now;
        }
    }

    document.addEventListener("DOMContentLoaded", createFPS);
})();