Class Attribute

java.lang.Object
cn.nukkit.entity.Attribute
All Implemented Interfaces:
Cloneable

public class Attribute extends Object implements Cloneable
属性是作用于Entity上一个的增益/减益系统。

Attributes are buffs/debuffs systems that act on Entity.

Since:
Nukkit 1.0 | Nukkit API 1.0.0
Author:
Box, MagicDroidX(code), PeratX @ Nukkit Project
  • Field Details

  • Method Details

    • init

      public static void init()
    • addAttribute

      public static Attribute addAttribute(int id, String name, float minValue, float maxValue, float defaultValue)
    • addAttribute

      public static Attribute addAttribute(int id, String name, float minValue, float maxValue, float defaultValue, boolean shouldSend)
    • toNBT

      public static CompoundTag toNBT(Attribute attribute)
      将这个Attribute转换成NBT

      Convert this attribute to NBT

      like

       {
           "Base": 0f,
           "Current": 0f,
           "DefaultMax": 1024f,
           "DefaultMin": -1024f,
           "Max": 1024f,
           "Min": -1024f,
           "Name": "minecraft:luck"
       }
       
      Parameters:
      attribute - the attribute
      Returns:
      the compound tag
    • fromNBT

      public static Attribute fromNBT(CompoundTag NBT)
      从NBT获取Attribute

      Get the Attribute from NBT

      like

       {
           "Base": 0f,
           "Current": 0f,
           "DefaultMax": 1024f,
           "DefaultMin": -1024f,
           "Max": 1024f,
           "Min": -1024f,
           "Name": "minecraft:luck"
       }
       
      Parameters:
      NBT - the nbt
      Returns:
      the attribute
    • getAttribute

      public static Attribute getAttribute(int id)
      获取对应id的Attribute

      Get the Attribute of the corresponding id.

      Parameters:
      id - the id
      Returns:
      the attribute
    • getAttributeByName

      public static Attribute getAttributeByName(String name)
      获取对应名字的Attribute

      Get the Attribute of the corresponding name.

      Parameters:
      name - name
      Returns:
      null |Attribute
    • getMinValue

      public float getMinValue()
    • setMinValue

      public Attribute setMinValue(float minValue)
    • getMaxValue

      public float getMaxValue()
    • setMaxValue

      public Attribute setMaxValue(float maxValue)
    • getDefaultValue

      public float getDefaultValue()
    • setDefaultValue

      public Attribute setDefaultValue(float defaultValue)
    • getValue

      public float getValue()
    • setValue

      public Attribute setValue(float value)
    • setValue

      public Attribute setValue(float value, boolean fit)
    • getName

      public String getName()
    • getId

      public int getId()
    • isSyncable

      public boolean isSyncable()
    • clone

      public Attribute clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object