用于在 Forge 1.20.1 上使用 NeoForge 1.21.1 特性和方法的库
本模组旨在作为库与其他模组一同使用。目前,唯一的独立功能是模糊的 1.21 风格 GUI 背景。手动安装比打包版本更新的版本仅对修复 bug 有用。
当前功能包括:
- 数据映射(Datamaps)
- 数据组件(Data components)
- 数据附件(Data attachments)
- 流编解码器(Stream codecs)
- 模糊 GUI 背景(通过内置资源包启用)
- 延迟持有者(DeferredHolders)及其子类型
- 1.21.1 风格的网络通信
- 带有编解码器的配方序列化器
- 方块的 useItemOn 和 useWithoutItem 方法
……以及大量便捷接口扩展
常见问题解答
- 为什么要逆向移植到 1.20.1?这难道不比帮助开发者向下移植更有意义吗?
- 制作用于正向移植的库从根本上说是毫无意义的,因为它会带来技术债务,并且每次新版本发布都需要将该库向上移植。即使新特性客观上更好,开发者也不会习惯这些新特性,从而导致模组运行更慢且 bug 更多。这样做可以在满足 1.20 玩家需求的同时,推动他们向新版本过渡。
- 这听起来像是一个 Synitra 连接器类型的模组,它能那样工作吗?
- 理论上,如果我投入大量精力,可能能让非常小的 1.21.1 模组在 1.20.1 上运行,但支持将极其有限,因此不值得花费时间。简而言之:不行。
安装说明
由于本库使用接口注入,因此需要将 ForgeGradle 切换为 ModDevGradle Legacy gradle 插件。文档在此,可用的 MDK 在此。
在 build.gradle 中:
repositories {
// 你可能有的其他仓库...
maven {
url = 'https://nikdo53.github.io'
}
}
dependencies {
// 你可能有的其他依赖项...
jarJar(modImplementation("net.nikdo53:NeoBackports:${neobackports_version}"))
interfaceInjectionData("net.nikdo53:NeoBackports:${neobackports_version}")
}
在 gradle.properties 中:
# 设置为最新版本
neobackports_version=1.4.1
技术差异
由于版本间后端存在差异,功能并非一对一地逆向移植,但对于大多数模组而言,相似性足以使其无需重大修改即可正常运行。
类名
为了区分原始 Forge/原版类和逆向移植的类,逆向移植的类会加上 "neo" 后缀,例如:
- SmithingRecipe -> SmithingRecipeNeo
- PacketDistributor -> PacketDistributorNeo
- DeferredRegister -> DeferredRegisterTyped(这个不同是因为我忘了)
数据组件/附件
与 1.21.1 不同,这些只是现有功能(分别是物品 NBT 和能力系统)的智能包装器,这意味着不使用此 API 的其他模组应能像往常一样访问它们。
数据映射
这些已(经许可)直接从 NeoForge 代码移植而来,差异极小。请注意,握手已知数据映射的登录数据包已被移除,非强制性的一般也不支持。我将来可能会重新考虑这一点,但由于本模组在客户端和服务端都必须安装,它可能并不是很有用(而且 1.20.1 的登录数据包很奇怪)。
流编解码器
由于所有内容都使用 FriendlyByteBuf,因此移除了 ByteBuf 泛型:
StreamCodec<RegistryFriendlyByteBuf, SomeClass> -> StreamCodec<SomeClass>
图标是一只藏狐,它看起来很生气,因为它被迫使用了 Forge。
A library for using neoforge 1.21.1 features and methods on forge 1.20.1
This mod is intended to be used as a library included with other mods. Currently, the only standalone features are blurred 1.21-style gui backgrounds. Manually installing a newer version than is packaged is only useful for fixing bugs
Current features include:
- Datamaps
- Data components
- Data attachments
- Stream codecs
- Blurred gui backgrounds (enabled with a built-in resourepack)
- DeferredHolders (and their subtypes)
- 1.21.1-style networking
- Recipe serializers with codecs
- useItemOn and useWithoutItem methods for blocks
... and a lot of convenience interface extensions
Q&A
- Why backport to 1.20.1? wouldn't it make more sense to help devs port up instead of down?
- Making a lib for foward porting is fundamentally pointless, as it carries technical debt and would require porting the lib up every new version. Devs would never get used to new features, even when they are objectively better, and would make laggier and buggier mods. Doing it this way means we can satisfy the 1.20 crowd while still pushing them towards newer version
- This sounds like a synitra connector type mod, could it work that way?
- Theoretically, if I put a lot of work into it, it could make very tiny 1.21.1 mods run on 1.20.1, but the support would be extremely limited so it's not work the time. TLDR: NO
Installation instructions
Since this lib uses interface injections, switching from ForgeGradle to ModDevGradle Legacy gradle plugin is required. Documentation here and a working MDK here
In build.gradle:
repositories {
// Some other repositories you might have...
maven {
url = 'https://nikdo53.github.io'
}
}
dependencies {
// Some other dependencies you might have...
jarJar(modImplementation("net.nikdo53:NeoBackports:${neobackports_version}"))
interfaceInjectionData("net.nikdo53:NeoBackports:${neobackports_version}")
}
In gradle.properties:
# Set to whatever is latest
neobackports_version=1.4.1
Technical differences
Features aren't backported 1 to 1 (due to backend differences between versions) but should be similar enough for most mods to just work without major differences
Class names
In order to make the difference between original forge/vanilla classes and backported ones, backported classes get the "neo" suffix, for example:
- SmithingRecipe -> SmithingRecipeNeo
- PacketDistributor -> PacketDistributorNeo
- DeferredRegister -> DeferredRegisterTyped (this ones different cuz i forgot)
Data components/attachments
Unlike 1.21.1, these are just clever wrappers for existing features (item nbt and capabilities respectively), meaning that other mods not using this API should be able to access them like normal.
Datamaps
These have been (with permission) ported directly from neoforges code with minimal differences. Note that the login packet which handshaked known datamaps has been removed and non-mandatory are generally not supported. I might return to this in the future, but since this mod is required on both client and server, it's probably not very useful (and 1.20.1 login packets are weird)
Stream codecs
The ByteBuf generic has been removed, since everything uses FriendlyByteBuf:
StreamCodec<RegistryFriendlyByteBuf, SomeClass> -> StreamCodec<SomeClass>
The icon is a tibetan fox, it looks pissed cuz its been forced to use forge
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
下载 NeoBackports
修复了与其他模组回退 NeoForge 数据条件时的崩溃问题
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧