Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
3.7 kB
7
Indexable
Never
/// <reference types='../../../CTAutocomplete' />
/// <reference lib='es2022' />

import RenderLib from '../../../RenderLib'
import PogObject from '../../../PogData'

const featureConfig = new PogObject('MQOL/config', { available: false, coords: [] }, 'config.AdvancedWaypoints.json')
let isRenderable = true;

export class AdvancedWaypoints
{
    constructor ()
    {
        register('renderWorld', () =>
            {
                if ( featureConfig.available )
                {
                    
                    this.traceVectors(featureConfig.coords, 255, 255, 255, 0.5, 3)
                }
            }
        )

        register('command', () =>
            {
                featureConfig.coords.push({ x: Player.getX(), y: Player.getY(), z: Player.getZ() });
                featureConfig.save()
                ChatLib.chat('new route added')
            }
        ).setName('addr')

        register('command', () =>
            {
                featureConfig.coords.shift()
                featureConfig.save()
                ChatLib.chat('route removed')
            }
        ).setName('remr')
    }

    traceVectors (coords, red, green, blue, alpha, radius)
    {
        if ( coords.length >= 2 && isRenderable )
        {

            for ( let i = coords.length; --i; )
            {
                RenderLib.drawInnerEspBox(coords[i].x, coords[i].y - 1, coords[i].z, 1, 1, 82 / 255, 214 / 255, 83 / 255, 0.2, true);
                RenderLib.drawEspBox(coords[i].x, coords[i].y - 1, coords[i].z, 1, 1, 82 / 255, 214 / 255, 83 / 255, 1, true);
                Tessellator.drawString(`#${i + 1}`, coords[i].x, coords[i].y + 1.25, coords[i].z, Renderer.WHITE, true, 1, true)
                
                RenderLib.drawInnerEspBox(coords[i].x, coords[i].y - 1, coords[i].z, 1, 1, 82 / 255, 214 / 255, 83 / 255, 0.2, true);
                RenderLib.drawEspBox(coords[(i + coords.length - 1) % coords.length].x, coords[(i + coords.length - 1) % coords.length].y - 1, coords[(i + coords.length - 1) % coords.length].z, 1, 1, 82 / 255, 214 / 255, 83 / 255, 1, true);    
                Tessellator.drawString(`#${(i + coords.length - 1) % coords.length + 1}`, coords[(i + coords.length - 1) % coords.length].x, coords[(i + coords.length - 1) % coords.length].y + 1.25, coords[(i + coords.length - 1) % coords.length].z, Renderer.WHITE, true, 1, true)    
            }
            
            GL11.glLineWidth(radius)
            GlStateManager.func_179129_p()
            GlStateManager.func_179147_l()
            GlStateManager.func_179112_b(770, 771)
            GlStateManager.func_179132_a(false)
            GlStateManager.func_179090_x()
        
            Tessellator.disableDepth();
            Tessellator.begin(1).colorize(red / 255, green / 255, blue / 255, alpha)
        
            for ( let i = coords.length; --i; )
            {
                Tessellator.pos((coords[i].x + 0.25), (coords[i].y), (coords[i].z - 0.25));
                Tessellator.pos((coords[(i + coords.length - 1) % coords.length].x + 0.25), (coords[(i + coords.length - 1) % coords.length].y), (coords[(i + coords.length - 1) % coords.length].z - 0.25));    
            }
        
            Tessellator.draw()
        
            GlStateManager.func_179089_o()
            GlStateManager.func_179084_k()
            GlStateManager.func_179132_a(true)
            GlStateManager.func_179098_w()
        }
    }

    static toggleFeature ()
    {
        featureConfig.available = !featureConfig.available;
        featureConfig.save();
    
        return featureConfig.available;
    }

    static getToggleStatus ()
    {
        return featureConfig.available;
    }
}

new AdvancedWaypoints()