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.

  • Constructor Details

    • CustomItemDefinition

      public CustomItemDefinition(String identifier, CompoundTag nbt)
      Creates an instance of a CustomItemDefinition record class.
      Parameters:
      identifier - the value for the identifier record component
      nbt - the value for the nbt 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 item
      creativeCategory - 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 item
      creativeCategory - the creative category
    • toolBuilder

      public static CustomItemDefinition.ToolBuilder toolBuilder(ItemCustomTool item, ItemCreativeCategory creativeCategory)
      自定义工具的定义构造器

      Definition builder for custom tools

      Parameters:
      item - the item
      creativeCategory - the creative category
    • armorBuilder

      public static CustomItemDefinition.ArmorBuilder armorBuilder(ItemCustomArmor item, ItemCreativeCategory creativeCategory)
      自定义盔甲的定义构造器

      Definition builder for custom armor

      Parameters:
      item - the item
      creativeCategory - the creative category
    • edibleBuilder

      public static CustomItemDefinition.EdibleBuilder edibleBuilder(ItemCustomEdible item, ItemCreativeCategory creativeCategory)
      自定义食物(药水)的定义构造器

      Definition builder for custom food or potion

      Parameters:
      item - the item
      creativeCategory - the creative category
    • getDisplayName

      @Nullable public String getDisplayName()
    • getTexture

      public String getTexture()
    • getRuntimeId

      public int getRuntimeId()
    • getRuntimeId

      public static int getRuntimeId(String identifier)
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • identifier

      public String identifier()
      Returns the value of the identifier record component.
      Returns:
      the value of the identifier record component
    • nbt

      public CompoundTag nbt()
      Returns the value of the nbt record component.
      Returns:
      the value of the nbt record component