Package cn.nukkit.item.customitem
Record Class CustomItemDefinition
java.lang.Object
java.lang.Record
cn.nukkit.item.customitem.CustomItemDefinition
@PowerNukkitXOnly
@Since("1.19.31-r1")
public record CustomItemDefinition(String identifier, CompoundTag nbt)
extends Record
CustomBlockDefinition用于获得发送给客户端的物品行为包数据。
CustomItemDefinition.SimpleBuilder
中提供的方法都是控制发送给客户端数据,如果需要控制服务端部分行为,请覆写Item
中的方法。
CustomBlockDefinition is used to get the data of the item behavior_pack sent to the client. The methods provided in CustomItemDefinition.SimpleBuilder
control the data sent to the client, if you need to control some of the server-side behavior, please override the methods in Item
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Constructor Summary
ConstructorDescriptionCustomItemDefinition
(String identifier, CompoundTag nbt) Creates an instance of aCustomItemDefinition
record class. -
Method Summary
Modifier and TypeMethodDescriptionarmorBuilder
(ItemCustomArmor item, ItemCreativeCategory creativeCategory) 自定义盔甲的定义构造器customBuilder
(CustomItem item, ItemCreativeCategory creativeCategory) 自定义物品的定义构造器edibleBuilder
(ItemCustomEdible item, ItemCreativeCategory creativeCategory) 自定义食物(药水)的定义构造器final boolean
Indicates whether some other object is "equal to" this one.int
static int
getRuntimeId
(String identifier) final int
hashCode()
Returns a hash code value for this object.Returns the value of theidentifier
record component.nbt()
Returns the value of thenbt
record component.simpleBuilder
(ItemCustom item, ItemCreativeCategory creativeCategory) 简单物品的定义构造器toolBuilder
(ItemCustomTool item, ItemCreativeCategory creativeCategory) 自定义工具的定义构造器final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
CustomItemDefinition
Creates an instance of aCustomItemDefinition
record class.- Parameters:
identifier
- the value for theidentifier
record componentnbt
- the value for thenbt
record component
-
-
Method Details
-
customBuilder
@PowerNukkitXOnly @Since("1.19.60-r1") public static CustomItemDefinition.SimpleBuilder customBuilder(CustomItem item, ItemCreativeCategory creativeCategory) 自定义物品的定义构造器Definition builder for custom simple item
- Parameters:
item
- the itemcreativeCategory
- the creative category- Returns:
- the custom item definition . simple builder
-
simpleBuilder
public static CustomItemDefinition.SimpleBuilder simpleBuilder(ItemCustom item, ItemCreativeCategory creativeCategory) 简单物品的定义构造器Definition builder for custom simple item
- Parameters:
item
- the itemcreativeCategory
- the creative category
-
toolBuilder
public static CustomItemDefinition.ToolBuilder toolBuilder(ItemCustomTool item, ItemCreativeCategory creativeCategory) 自定义工具的定义构造器Definition builder for custom tools
- Parameters:
item
- the itemcreativeCategory
- the creative category
-
armorBuilder
public static CustomItemDefinition.ArmorBuilder armorBuilder(ItemCustomArmor item, ItemCreativeCategory creativeCategory) 自定义盔甲的定义构造器Definition builder for custom armor
- Parameters:
item
- the itemcreativeCategory
- the creative category
-
edibleBuilder
public static CustomItemDefinition.EdibleBuilder edibleBuilder(ItemCustomEdible item, ItemCreativeCategory creativeCategory) 自定义食物(药水)的定义构造器Definition builder for custom food or potion
- Parameters:
item
- the itemcreativeCategory
- the creative category
-
getDisplayName
-
getTexture
-
getRuntimeId
public int getRuntimeId() -
getRuntimeId
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
identifier
Returns the value of theidentifier
record component.- Returns:
- the value of the
identifier
record component
-
nbt
Returns the value of thenbt
record component.- Returns:
- the value of the
nbt
record component
-