Silver Star Library

Quick rating

Community listing page, reviews here may not be monitored by the author.

Silver Star Library

No reviews yet

A library for Minecraft Datapack developers, that adds pre-established scores, predicates, and modules to simplify development. Also includes a framework for custom potion effects.

Mod Loaders
Minecraft
26.2

About

Description

Silver Star Library is a development tool for datapack creators. It was originally a library I created for my own use, but its usage is not specifically catered to my own projects, and can be used across a wide variety of applications.

Please note!

For many features of SSL, you will be required to invoke the ss_lib:_pre_function and ss_lib:_post_function functions. These files are designed to be run before all other functions, and after all other functions, respectively. I achieve this by having a "core" module which invokes these functions at the proper time, but do it however you like.

This datapack is offered "as-is". I make no guarantees about the robustness or legibility of included code. Updates and patches will be offered as long as I continue to work on the project.

Features

Elixir Framework / Custom Potion Effects

Elixir adds the ability to create fully custom potion effects, and it's designed to be compatible with your datapack, so you don't actually have to mess with any of the code in Silver Star Library (feel free to if you want to). More information on Elixir will be below, as it requires quite a lot of explanation.

Scores / Smart Score "Fetching"

SSL adds a wide array of scores that cover entity data, condition, location, and more. These scores can be called as needed through a group of "fetch" functions, which have a built-in check for whether they've already been called in the same tick. This drastically increases efficiency compared to calculating scores every tick, because it allows scores to only be calculated when necessary, and means that there won't be redundant calculations.

Generic Scores

SSL also adds ten "generic" scores, along with basic integer scores. "generic" scores are meant to be assigned and used in a single function, as they act just as temporary, placeholder scores. The basic integer scores are used for basic arithmetic operations, again, to cut down on the amount of extraneous, single-use scoreboard objectives.

Quick Destroy Items

SSL adds in a module that allows items to be designated as "quick destroy" items. These items, when dropped on the ground, will disintegrate after five seconds.

Items are designated as Quick Destroy just by adding quick_destroy:true to the custom item data.

Particles

SSL adds in a Particles module, which is just a group of preset particle effects. Most of these effects come from my personal projects, so there's not much of a theme to them. However, they are used for the Quick Destroy module.

Score Parse Module

The Score Parse Module is a sub-module of SSL that takes a macro input of a scoreboard objective and a function, and outputs the value of the scoreboard objective into the target function, as a macro. For example, if a player has a Test score of 50, and they want their maximum health attribute to always match their Test score, the Score Parse Module can read their score and output a string of "50" into the target function. SPM also has the ability to prepend, append, and insert special characters, allowing scores to be converted to floats.

In essence, the Score Parse Module is used to convert scores into macro strings.

A full breakdown of SPM is in a README file in its functions folder.

Raycast Module

The Raycast module adds a group of functions for creating raycasts, for instant straight-line block or entity detection. It allows input of how far the raycast should travel, the integer between each raycast node, and the target block, entity, or both. If the raycast succeeds, and detects the target, it will then run the function the developer specifies.

A full breakdown of the Raycast module is in progress, but feel free to DM me on Discord (@skeleton.toast) if you have any questions.

Rounding Module

The Rounding module is used to increase precision of scores when they're divided. By default, Minecraft will always round scores down to the nearest integer. However, the Rounding module will properly round these values instead of rounding them down every time.

The rounding module is pretty straight forward. It takes one input parameter, "score" which is the scoreboard objective that will be rounded for the executing entity.

Run Module

The Run module is a developer tool for discreet command execution, and easy command repetition. The Run module allows you to specify what command to run and how many times to run it, and in any server console or chat log, the only message displayed will be that the Run function was called. The specific command that was run will not be displayed.

The Run module takes two input parameters, "f" and "r". "f" is the full command to run, and "r" is the amount of times to run it.

Auto-Whitelist

The Auto-Whitelist function is a way to prevent developers from accidentally banning, blacklisting, or de-oping themselves from a server. It can be found in the ss_lib:_load function. Replacing the template username with your username will ensure that your account continues to have the correct permissions tied to it.

SSID

The Silver Star Identifier, or SSID, is a numerical value that is assigned to entities, that essentially gives them a UUID that can be interacted with like a score. SSIDs are an evolution on the previous URID system, and as such, they replace URIDs, which are no longer supported. An SSID is a 9-digit number assigned upon request to any entity, which is stored as a scoreboard value, and cannot be used more than once, EVER, PER WORLD. They're assigned by running the following function as the entity to be assigned:

ssid:assign

SSIDs are meant to be used as a scoreboard-based identifier for entities, which also allows global data storage on a per-entity basis. If you pass their SSID through the Parse module, and use that to create/access a data storage location, this allows for complex (as in more than just scoreboards) storage, that will only be accessed by the right entity.

SSIDs also support some fun developer features:

ssid:request ssid:reserve ssid:reset

Request is used to request a specific number, if you as a developer have a number you like to use. Some numbers, including 1-99 and a couple others, have been reserved by default, for myself and some close friends. Using ssid:request with the {"ssid":""} macro, and inputting your requested SSID, will either assign it to you, or return an error if it's already in use/reserved.

Reserve is used to reserve an SSID for an entity that may not currently exist. It takes two input macros: "player" and "ssid". "player" is typically a player's UUID, and "ssid" is self explanatory.

Reset will remove the SSIDs of all currently existing entities with the specified SSID, and will remove that SSID from the log of used SSIDs, allowing it to be used again later. This will remove the record of that SSID having been used, so only use this if you are CERTAIN that SSID is not in use.

Elixir / Custom Potion Effects (Cont'd)

Elixir is a module that sets up the framework necessary for fully custom potion effects, including stacking applications, which is difficult to do with just scores. The Elixir Framework lets you apply an effect at any time, and intelligently orders the active applications so that they match vanilla potion effects, e.g., the application with the highest amplifier is the one that's prioritized.

Elixir is written in a way so that it can be easily accessed and used by other datapacks, without having to write anything in the Silver Star Library itself. In order to add your own custom potion effect, you need to create two functions:

  1. The function that is run on entities which have the custom effect active
  2. The function that is run when an application expires For example, one of the preset effects, or "statuses" for clarity, is called Lightweight. The active function applies attributes that reduce gravity and knockback resistance, and the expire function removes these attributes.

YOU WILL ALSO NEED TO RUN TWO PREMADE FUNCTIONS: elixir:custom/load_status and elixir:custom/tick_status. As the names indicate, load_status only needs to be run once, and it creates all the scores necessary to run your custom effect, and tick_status MUST be run on every tick (or the status timer will be inaccurate).

elixir:custom/load_status takes two input parameters: source and status. source should be the name of YOUR datapack, or a nickname, anything that will identify where the status is defined. For example, the premade statuses use elixir as the input for source. status, on the other hand, should be the name of the effect itself; for example, lightweight or frostbite or whatever. IMPORTANT: Both of these input parameters must have valid characters for the purpose of creating scoreboard objectives. Essentially, no spaces, and no custom characters that you couldn't have in the name of another scoreboard objective. The scores created use the format of $(source).$(status).score, so just keep this in mind.

elixir:custom/tick_status takes four input parameters: source, status, status_function, and expire_function. source and status are used identically to how they're used in elixir:custom/load_status. status_function is the name of the function that contains the actual effects of your custom potion effect. For example, the premade status "lightweight" uses elixir:status/lightweight/main for its status function. The status function will be run on every tick for every entity that has an active application of your status. expire_function is the name of the function that will be run whenever an application expires, INCLUDING when a higher-amplifier application expires and is replaced by a lower-amplifier application. This should include any code that is run, well, whenever an application expires.

And this is all you have to do! Create your status and expire functions for each custom potion effect you want to create, run elixir:custom/load_status on load and elixir:custom/tick_status on every tick, and your potion effect is up and running.

Silver Star Library

This is a project I've been working on for a long time, and I've found it very helpful in my datapack projects. I hope you find it to be just as useful.