Scarpet additions

Scarpet additions

Adds some miscellaneous new functions like http requests to the scarpet language

by
4.2K Downloads
fabriclibraryutility
Rent Server with this Mod

About this Mod

scarpet-additions

Available for fabric
See me on GitHub
Available on Modrinth
Chat on Discord

scarpet-additions

A Carpet mod extension for some additional scarpet functions

Reqires Carpet mod

Functions

convert_color(color,model,output)

Converts a color from one model to another.

color -> List: Depending on specified model

model -> String: Input color model, can be RGB, RGBA or HSB

  • RGB: List of a red, green and blue value
  • RGBA: List of a red, green, blue and alpha value
  • HSB: List of a hue, saturation and brightnes value

output -> String: Output color model, can be RGB, RGBA, HEX or NUM

  • RGB: List of a red, green and blue value
  • RGBA: List of a red, green, blue and alpha value
  • HEX: String of hex characters (without leading '#') Can be used for format()
  • NUM: Number representing the color as 4 bytes: 0xRRGGBBAA. Can be used for 'color' parameter in draw_shape()

Examples:

convert_color([255,128,0],'rgb','hex'); -> 'FF8000'

convert_color([255,128,0],'rgb','num'); -> 0xff7f00ff

convert_color([0,255,255],'hsb','hex'); -> 'FF0000'

convert_color([120,255,255],'hsb','hex'); -> '00FF00'

Example:

__on_tick() -> (
    if((tick_time() % 2) == 0,
        headerHue = tick_time()%360;
        headerGlossIndex = (floor(tick_time()/3)%40)-10;
        header = [];
        title = 'MinecraftServer';
        for(range(length(title)),
            if(abs(_-headerGlossIndex) < 3,
                c = convert_color([headerHue,abs(_-headerGlossIndex)/3*255,255],'hsb','hex');
            ,
                if(_ < 7,
                    c = convert_color([headerHue,255,190],'hsb','hex');
                ,
                    c = convert_color([headerHue,255,255],'hsb','hex');
                );
            );
            put(header,null,str('b#%s %s',c,slice(title,_,_+1)));
        );
        header = format(header);
        footer = format('r to the server!');
        set_tab_text(header,footer);
  )
);

http_request(options)

Performs a http request specified by the given options.

This call is blocking, so you should use it in a task()!

The options parameter is a map value with the following keys:

  • uri (String): The URI to request from
  • method (String, optional): The http request method. For example GET, POST, DELETE,... Defaults to GET
  • headers (Map, optional): Each map entry is a string key pointing to a string, or list of strings
  • body (String): The body for POST or other requests

The function returns a map with the following entries:

  • status_code (number): The status code of the request
  • body (String): The body returned from the request
  • headers (Map: string -> [strings]): The received response headers
  • uri (String): The originally requested URI

Note that the response body is not parsed as json or html escaped.
Use the escape_html and unescape_html functions,
as well as the scarpet-builtins encode_json and decode_json.

Example usage:

// simple get request and parsing

response = http_request({
    'uri'->'https://opentdb.com/api.php?amount=1'
});

print('Response: ' + response);

if(response:'status_code' != 200,
    print('Request failed: ' + response:'status_code');
,
    body = decode_json(response:'body');
    print('\n\nBody: ' + body);

    question_data = body:'results':0;
    question = unescape_html(question_data-blocked:'question');
    answer = unescape_html(question_data-blocked:'correct_answer');

    print('\n\n\n' + question + '\n' + answer);
);

escape_html(html)

Returns the escaped html string (e.g. " -> &quot;)

unescape_html(html)

Returns the unescaped html string (e.g. &quot; -> ")

list_text(header, footer, player?)

Sets header and footer in tab menu of all players, or changes it for one player if player? is given.

set_motd(motd)

Sets the message of the day of the server.

Available Versions

1.1.4release
MC 26.1, 26.1.1, 26.1.2, 26.2fabric
April 8, 2026
1.1.3release
MC 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, 1.21.8fabric
October 27, 2024
1.1.2release
MC 1.20.5, 1.20.6, 1.21, 1.21.1fabric
April 23, 2024
1.1.1release
MC 1.20.4fabric
December 12, 2023
1.1.0release
MC 1.20, 1.20.1, 1.20.2fabric
June 7, 2023

How to Install Scarpet additions on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (26.2).

3

Install Mod

Open the mod browser in the dashboard and search for "Scarpet additions". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

fabric

Minecraft Versions

26.2, 26.1.2, 26.1.1 (+18 more)

Server-side

Required

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

Scarpet additions server crashes on startup – what to do?

Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (26.2). You can switch loaders with one click in the panel.

Is Scarpet additions compatible with fabric?

Scarpet additions officially supports fabric for Minecraft 26.2, 26.1.2, 26.1.1. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with Scarpet additions – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if Scarpet additions consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install Scarpet additions with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Required

Supported Versions

26.226.1.226.1.126.11.21.81.21.71.21.61.21.51.21.41.21.3+11 more