SpectraX Client - REAL FPS Boost

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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);
})();