Files
netease-bedrock-wiki/mcguide/20-玩法开发/15-自定义游戏内容/1-自定义物品/9-自定义鱼竿.md
MCNeteaseDevs 707e3a7b2b
Some checks failed
Auto Push on Tag / push-code (push) Has been cancelled
[自动同步] 新增 1 个 - 2026-04-01 10:17:03
2026-04-01 10:17:03 +08:00

94 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
front:
hard: 入门
time: 分钟
---
# 自定义鱼竿
## 概述
属于特殊的自定义物品,在支持自定义物品所有特性的基础上,还具有原版鱼竿相关功能,可以自定义鱼线长、鱼线颜色,以及鱼漂,其中鱼漂支持自定义实体
## 注册
1. 与自定义基础物品的注册1-6步相同
1. 在behavior/netease_items_beh的json中添加武器/工具相关的定义,包括:
custom_item_type为custom_item_type
一个netease:fishing_hook组件选填。组件的参数见[json组件](#json组件)
```json
{
"minecraft:item": {
"description": {
"category": "Custom",
"identifier": "customshield:test_fishing_rod",
"custom_item_type": "fishing_rod"
},
"components": {
"netease:fishing_hook":{
"hook_entity":["minecraft:creeper"],//代表投掷出的将会是一个苦力怕实体作为鱼漂苦力实体无AI。
"line_max":50,//代表鱼线可以达到的最长长度(鱼漂与玩家实体的直线距离),超过这个长度后鱼线将会直接断开
"line_color":[0.6, 0.5, 0.3, 1.0]//线的颜色和透明度
}
}
},
"format_version": "1.10"
}
```
## JSON组件
### 网易components
* netease:fishing_hook
| 键 | 类型 | 默认值 | 解释 |
| -------- | ---- | --------- | ---------------------------------------------- |
| hook_entity | str | | 实体的identify填入的实体除了无AI以外支持动画、动画控制器等实体一系列操控 |
| line_max | int | 32 | 代表鱼线可以达到的最长长度鱼漂与玩家实体的直线距离超过这个长度后鱼线将会直接断开。如果不配置代表和原版鱼线一致为32米 |
| line_color | list(rgba) | | 代表鱼线的初始颜色与透明度,如果不配置默认为原版鱼竿黑色 |
## 新增的事件和接口
### 事件
* <a href="../../../../mcdocs/1-ModAPI/事件/玩家.html#playerfishingserverevent">PlayerFishingServerEvent</a>
服务端,钓鱼成功收杆时触发事件
* <a href="../../../../mcdocs/1-ModAPI/事件/玩家html#playerfishingafterserverevent">PlayerFishingAfterServerEvent</a>
服务端,钓鱼成功收杆后触发事件
* <a href="../../../../mcdocs/1-ModAPI/事件/玩家html#playerstartfishingserverevent">PlayerStartFishingServerEvent</a>
服务端,玩家开始钓鱼事件
### 接口
* <a href="../../../../mcdocs/1-ModAPI/接口/玩家/背包.html#getplayerfishitem">GetPlayerFishItem</a>
服务端接口。获取玩家钓鱼时候的鱼竿物品字典
* <a href="../../../../mcdocs/1-ModAPI/接口/玩家/行为.html#getplayerisfishing">GetPlayerIsFishing</a>
客户端接口。获取玩家是否在钓鱼
* <a href="../../../../mcdocs/1-ModAPI/接口/玩家/背包.html#getplayerfishhookentity">GetPlayerFishHookEntity</a>
客户端接口。获取玩家钓鱼时候的鱼漂实体id
## demo解释
[自定义鱼竿](../../13-模组SDK编程/60-Demo示例.md#CustomFishHookItemMod)中定义了一个自定义鱼竿