-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandyCaneSword.java
More file actions
99 lines (90 loc) · 2.29 KB
/
Copy pathCandyCaneSword.java
File metadata and controls
99 lines (90 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package cn.nukkitmot.exampleplugin.custom.item;
import cn.nukkit.item.customitem.CustomItemDefinition;
import cn.nukkit.item.customitem.ItemCustom;
/**
* 糖果拐杖剑类
*
* 展示了 Nukkit 自定义物品的完整实现方式。
* 这是一把自定义剑类武器,具有独特的属性。
*
* 物品属性:
* <ul>
* <li>命名空间ID:nukkit:candy_cane_sword</li>
* <li>材质贴图:candy_cane_sword</li>
* <li>最大耐久度:500</li>
* <li>堆叠数量:1</li>
* <li>攻击伤害:4</li>
* <li>可装备副手:支持</li>
* <li>主手装备:是</li>
* </ul>
*
* @author NukkitMOT
* @version 1.0.0
*/
public class CandyCaneSword extends ItemCustom {
/** 命名空间ID */
private static String spacenameId = "nukkit:candy_cane_sword";
/** 材质贴图名称 */
private static String textureName = "candy_cane_sword";
/** 物品显示名称(null 使用默认名称) */
private static String name = null;
/**
* 构造函数
*/
public CandyCaneSword() {
super(spacenameId, name, textureName);
}
/**
* 获取物品在客户端显示的偏移量
* @return 偏移量值
*/
public int scaleOffset() {
return 32;
}
/**
* 获取物品定义
* @return 自定义物品定义对象
*/
@Override
public CustomItemDefinition getDefinition() {
return CustomItemDefinition
.simpleBuilder(this, null)
// 允许装备在副手
.allowOffHand(true)
// 作为主手武器装备
.handEquipped(true)
.build();
}
/**
* 获取物品最大耐久度
* @return 最大耐久度值
*/
@Override
public int getMaxDurability() {
return 500;
}
/**
* 获取物品最大堆叠数量
* @return 最大堆叠数量(剑类为1)
*/
@Override
public int getMaxStackSize() {
return 1;
}
/**
* 获取物品攻击伤害
* @return 基础攻击伤害值
*/
@Override
public int getAttackDamage() {
return 4;
}
/**
* 判断是否为剑类物品
* @return true 是剑类物品
*/
@Override
public boolean isSword() {
return true;
}
}