English
NativeLoader is a compatibility-layer Fabric mod designed to modify game content in languages that can be compiled to native code except Java or Kotlin. It interacts with native code via JNI and JNA, giving native code enough flexibility and minimizing performance overhead.
Use
NativeLoader itself is only responsible for calling native code and providing wrapper classes, and does not modify the game content, you need to use other languages that can be compiled to native code and publish them as dll/so/dylib to actually modify the game
It is often necessary to use third-party libraries when writing code, which can avoid causing Invalid Memory Access by allowing users to interact directly with JNI
Although this is not necessary, we recommend that libraries in other languages provide corresponding Java class bindings to provide a similar programming experience to Java
The currently available library is Mliybs.Minecraft.Fabric for C# NativeAOT
Load your code
Assuming you have made a dll, you need to create a valid resource package in the nativepacks folder of the game directory (if it doesn't exist, the game will automatically create it when it starts running), and place your dll in the assets/arbitrary namespace ID/natives/ directory, for example:

It is important to note that the path and file name must be valid identifiers and can only contain lowercase letters, numbers, and ,.-_ characters
Once done, launch the game and the game will automatically load all dll/so/dylib in the natives path in all namespaces(the resource pack will also be loaded)
If your dll contains code to modify the game, you should be able to see the changes in the game
If your dll is coming from someone else, make sure it's safe
P.S
NativeLoader is currently in the development phase, but the basic functionality is complete
We expect that Mixin is unlikely to add support in the future, but reflection in Java is not limited to this (called directly via JNI functions)
NativeLoader needs more people to help improve it, contributions are welcome!
简体中文
NativeLoader 是一个兼容层 Fabric 模组,旨在通过除 Java、Kotlin 以外能编译成原生代码的其他语言修改游戏内容。它通过 JNI 和 JNA 与原生代码交互,不仅给了原生代码足够的灵活程度还尽可能减少了性能开销。
使用
NativeLoader 本身只负责调用本机的原生代码以及提供包装类,并不会修改游戏内容,你需要使用其他能够编译成原生代码的语言并将它们发布成 dll/so/dylib 才能真正修改游戏
在编写代码的时候往往需要使用第三方库,这能够避免让用户直接与 JNI 交互导致 Invalid Memory Access
尽管这不是必要的,但我们建议其他语言的库提供相对应的 Java 类绑定,尽力提供与 Java 相似的编程体验
目前的可用库有 Mliybs.Minecraft.Fabric,用于 C# NativeAOT
调用你的代码
假设你已经制作好了一个 dll,你需要在游戏目录下的 nativepacks 文件夹(若不存在则游戏在开始运行时会自动创建)中创建一个合法的资源包(这个资源包后续也会用来存放资源),在 assets/任意命名空间ID/natives/ 目录中放置你的 dll,例如:

需要注意的是,路径和文件名必须是合法的标识符,只能包含小写字母,数字,以及
,.-_几个字符
完成后,启动游戏,游戏就会自动加载所有命名空间中 natives 路径下的所有 dll/so/dylib(资源包也会被强制加载)
如果你的 dll 中包含了修改游戏的代码,你应该就能在游戏中看到它的更改了
如果你的 dll 来自其他人,请确保它是安全的
附言
NativeLoader 目前还处于开发阶段,但基本功能已完成
我们预计将来 Mixin 不太可能添加支持,但 Java 中的反射不受此限制(直接通过 JNI 函数进行调用)
NativeLoader 需要更多人来帮助完善,欢迎所有人的贡献!
你是这个资源的作者?登录后可认领此资源。
相似资源
让你能够在世界中的任何位置定位结构。
一堆修复
所有本应存在的事物
为 Cobblemon 添加 Mega 进化、Z 招式、太晶化、超极巨化/超巨大化、究极爆击与融合!
一款适用于你选择的加载器的 Minecraft VR 模组!
TerraFirmaCraft (TFC) 是一个全面转换模组,对生存模式进行了彻底的改造与重新设计。
评论 0
登录后参与评分
还没有评论,来抢沙发吧