SpectraX Client - REAL FPS Boost

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

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

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