Community listing page, reviews here may not be monitored by the author.
Unruled API
No reviews yet
Expands on the vanilla gamerules to add new gamerules types for other mods to use
Forge is a popular mod loader for versions 1.1+ of Minecraft.
Neoforge is a fork of the Minecraft Forge available for versions 1.20.1+ of Minecraft. Many Forge mods are compatible with Neoforge and vice versa.
Fabric is a mod loader for versions 1.14+ of Minecraft, particularly popular for client side and optimization mods.
Quilt is a fork of the Fabric mod loader. Many Fabric mods are compatible with Quilt and vice versa.
Community voices
Reviews
Filters
Click once to include, again to exclude, again to clear
No reviews yet. Be the first to review this project!
Get it on
Available Platforms
Compatibility
Supported Environments
Required on the client. Installing it on the server adds functionality.
Runs entirely on the server. Also works in singleplayer.
Required on the server. Installing it on the client adds functionality.
Varies by version.
About
Project Details
For authors
Embed Badge
If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.
Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.
Identifiers
Platform IDs
About
Description
Unruled API
(for some reason CurseForge doesn't like to properly render the boxed url or code blocks, along other aspects, sorry about that. Don't hesitate to head on to the Modrinth page to see the proper and colored version)
---
Allows to create new form of gamerules, beyond the restrictive vanilla integers and booleans.
Albeit not registering them automatically, this mod allows you to easily create new floating, long, double, string, text and enum-driven gamerules, using the generative static methods of the mc.recraftors.unruled_api.UnruledApi class.
For consistency, methods have also been created to allow instantiating vanilla gamerules.
Example:
public void gamerulesRegistration() {
myGameRule = registerGamerule("my_gamerule", category, UnruledApi.createFloat(1.5));
myOtherGameRule = registerGamerule("my_other_gamerule", category, UnruledApi.createString("some text"));
myLastGameRule = registerGamerule("my_last_gamerule", category, UnruledApi.createBoolean(false, (server, rule) -> {
onLastRuleChange(server, rule);
}));
}
Each rule can also be easily consulted using the IGameRulesProvider interface.
Example:
String value = ((IGameRulesProvider)gamerules).unruled_getString(myStringGameRule);
float aFloat = ((IGameRulesProvider)gamerules).unruled_getFloat(myFloatGameRule);
How to use in your project
You can implement this mod in your project using the Modrinth maven.
Don't hesitate to read the official documentation.
Need help
Don't hesitate to join our Discord!
Add the Modrinth maven repository
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
<br /><br />
Import the mod
loom example:
dependencies {
// using modApi allows your project's dependents to also import dependencies by default
modApi "maven.modrinth:unruled-api:${project.unruled_version}"
}
forgeGradle example:
dependencies {
implementation "maven.modrinth:unruled-api:${project.unruled_version}"
}
For copyright reasons, we require you to not include (JiJ, jar-in-a-jar, shadow, etc) this mod inside of your own. Thank you for your comprehension.
Unruled API
Allows to create new form of gamerules, beyond the restrictive vanilla integers and booleans.
This mod enables developers to easily create new floating, long, double, string, text, enum-driven,
entity selector and even registry-entry gamerules, using their respective builders,
all available from the com.nerjal.unruled_api.UnruledApi class's static methods.
It also provides means to add value validators alongside registering new gamerules, which in turn allows to restrict the range of valid values for gamerules. For instance, it can be used to only allow odd values in an integer gamerule.
Additionally, this mod also adds per-dimension gamerule overrides! These are applied in their strict dimension (provided they are queried correctly). See gamerules overrides for more details about it.
Gamerules registration
Example:
import com.nerjal.unruled_api.UnruledApi;
public class MyClass {
private static final int STRING_RULE_MAX_LENGTH = 24;
public void gamerulesRegistration() {
var myFloatingRule = UnruledApi.floatRuleBuilder(category, 1.5) // takes the category and the initial value as arguments
// the category determines where in the world creation screen will it be placed
.register("mymod:my_gamerule"); // gamerule registration always takes the gamerule's ID
// the ID also determines the translated name of the gamerule
var myStringRule = new StringRule.Builder(category, "initial value", STRING_RULE_MAX_LENGTH)
// using the UnruledApi methods or directly creating the builder has the same result, and arguments are the same.
// however, mind that in some cases, it is strongly recommended to use the specified builders such as for string
// rules, enum, and dynamic registry entry rules, as they have a more specific processing of their values and
// command handling.
.register("mymod:my_other_gamerule");
}
}
Additionally, quick creation and registration methods have been added for your convenience
import com.nerjal.unruled_api.UnruledApi;
public static void quickGamerulesRegistration() {
var myLongRule = UnruledApi.registerLong(Identifier.of("mymod:my_long_rule"), category, 25L);
// Quick registration methods always follow the same parameter order: name, category, initial value, gamerule-type specific arguments
// Except for enum rules, for which the enum class goes before the initial value
var myEnumRule = UnruledApi.registerEnumRule(Identifier.of("mymod:my_enum_rule"), category, MyEnum.FIRST, MyEnum.class);
}
enum MyEnum {
FIRST,
SECOND,
THIRD
}
For consistency, methods have also been created to allow quickly register vanilla-type gamerules.
import com.nerjal.unruled_api.UnruledApi;
public static void registerBasicRules() {
UnruledApi.registerInteger("my_int_rule", category, 5);
UnruledApi.registerBoolean("my_bool_rule", category, false);
}
You can also retrieve their values using the same class's methods
This has become outdated since release 2.0 (for Minecraft 1.21.11 and later).
Please use the gamerule methods directly as now meant by the game code.
public long getMyLongGamerules(ServerWorld dimension) { // ServerWorld is a Yarn mapping class. Might be Level or ServerLevel with Mojmap
return UnruledApi.getLong(dimension.getGameRules(), myLongGamerule);
}
public Block getMyBlockRule(ServerWorld dimension) {
// querying a registry entry rule returns the registry entry's very value, as it can only be set if it exists in the registry
return UnruledApi.getRegistryEntry(dimension.getGameRules(), myBlockRegistryEntryRule);
}
Command Tweaks
The average experience of using gamerules in vanilla minecraft is pretty poor. Navigating a long list of names, trying to remember the one of the rule you need, or even worse, searching for a hypothetic one, can be pretty annoying.
Thus, Unruled API aims to alleviate that burden ever so slightly, by allowing you to navigate the same list by category!
Hence, you can now add the category name or full ID (both in full caps) in the command and the following list will only contain rules in the appropriate category.
E.g. /gamerule CHAT will then have your game suggest you only the rules inside the
chat category, according to the world creation menu listing.
This also applies to all modded gamerules and categories, as well as modded gamerule types from any and all mod.
/gamerule [<category NAME or FULL ID>] <gamerule name or ID> [<value>]
Gamerules Overrides
Gamerules overrides are set per dimension. They allow players to set specific rules to specific values
in the wanted dimension, all via the gamerule-override command.
This command has many uses:
gamerule-overridealone and with no arguments allows you to get a list of existing overrides in the current dimension.gamerule-override <dimension id>allows you to get a list of existing overrides in the specified dimension.gamerule-override get <gamerule id>allows you to query a potential override for the specified gamerule in the current dimension.gamerule-override set <gamerule id> <value>allows you to set an override for the specified gamerule to the given value in the current dimension.gamerule-override unset <gamerule id>allows you to remove a set override for the specified gamerule in the current dimension.gamerule-override in <dimension id> get <gamerule id>allows you to query a potential override for the specific gamerule in the given dimension.gamerule-override in <dimension id> set <gamerule id> <value>allows you to set an override for the specified gamerule to the given value in the provided dimension.gamerule-override in <dimension id> unset <gamerule id>allows you to remove a set override for the specified gamerule in the provided dimension.
Gamerule overrides are stored in the dimension's data folder, as the gamerules.dat file.
Removing it while the server is offline/world is not being played will simply remove all overrides for the dimension.
Additionally, for your convenience, the get, set and unset in all cases also
support the per-category filtering, for easier usage.
You can thus use the command as follows:
/gamerule-override in <dimension id> set [<category NAME or FULL ID>] <gamerule name or id> <value>
Configurable Default Values
Especially relevant for modpack creators, this feature allows to set custom values to be used as default gamerule values upon world creation.
In order to set them, you only need to create a config/default_gamerules.json file, and for each gamerule you want
to add a default value for, set a key-value pair with the wanted new value, set as a string. (due to limitations in
the mojang code for easy JSON-parsing, only string values are accepted, anything else will simply be ignored)
Example:
{
"doDaylightCycle": "false",
"mobGriefing": "false"
}
Obviously, this works just as well with modded gamerules and gamerule types!
Custom Gamerule Categories
As of 1.21.11, gamerule categories are now a registry. The following is only relevant to game versions prior to this
Developers can easily register new custom gamerule categories, that will be added straight to the category enum! However, you do need it to be done early in the game load process, i.e. before the gamerules class gets loaded.
This can be done on Fabric with a preLaunch entrypoint, on (Neo)Forge upon initializing your @Mod class,
or on any launcher from your mixin config plugin.
You only need to add a CategoryProvider implementation to the UnruledEarlyUtils.CATEGORY_PROVIDERS set.
The CategoryProvider interface is a String supplier-like class, that allows for an optional implementation of a
category consumer upon creation of the matching category. The provided String will be set as the category name, but
will not allow for duplicate entries (i.e. if two mods want to add a same category, only one will be created, but both
providers will receive it as well)
How to use in your project
You can implement this mod in your project using the Modrinth maven. Don't hesitate to read the official documentation.
Add the Modrinth maven repository
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
Import the mod
loom example:
dependencies {
// using modApi allows your project's dependents to also import dependencies by default
modApi "maven.modrinth:unruled-api:${project.unruled_version}"
}
(neo)forgeGradle example:
dependencies {
implementation "maven.modrinth:unruled-api:${project.unruled_version}"
}
For copyright reasons, we require you to not include (JiJ, jar-in-a-jar, shadow, etc) this mod inside of your own. Thank you for your comprehension.
Versions
Files
Relations
Project Relations
More like this
Similar Mods
Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.
On ModDex
Community snapshot
By the numbers
Statistics
Want to reach Minecraft players?
We're looking for a server hosting partner to feature here and other parts of the site. Interested? Send us a message!
Get in touchGet it on
Available Platforms
On ModDex
Community snapshot
By the numbers