Framework

Framework

77234970 次下载
最近更新9 个月前
为 MrCrayfish 的所有模组提供动力的一个通用库 A common library powering a...

 

📙 关于:

Framework是一个旨在辅助多平台模组开发的库,包含注册系统、网络消息等功能。此外,Framework还具备更多特性,能进一步挖掘模组开发的潜力,具体内容如下。

🚀 开放模型格式

开放模型格式是对原版JSON方块模型格式的扩展。它消除了设计方块模型时的一些随意限制,这意味着现在你可以将元素旋转到任意角度,而不必以22.5度为增量。它还允许元素的定位和尺寸超出[-16, -16, -16]到[32, 32, 32]的最大界限。以下是一个在载具模组中使用的直升机模型示例。

🔑 同步数据键

同步数据键是对Minecraft实体数据访问系统的改进。它允许你在无需编写复杂能力的情况下,为任何实体附加额外数据。使用Framework的同步数据键的好处在于它所提供的强大功能。正如其名称所示,数据可以自动同步到客户端;这意味着你无需处理数据包。数据可以保存到实体上,这样在世界重载或服务器重启时也能保留。与Minecraft的系统不同,Framework增加了一个选项,允许你的数据在实体死亡后仍然保留,而不是重置为默认值。还不信?看看下面的示例,感受一下这个系统多么简单却又强大。

一个记录玩家击打鸡的次数的示例。

// 创建一个同步数据键 private static final SyncedDataKey HIT_COUNT = SyncedDataKey.builder(SyncedClassKey.CHICKEN, Serializers.INTEGER) .id(new ResourceLocation("your_mod_id", "hit_count")) .defaultValueSupplier(() -> 0) .saveToFile() .syncMode(SyncMode.TRACKING_ONLY) .build(); // 在通用设置中调用此方法 FrameworkAPI.registerSyncedDataKey(HIT_COUNT); // 玩家攻击实体时的Forge事件 void onHitEntity(AttackEntityEvent event) { if(event.getTarget() instanceof Chicken chicken) { int newCount = HIT_COUNT.getValue(chicken) + 1; HIT_COUNT.setValue(chicken, newCount); } }

📦 简易登录数据包

Forge允许开发者创建登录数据包,但实现起来需要大量代码。Framework将所需代码浓缩为一个简单的注册方法,并会处理将你的数据发送到客户端的操作。

📔 开发者:

通过阅读此处的功能介绍,了解Framework如何对你的开发有益。

🙋‍♀️ 需要支持?加入官方Discord服务器:

评论区不太适合获取支持,加入官方Discord服务器吧。你可以获得安装和配置模组、解决崩溃等方面的帮助!此外,你还能抢先获取模组更新和开发的消息(比其他任何地方都早)。


 

📙 About:

Framework is a library designed to aid in the development of multi-platform mods, containing systems for registration, network messages, and more. In addition, Framework contains additional features to further unlock the potential of modding, which can be read below.

🚀 Open Model Format

Open Model Format is an extension to Vanilla's JSON Block Model format. It removes the arbitrary restrictions placed on designing block models, this means you can now rotate an element to any angle instead of  22.5 increments. It also allows elements to be positioned and sized larger than the maximum bounds [-16,-16, -16] to [32, 32, 32]. Below is an example of a helicopter model used in a vehicle mod.

🔑 Synced Data Keys

Synced Data Keys are an improvement of Minecraft's entity data accessor system. It allows you to attach additonal data to any entity without the need of writing a complex capability. The benefit of using Framework's Synced Data Keys is the powerful features it provides. As mentioned by in the name, the data can be automatically synced to clients; this means you don't have to deal with packets. The data can be saved to the entity so it's remembered across world reloads or server restarts. Unlike Minecraft's system, Framework adds an option to allow your data to persist across deaths instead of being reset back to it's default value. Not convinced yet? Check out the example below to see how simple but powerful this system is.

An example of keeping track of how many times a chicken has been hit by players.

// Creating a synced data key private static final SyncedDataKey HIT_COUNT = SyncedDataKey.builder(SyncedClassKey.CHICKEN, Serializers.INTEGER) .id(new ResourceLocation("your_mod_id", "hit_count")) .defaultValueSupplier(() -> 0) .saveToFile() .syncMode(SyncMode.TRACKING_ONLY) .build(); // Call this in your common setup FrameworkAPI.registerSyncedDataKey(HIT_COUNT); // Forge event for when a player attacks an entity void onHitEntity(AttackEntityEvent event) { if(event.getTarget() instanceof Chicken chicken) { int newCount = HIT_COUNT.getValue(chicken) + 1; HIT_COUNT.setValue(chicken, newCount); } }

📦 Easy Login Packets

Forge has the ability to allow developers to create login packets, however implementing it requires a significant amount of code. Framework condenses the required code into a simple registration method and will handle sending your data to clients.

📔 Developers:

Discover how Framework can be beneficial to your development by reading about it's features here.

🙋‍♀️ Need Support? Join the Official Discord Server:

The comment section isn't great for support, join the official discord server. You can get help installing and configuring mods, resolving crashes and more! Plus you'll also get access to news about mod updates and development (before anywhere else).

本站是资源分享站,资源均来自于互联网和用户自发分享,仅供学习和交流使用。如有版权问题,请联系管理员删除。

评论区 (0)

登录 后才能发表评论

暂无评论

快来发表第一条评论吧!