Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enjarai/shared-resources
A Minecraft mod to easily share resources between multiple game instances.
https://github.com/enjarai/shared-resources
fabric fabricmc-mod minecraft minecraft-mod mod
Last synced: 3 months ago
JSON representation
A Minecraft mod to easily share resources between multiple game instances.
- Host: GitHub
- URL: https://github.com/enjarai/shared-resources
- Owner: enjarai
- License: lgpl-3.0
- Created: 2022-08-10T19:24:56.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T14:32:04.000Z (4 months ago)
- Last Synced: 2024-10-01T08:21:46.203Z (3 months ago)
- Topics: fabric, fabricmc-mod, minecraft, minecraft-mod, mod
- Language: Java
- Homepage: https://www.curseforge.com/minecraft/mc-mods/shared-resources
- Size: 404 KB
- Stars: 31
- Watchers: 1
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Shared Resources
[![Mod Loader](https://img.shields.io/badge/Mod%20Loader-Fabric-lightyellow?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFHGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20ve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mZjhjLWU0NDEtOTMxZi00OTVkNGYxNGM3NjAiIHN0RXZ0OndoZW49IjIwMTgtMTItMTZUMTY6NTQ6MTctMDg6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE4IChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4/HiGMAAAAtUlEQVRYw+XXrQqAMBQF4D2P2eBL+QIG8RnEJFaNBjEum+0+zMQLtwwv+wV3ZzhhMDgfJ0wUSinxZUQWgKos1JP/AbD4OneIDyQPwCFniA+EJ4CaXm4TxAXCC0BNHgLhAdAnx9hC8PwGSRtAFVMQjF7cNTWED8B1cgwW20yfJgAvrssAsZ1cB3g/xckAxr6FmCDU5N6f488BrpCQ4rQBJkiMYh4ACmLzwOQF0CExinkCsvw7vgGikl+OotaKRwAAAABJRU5ErkJggg==)](https://fabricmc.net)
![Enviroment](https://img.shields.io/badge/Enviroment-Client-purple)
[![Discord](https://img.shields.io/discord/1016206797389975612?color=blue&logo=discord&label=Discord)](https://discord.gg/WcYsDDQtyR)[![Modrinth](https://img.shields.io/modrinth/dt/shared-resources?color=00AF5C&label=downloads&logo=modrinth)](https://modrinth.com/mod/shared-resources)
[![CurseForge](https://cf.way2muchnoise.eu/full_679045_downloads.svg)](https://curseforge.com/minecraft/mc-mods/shared-resources)A mod for easily sharing game files between separate Minecraft instances.
Best used with a multi-instance launcher like [MultiMC](https://multimc.org/) or [Prism Launcher](https://prismlauncher.org/).It works by selecting a global directory to hold your common game files,
and modifying Minecraft to use that directory instead of the default one.
Where possible, the mod tries to load files from the global directory together
with the local ones, merging the two and allowing you to select from both.
This is currently only available for resource packs, data packs and shaders.Currently supported game files/directories:
- Resource packs
- Data packs
- Saves
- Vanilla options (video settings, controls, etc.)
- Servers
- Screenshots
- Saved Hotbars
- The fabric config folder (should work with the configs of any properly coded mods)
- Shader packs (via Iris)
- Schematics (via Litematica)
- Replay Recordings (via ReplayMod)
- Skin Presets (via SkinShuffle)
- World Map Data (via Xaero's World Map)Incorporates code from [RememberMyTxt](https://github.com/DuncanRuns/RememberMyTxt)
(with permission from [DuncanRuns](https://github.com/DuncanRuns))
to ensure game options aren't lost when sharing the options.txt file
between different game versions and mod sets.## API
A robust API is available for other mods to use, allowing them to easily
add support for their own game files and directories.To make use of the API, first add it as a dependency in gradle.
It's recommended to include the API as a JiJ dependency as well,
as the file size is small, and it doesn't do anything without the main mod present.
You can also use it without JiJ'ing, but you'll have to make sure you only
interact with API classes when the main mod is present.```groovy
repositories {
maven {
url "https://maven.enjarai.nl/releases"
}
}dependencies {
modImplementation include("nl.enjarai:shared-resources-api::[VERSION]")
}
```As the version, use the latest version from the [releases page](https://github.com/enjarai/shared-resources/releases)
Then, you'll want to create a Shared Resources entrypoint in your mod's `fabric.mod.json`:
```json
{
"entrypoints": {
"shared-resources": [
"com.example.modid.GameResources"
]
}
}
```Make sure to implement the `SharedResourcesEntryPoint` interface in your entrypoint class,
and use that to create and register your `GameResource` instances, each corresponding to a game file or directory.
**This entrypoint is run during fabric's preLaunch phase, limit your interaction with Minecraft classes to a minimum.**```java
public class GameResources implements SharedResourcesEntrypoint {
// You can manually implement these interfaces, but a builder is provided for convenience
public static final ResourceDirectory MY_CUSTOM_DIRECTORY = new ResourceDirectoryBuilder("custom_directory")
.setDisplayName(Text.translatable("modid.directory.custom_directory"))
.setDescription(
Text.translatable("modid.directory.custom_directory.description[0]"),
Text.translatable("modid.directory.custom_directory.description[1]")
)
.requiresRestart() // Set this if the directory requires a restart to take effect
.overridesDefaultDirectory() // Set this if the directory completely overrides the default one
.defaultEnabled(false) // You can probably guess what this does
.isExperimental() // Set this to warn the user that issues may arise
.build(); // For a comprehensive list of the available options, see the javadocs
public static final ResourceFile A_CUSTOM_FILE = new ResourceFileBuilder("custom_file")
.setDisplayName(Text.translatable("modid.file.custom_file"))
.build();
@Override
public void registerResources(GameResourceRegistry registry) {
// Don't forget to register your resources
registry.register(new Identifier("modid", "custom_directory"), MY_CUSTOM_DIRECTORY);
registry.register(new Identifier("modid", "custom_file"), A_CUSTOM_FILE);
}
}
```After registering your resources, they will automatically show up in the main mod's config screen, if it is loaded.
Finally, you can use `GameDirectoryHelper` to get the path to the location of your resource when loading it:
```java
// If a global directory is selected, this will return the path to the global directory
Path dirLocation = GameDirectoryHelper.getPathFor(GameResources.MY_CUSTOM_DIRECTORY);// Make sure to check if its null before using it
if (dirLocation != null) {
loadYourStuffFunction(dirLocation);
}
// Try to load from your default directory as well when possible
loadYourStuffFunction(GameResources.MY_CUSTOM_DIRECTORY.getDefaultPath());
```## License
This mod is under the [GNU Lesser General Public License v3.0](LICENSE).