Skip to content

Commit

Permalink
add dynamic-skins command
Browse files Browse the repository at this point in the history
  • Loading branch information
diacritics-owo committed Jul 30, 2024
1 parent fab6adb commit be22ec7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ This configuration will be run once per player rendered per frame.

## Configuration Cache

The configuration is read once on mod initialisation and cached in memory, and updates to it will not be read unless you open the Mod Menu configuration page for Dynamic Skins and click "Reload configuration", upon which it will be read and cached again. Every time you update the configuration, you must reload it for it to apply.
The configuration is read once on mod initialisation and cached in memory, and updates to it will not be read unless you run `/dynamic-skins cache reload`. Alternatively, you can open the Mod Menu configuration page for Dynamic Skins and click "Reload configuration". Every time you update the configuration, you must reload it for it to apply.

## Errors

If an error is encountered when Dynamic Skins executes the configuration, the error and a message stating that Dynamic Skins has stopped will be logged. To start it again, you must open the Mod Menu page (or reopen if it was already open) and click the "Restart" button that should now be visible. Note that restarting will reload the configuration.
If an error is encountered when Dynamic Skins executes the configuration, the error and a message stating that Dynamic Skins has stopped will be logged. You can run the command `/dynamic-skins error` to display the error. To start it again, you must either run `/dynamic-skins error reset` or open the Mod Menu page (reopen if it was already open) and click the "Restart" button that should now be visible. Note that restarting will reload the configuration.

## Custom Skins

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.15.11

# Mod Properties
mod_version=1.0.1
mod_version=1.1.0
maven_group=diacritics.owo
archives_base_name=dynamic-skins

Expand Down
29 changes: 28 additions & 1 deletion src/client/java/diacritics/owo/DynamicSkinsClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
package diacritics.owo;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.text.Text;
import static net.minecraft.server.command.CommandManager.literal;

public class DynamicSkinsClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(literal("dynamic-skins")
.then(literal("cache")
.then(literal("reload").executes(context -> {
DynamicSkins.config.resetCache();
context.getSource().sendFeedback(() -> Text.of("Successfully reloaded configuration cache"), false);
return 1;
})))
.then(literal("error")
.executes(context -> {
context.getSource().sendFeedback(
() -> Text.of(DynamicSkins.dynamicSkinsError == null ? "No errors found"
: DynamicSkins.dynamicSkinsError.toString()),
false);
return 1;
})
.then(literal("reset").executes(context -> {
DynamicSkins.config.resetCache();
DynamicSkins.dynamicSkinsError = null;
context.getSource().sendFeedback(
() -> Text.of("Dynamic Skins has been restarted"),
false);
return 1;
}))));
});
}
}
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"fabricloader": ">=0.15.11",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*",
"fabric-api": "*"
},
"suggests": {
"modmenu": ">=7.2.2"
}
}

0 comments on commit be22ec7

Please sign in to comment.