Respackopts/README.md

58 lines
4.3 KiB
Markdown
Raw Normal View History

# Respackopts
Respackopts provides resource packs with config menus\
By default it integrates with frex (canvas shaders, currently requires the latest development release) and provides a custom system for conditional resources\
2021-03-05 07:58:56 +01:00
An example for the frex/canvas integration can be found [here](https://gitlab.com/jfmods/respackopts/-/tree/master/run/resourcepacks/lumi)
# Using Respackopts
## Users
2020-11-26 21:14:56 +01:00
You will just need to install Respackopts. A menu button will appear besides all supported resourcepacks.\
2021-03-05 07:58:56 +01:00
You can get the latest debug build [here](https://gitlab.com/jfmods/respackopts/-/jobs/artifacts/master/raw/latest.jar?job=build_test) and the latest stable build [here](https://modrinth.com/mod/respackopts)
## Resource pack authors
2021-03-05 07:58:56 +01:00
You will need to define a respackopts conf as seen [here](https://gitlab.com/jfmods/respackopts/-/blob/master/run/resourcepacks/lumi/assets/respackopts/conf.json)
This config may include:
- boolean values, expressed as Json bools
- number values, expressed as Json numbers
- slider-based numeric values, expressed as a json object containing only the fields `default`, `min` and `max` and only whole numbers
- string values (not accessible from default integrations), expressed as Json strings
- enums, expressed as Json arrays containing simple strings
- subcategories expressed as json objects. These must meet the same constraints as the root config
You can also provide translations/more complex names for your resource pack's configs.\
The following things can be changed:
- Entry names: `respackopts.field.{packId}.{entryId}`
2020-12-29 11:19:21 +01:00
- Category titles: `respackopts.title.{packId}`
- Tooltips: `respackopts.tooltip.{packId}.{entryId}`
In subcategories, you can use `{packId}.{categoryId}` instead of `{packId}`
2020-11-26 21:14:56 +01:00
Please note that translations require your resource pack to be loaded.
The version property defines the format version. It will be incremented if changes to the layout of the config are made\
I will likely attempt to support older versions if I decide to make an incompatible change.\
To use the information from the config you will need to use and integration module/plugin.\
For the ones included by default:
### Canvas
Respackopts defines a config supplier, you can include it with `#include respackopts:config_supplier`\
You can always check whether it was properly loaded by checking if `respackopts_loaded` is defined.\
Values can be accessed with `{packId}_{entryId}` for basic elements.\
Enum values can be accessed as booleans expressing whether the specified entry is selected with `{packId}_{entryId}_{enumKey}`.\
2021-03-05 07:58:56 +01:00
Examples of using these are available [here](https://gitlab.com/jfmods/respackopts/-/tree/master/run/resourcepacks/lumi)
### Conditional resources
Respackopts allows creating conditional resources by creating a file named `{targetFile}.rpo`.\
This file is a json file that contains an array named "conditions". The resource will be ignored if any of the conditions are not met.\
This allows (for example) overrides for textures to only be loaded if the user enables them through the config.\
2021-02-15 11:44:59 +01:00
It also allows the following operations: `and`, `equal`, `nor`/`not`, `or`, `xor`.\
2021-03-05 07:58:56 +01:00
An example can be seen [here](https://gitlab.com/jfmods/respackopts/-/tree/master/run/resourcepacks/lumi/assets/minecraft/lang)
2021-02-15 11:44:59 +01:00
### Fallback resources
Respackopts allows creating fallbacks for resources if they are unavailable/disabled.\
2021-02-16 14:21:37 +01:00
To do this, create a "fallbacks" entry in a files .rpo containing every possible fallback file as a string in an array.\
2021-02-15 11:44:59 +01:00
Use this in conjunction with the conditional resources feature in order to create multiple options for a single texture.\
2021-02-16 14:21:37 +01:00
A simple example can be seen [here](https://gitlab.com/jfmods/respackopts/-/blob/master/run/resourcepacks/lumi/assets/minecraft/lang/de_de.json.rpo)
## Mod developers
All entry types extend the common ConfigEntry class and implement sevaral methods. The main config element can be found in Respackopts.CONFIG_BRANCH
and will always be a config branch (an element containing sub-elements).\
If you need code to be ran after changes are made to the state, add an action to `saveActions`.\
2020-11-26 21:14:56 +01:00
This is currently used for the Canvas/FREX integration, which uses it to generate shader code.\
2021-02-16 14:21:37 +01:00
The config GUI is currently generated using cloth config. The config icon ís loaded from ModMenu. It will not display if that is not loaded.