一个用于 Fabric 模组的自动内容加载器。
用法
若要直接使用 Lodestone, 请确保你 将其作为模组的依赖项。 本模组本身不添加任何内容。
Lodestone 提供了基本的接口和 API,
以便在初始化期间轻松注册模组内容。
其中最重要的类型是 Loaded 接口,
整个模组都是围绕它构建的。
有关基本示例,请参阅 Cheese 模组。
要创建自动注册的类型, 只需实现目标环境的相关接口即可。
/** 在运行时加载的物品。 */
public class LoadedItem extends Item implements CommonLoaded {
// `Loaded` 的所有实例都需要此方法。允许 Lodestone 按模组标识符对已注册的值进行分组。
@Override
public Identifier getLoaderId() {
return Identifier.of(YourMod.MOD_ID, "your_item");
}
// 在运行时注册该值的函数。
@Override
public void loadCommon() {
Registry.register(Registries.ITEM, this.getLoaderId(), this);
}
}
每个模组环境都有其专用的接口:
CommonLoaded在“通用”环境中加载值,即同时在客户端 和 服务器上加载。ClientLoaded仅 在客户端实例上加载值。ServerLoaded仅 在服务端实例上加载值。DataGenerating仅 在 Fabric 的数据生成任务期间加载值。
这些接口旨在在各模组的初始化程序中使用,以正确加载内容。
public class YourMod implements ModInitializer {
public static final String MOD_ID = "your_mod";
public static final LoadedItem YOUR_ITEM = new LoadedItem(new Settings());
@Override
public void onInitialize() {
// 注册此物品以供后续加载。
Lodestone.register(CommonLoaded.class, YOUR_ITEM);
// 然后在下面执行加载操作。
Lodestone.load(CommonLoaded.class, MOD_ID);
}
}
Lodestone 还提供了一个抽象类和两个注解,用于值的自动注册。
public final class ItemLoader extends AutoLoader {
@LoadingPriority(-1) // 控制加载顺序。在这种情况下,此项最后加载。
public static final LoadedItem ITEM_1 = new LoadedItem("item_1", new Settings());
public static final LoadedItem ITEM_2 = new LoadedItem("item_2", new Settings());
public static final LoadedItem ITEM_3 = new LoadedItem("item_3", new Settings());
public static final LoadedItem ITEM_4 = new LoadedItem("item_4", new Settings());
public static final LoadedItem ITEM_5 = new LoadedItem("item_5", new Settings());
@IgnoreLoading({ }) // 阻止此值被加载。
public static final LoadedItem NULL = null;
@Override
public Identifier getLoaderId() {
return Identifier.of(YourMod.MOD_ID, "items");
}
}
其注册方式非常相似。
public class YourMod implements ModInitializer {
public static final String MOD_ID = "your_mod";
public static final ItemLoader ITEMS = new ItemLoader();
@Override
public void onInitialize() {
// 注册所有物品以供后续加载。
ITEMS.register();
// 然后在下面执行加载操作。
Lodestone.load(CommonLoaded.class, MOD_ID);
}
}
依赖 Lodestone
Lodestone 的唯一用途是作为其他模组的库使用。 如果你想让你的 Fabric 模组依赖 Lodestone, 请在你的 Gradle 清单中添加以下内容:
# gradle.properties
lodestone_version = 1.8.0
// build.gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
modImplementation "com.github.Jaxydog:Lodestone:${project.lodestone_version}"
// 或者,选择性地依赖最新的提交版本:
modImplementation 'com.github.Jaxydog:Lodestone:main-SNAPSHOT'
}
Lodestone 应该 能兼容许多较旧版本的 Minecraft, 但只有最新版本的游戏能保证获得适当的支持。 我目前不打算向后移植到大约 1.18 之前的版本, 但如果你遇到任何问题,欢迎随时告知我。
An automatic content loader for Fabric mods.
Usage
In order to use Lodestone directly, please ensure that you add it as a dependency for your mod. This mod does not add any content by itself.
Lodestone provides basic interfaces and APIs for
easily registering modded content during initialization.
The most important type provided is the Loaded interface,
which the mod is built around.
For a basic example, see the Cheese mod.
To create an automatically registered type, simply implement the target environment's associated interface.
/** An item that is loaded at runtime. */
public class LoadedItem extends Item implements CommonLoaded {
// Required for all instances of `Loaded`. Allows Lodestone to group registered values by mod identifier.
@Override
public Identifier getLoaderId() {
return Identifier.of(YourMod.MOD_ID, "your_item");
}
// A function that registers the value at runtime.
@Override
public void loadCommon() {
Registry.register(Registries.ITEM, this.getLoaderId(), this);
}
}
Each mod environment has its own dedicated interface:
CommonLoadedloads the value on the "common" environment, meaning both the client and the server.ClientLoadedonly loads the value on the client instance.ServerLoadedonly loads the value on the server instance.DataGeneratingonly loads the value during Fabric's data generation task.
These are intended to be used within each mod initializer to load it properly.
public class YourMod implements ModInitializer {
public static final String MOD_ID = "your_mod";
public static final LoadedItem YOUR_ITEM = new LoadedItem(new Settings());
@Override
public void onInitialize() {
// Registers this item for later loading.
Lodestone.register(CommonLoaded.class, YOUR_ITEM);
// Which is then done here.
Lodestone.load(CommonLoaded.class, MOD_ID);
}
}
Lodestone also provides an abstract class and two annotations for automatic registration of values.
public final class ItemLoader extends AutoLoader {
@LoadingPriority(-1) // Controls the loading order. In this case, this loads last.
public static final LoadedItem ITEM_1 = new LoadedItem("item_1", new Settings());
public static final LoadedItem ITEM_2 = new LoadedItem("item_2", new Settings());
public static final LoadedItem ITEM_3 = new LoadedItem("item_3", new Settings());
public static final LoadedItem ITEM_4 = new LoadedItem("item_4", new Settings());
public static final LoadedItem ITEM_5 = new LoadedItem("item_5", new Settings());
@IgnoreLoading({ }) // Prevents this value from being loaded.
public static final LoadedItem NULL = null;
@Override
public Identifier getLoaderId() {
return Identifier.of(YourMod.MOD_ID, "items");
}
}
This is then registered in a very similar way.
public class YourMod implements ModInitializer {
public static final String MOD_ID = "your_mod";
public static final ItemLoader ITEMS = new ItemLoader();
@Override
public void onInitialize() {
// Registers all items for later loading.
ITEMS.register();
// Which is then done here.
Lodestone.load(CommonLoaded.class, MOD_ID);
}
}
Depending on Lodestone
Lodestone's sole purpose is to be used as a library for other mods. If you would like to depend on Lodestone for your Fabric mod, add the following to your Gradle manifest:
# gradle.properties
lodestone_version = 1.8.0
// build.gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
modImplementation "com.github.Jaxydog:Lodestone:${project.lodestone_version}"
// Or, to alternatively depend on the most recent commit:
modImplementation 'com.github.Jaxydog:Lodestone:main-SNAPSHOT'
}
Lodestone should work with many older versions of Minecraft, but only the latest game version is guaranteed to have proper support. I am currently not interested in backporting to versions prior to roughly 1.18, but if you encounter any issues feel free to let me know anyway.
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Lodestone
下载 Lodestone
下载 Lodestone
为与 AutoLoaders 配合使用而创建额外的类。
内容变更
- 添加了
AutoLoaded类;这是一个包装器,提供了将加载函数应用于泛型类型的 API。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
适用于 MC 1.18+ 的 Effekseer 加载器
评论 0
登录后参与评分
还没有评论,来抢沙发吧