补充说明:
Aether for Station API 使用了本模组!
Accessory API
在 b1.7.3 中使用 Babric,本模组提供了一个 API,用于添加类似于 Trinkets API 和 Baubles API 的各种物品的额外插槽,其样式灵感源自 b1.7.3 的 Aether。
开发者用法
要了解如何使用 babric 工具链为 b1.7.3 进行模组开发,请加入 The Modification Station!
它与 fabric 和 fabric-api 非常相似,但适用于 b1.7.3。
工作区
将 Accessory API 添加到你的 build.gradle 中
repositories {
maven {
name = "Jitpack"
url "https://jitpack.io/"
}
}
dependencies {
modImplementation('com.github.matthewperiut:accessory-api:0.5.1') {
transitive false
}
}
建议
如果你想快速了解如何使用此 API,请克隆仓库(最好在 IDE 中)并导航至 src/test/java/com/matthewperiut/testmod。
同时查看 API 的 javadocs / 文档
实现
在你的物品类中实现 "Accessory" (配合 STAPI 使用,也可与任何 API/mixins 配合)
public class ExampleRing extends TemplateItemBase implements Accessory
{
public Pendant(Identifier identifier)
{
super(identifier);
}
// 定义该物品可以放入的饰品插槽类型:
@Override
public String[] getAccessoryTypes(ItemInstance item)
{
return new String[]{ "ring" };
// return new String[0]; // 返回无插槽
// return new String[]{ "ring", "cape" }; // 可放入多种类型的插槽
// return new String[]{ "all" }; // 可放入任意饰品插槽
}
// 其他可用的方法,请使用 @Override
// void tickWhileWorn(PlayerBase player, ItemInstance accessory)
// void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
// void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)
// 渲染相关
private YourCustomRenderer renderer;
@Override
public Optional<AccessoryRenderer> getRenderer()
{
return Optional.ofNullable(renderer);
}
}
你可以选择不同的默认饰品类型:
"pendant"(吊坠)
"cape"(披风)
"shield"(盾牌)
"ring"(戒指)
"gloves"(手套)
"misc"(杂项)
"all"(全部)
或者使用你自己的自定义饰品类型
饰品函数详解
当玩家使用物品点击饰品插槽时调用此函数,物品会作为参数传入。
这提供了插槽信息以检查其兼容性。
String[] getAccessoryTypes(ItemInstance item)
此函数在关联玩家的 tick 函数中被调用,传递正在被 tick 的物品及对应的玩家。
void tickWhileWorn(PlayerBase player, ItemInstance item)
当与饰品相关的库存中添加/移除物品时调用此函数。
该函数提供了添加/移除饰品的玩家以及被添加/移除的物品。
void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)
通过 getRenderer 提供渲染函数:
public AccessoryRenderer getRenderer()
创建饰品渲染器
示例:
public class CustomRenderer implements AccessoryRenderer {
void renderThirdPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance, double x, double y, double z, float h, float v)
{
// 执行实体渲染逻辑
}
void renderFirstPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance)
{
// 执行第一人称实体渲染逻辑
}
}
用法与 EntityRenderers 类似
内置饰品渲染器:
CapeRenderer
GloveRenderer
NecklaceRenderer
ConfigurableRenderer
Side note:
Aether for Station API utilizes this mod!
Accessory API
Using Babric in b1.7.3, this mod provides an API to add additional slots for various items similar to the Trinkets API and Baubles API, with styling inspired by b1.7.3's Aether.
Developer Usage
To learn about modding b1.7.3 in the babric toolchain, join The Modification Station!
It's very similar to fabric and fabric-api, but for b1.7.3.
Workspace
Add Accessory API to your build.gradle
repositories {
maven {
name = "Jitpack"
url "https://jitpack.io/"
}
}
dependencies {
modImplementation('com.github.matthewperiut:accessory-api:0.5.1') {
transitive false
}
}
Recommendation
If you want to quickly see how to use this API, clone the repo (in an ide preferably) and navigate to src/test/java/com/matthewperiut/testmod.
Also view API javadocs / documentation
Implementation
Implement "Accessory" inside your item class (with STAPI, will work with any API/mixins)
public class ExampleRing extends TemplateItemBase implements Accessory
{
public Pendant(Identifier identifier)
{
super(identifier);
}
// To define trinket slots that your item can go into:
@Override
public String[] getAccessoryTypes(ItemInstance item)
{
return new String[]{ "ring" };
// return new String[0]; // returns no slots
// return new String[]{ "ring", "cape" }; // can be put in multiple types of slots
// return new String[]{ "all" }; // can be in any accessory slot
}
// other methods you can use, use @Override
// void tickWhileWorn(PlayerBase player, ItemInstance accessory)
// void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
// void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)
// Rendering
private YourCustomRenderer renderer;
@Override
public Optional<AccessoryRenderer> getRenderer()
{
return Optional.ofNullable(renderer);
}
}
You can choose different types of default accessory types:
"pendant"
"cape"
"shield"
"ring"
"gloves"
"misc"
"all"
or use your own custom accessory type
Accessory Functions Explained
This is called when an accessory slot is clicked on with an item, the item is passed to the function.
This provides the slot information to see if it is compatible with it.
String[] getAccessoryTypes(ItemInstance item)
This is called in the tick function of the associated player, passing the item that is being ticked on which player.
void tickWhileWorn(PlayerBase player, ItemInstance item)
This is called when the inventory relating to the accessory has an item added/removed.
The function provides what player added/removed an accessory as well as the item that was added/removed.
void onAccessoryAdded(PlayerBase player, ItemInstance accessory)
void onAccessoryRemoved(PlayerBase player, ItemInstance accessory)
Provide rendering functions with getRenderer:
public AccessoryRenderer getRenderer()
Creating Accessory Renderer
example:
public class CustomRenderer implements AccessoryRenderer {
void renderThirdPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance, double x, double y, double z, float h, float v)
{
// do entity rendering magic
}
void renderFirstPerson(PlayerBase player, PlayerRenderer renderer, ItemInstance itemInstance)
{
// do entity first person rendering magic
}
}
Similar usage as EntityRenderers
Built-in AccessoryRenderers:
CapeRenderer
GloveRenderer
NecklaceRenderer
ConfigurableRenderer
下载 Accessory API
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
下载 Accessory API
添加回心命令 改进发布
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
模组
添加全屏世界地图,显示你在世界中已探索的区域。与 Xaero's Minimap 搭配使用效果极佳。
评论 0
登录后参与评分
还没有评论,来抢沙发吧