barrl
Barrl 是一个面向 Minecraft 1.21.x 的 Fabric 渲染库。
API
作为你自己的模组使用此 API 的方法。
首先,我们需要添加 JitPack 仓库以便能够拉取依赖。
build.gradle
repositories {
mavenCentral()
maven "https://jitpack.io"
}
现在前往 JitPack Builds,你可以进入 Branches(分支)并获取所需的分支。一旦找到适合你的版本,点击 Get It 按钮。
接下来怎么做?
在下方页面滚动,它会展示如何“导入”该库。基本上,我们需要再次编辑 build.gradle 文件:
dependencies {
// 要更改版本号,请参阅 gradle.properties 文件
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API。这在技术上是可选的,但你可能仍然需要它。
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
// 添加 Barrl 库
modImplementation "com.github.Synnerz:barrl:1.21.5-SNAPSHOT"
}
你需要在此处添加它。你得到的链接("com.github.Synnerz:barrl:1.21.5-SNAPSHOT")与上述链接所在的页面相同。
使用方法
Barrl 实现了自己的 Events(事件)和 Context(上下文),其中 Context 类是最重要的,因为几乎所有内容都包含在其中。
Context
此类持有渲染所需的一些内容的引用,并提供了一些有用的辅助方法供你在世界中渲染。
Context.Immediate
Immediate 是一个 static(静态)字段,它将基本充当“全局” Context 实例,以便你能在其他上下文中使用它(即使它们并非来自 Barrl)。
注意:此模式要求你在渲染的 几乎 末尾使用它,例如:
WorldRenderEvents.LAST.register {
Context.Immediate?.renderWaypoint(-5.0, -61.0, -3.0, phase = true, color = Color.CYAN)
}
如果你改用 START,将会抛出错误或无法工作。
Context 点方法
这些是添加到 Context 中的辅助方法:
renderFilledShaperenderFilledBoxrenderBoxShaperenderBoxrenderStringrenderBeamrenderWaypoint
WorldRenderEvent
我们也添加了自定义事件,因为以这种方式处理此类库更容易。
这些事件的用法与常规 Fabric 事件的用法相同。
类型
STARTLAST
许可证
Barrl 根据 AGPL 3.0 License 授权。
barrl
Barrl is a fabric rendering library targeted towards minecraft 1.21.x
API
How to use it as an api for your own mod.
First we'll need to add the JitPack repository so we can actually pull from
build.gradle
repositories {
mavenCentral()
maven "https://jitpack.io"
}
Now we head over to the JitPack Builds where you can go into Branches and get the one you need, once you have located the correct one for you, you need to click on the Get It button.
What now?
Below you can scroll in the page, it'll show you how to "import" it, basically we need to edit the build.gradle file once more
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
// Adding Barrl library
modImplementation "com.github.Synnerz:barrl:1.21.5-SNAPSHOT"
}
You need to add it here, you get the link ("com.github.Synnerz:barrl:1.21.5-SNAPSHOT") in the same page that was linked above.
How To Use
Barrl implements its own Events and Context, this Context class is the most important one since everything is basically in there.
Context
This class holds reference to a few things that are required for rendering, as well as providing some helpful helper methods for you to render in the world.
Context.Immediate
Immediate is a static field that will basically act as the "global" Context instance in order for you to be able to use it inside other contexts (even if they don't come from Barrl)
NOTE: This mode requires you to use it at the almost end of a rendering, for example:
WorldRenderEvents.LAST.register {
Context.Immediate?.renderWaypoint(-5.0, -61.0, -3.0, phase = true, color = Color.CYAN)
}
If you use START instead it will throw error/not work
Context dot
These are the helper methods that are added inside of Context
renderFilledShaperenderFilledBoxrenderBoxShaperenderBoxrenderStringrenderBeamrenderWaypoint
WorldRenderEvent
We also add our own events since it's easier to handle a library like this that way
These events are used as regular Fabric events are used.
Types
STARTLAST
License
Barrl is licensed under the AGPL 3.0 License
下载 barrl
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 barrl
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 barrl
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 barrl
下载 barrl
下载 barrl
下载 barrl
下载 barrl
下载 barrl
下载 barrl
- 添加了更多渲染管线
- 添加了更多渲染参数
- 更改了线宽行为
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧