Record Class CustomBlockDefinition

java.lang.Object
java.lang.Record
cn.nukkit.block.customblock.CustomBlockDefinition

@PowerNukkitXOnly @Since("1.19.31-r1") public record CustomBlockDefinition(String identifier, CompoundTag nbt) extends Record
CustomBlockDefinition用于获得发送给客户端的方块行为包数据。CustomBlockDefinition.Builder中提供的方法都是控制发送给客户端数据,如果需要控制服务端部分行为,请覆写Block中的方法。

CustomBlockDefinition is used to get the data of the block behavior_pack sent to the client. The methods provided in CustomBlockDefinition.Builder control the data sent to the client, if you need to control some of the server-side behavior, please override the methods in Block.

  • Constructor Details

    • CustomBlockDefinition

      public CustomBlockDefinition(String identifier, CompoundTag nbt)
      Creates an instance of a CustomBlockDefinition record class.
      Parameters:
      identifier - the value for the identifier record component
      nbt - the value for the nbt record component
  • Method Details

    • builder

      public static CustomBlockDefinition.Builder builder(CustomBlock customBlock, String texture)
    • builder

      public static CustomBlockDefinition.Builder builder(CustomBlock customBlock, String texture, BlockCreativeCategory blockCreativeCategory)
    • builder

      public static CustomBlockDefinition.Builder builder(CustomBlock customBlock, Materials materials)
    • builder

      public static CustomBlockDefinition.Builder builder(@NonNull @NonNull CustomBlock customBlock, @NonNull @NonNull Materials materials, BlockCreativeCategory blockCreativeCategory)
      Builder custom block definition.
      Parameters:
      customBlock - the custom block
      materials - the materials
      blockCreativeCategory - 自定义方块在创造栏的大分类
      the block creative category
      Returns:
      the custom block definition builder.
    • 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