类 Enchantment
java.lang.Object
cn.nukkit.item.enchantment.Enchantment
- 所有已实现的接口:
Cloneable
- 直接已知子类:
EnchantmentBindingCurse
,EnchantmentBow
,EnchantmentCrossbow
,EnchantmentDamage
,EnchantmentDurability
,EnchantmentEfficiency
,EnchantmentFireAspect
,EnchantmentFrostWalker
,EnchantmentKnockback
,EnchantmentLoot
,EnchantmentLure
,EnchantmentMending
,EnchantmentProtection
,EnchantmentSilkTouch
,EnchantmentSoulSpeed
,EnchantmentSwiftSneak
,EnchantmentThorns
,EnchantmentTrident
,EnchantmentVanishingCurse
,EnchantmentWaterBreath
,EnchantmentWaterWalker
,EnchantmentWaterWorker
An enchantment that can be to applied to an item.
- 作者:
- MagicDroidX (Nukkit Project)
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明static final Enchantment[]
protected static Enchantment[]
final int
The internal ID which this enchantment got registered.static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
protected int
The level of this enchantment.protected final String
The name visible by the player, this is used in conjunction withgetName()
, unless modified with an override, the getter will automatically add "%enchantment." as prefix to grab the translation keystatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
The group of objects that this enchantment can be applied.static final String[]
-
构造器概要
构造器限定符构造器说明protected
Enchantment
(int id, String name, int weight, EnchantmentType type) 已过时。protected
Enchantment
(int id, String name, Enchantment.Rarity rarity, EnchantmentType type) Constructs this instance using the given data and with level 1. -
方法概要
修饰符和类型方法说明boolean
canEnchant
(Item item) Checks if the given item have a type which is compatible with this enchantment.protected boolean
checkCompatibility
(Enchantment enchantment) Checks if this enchantment can be applied to an item that have the give enchantment without doing reverse check.protected Enchantment
clone()
void
void
doPostAttack
(Entity attacker, Entity entity) void
doPostHurt
(Entity attacker, Entity entity) static Enchantment
get
(int id) 已过时。getAttackSideEffects
(Entity attacker, Entity entity) double
getDamageBonus
(Entity entity) static Enchantment
getEnchantment
(int id) The same asget(int)
but returns a safe copy of the enchantment.static Enchantment
getEnchantment
(String name) static Enchantment[]
已过时。int
getId()
The ID of this enchantment.int
getLevel()
The current level of this enchantment.int
getMaxEnchantAbility
(int level) The maximum enchantability for the given level as described in https://minecraft.gamepedia.com/Enchanting/Levelsint
The maximum level that can be obtained using an enchanting table.int
The maximum safe level which is possible with this enchantment.int
getMinEnchantAbility
(int level) The minimum enchantability for the given level as described in https://minecraft.gamepedia.com/Enchanting/Levelsint
The minimum safe level which is possible with this enchantment.getName()
float
static String
How rare this enchantment is.static Collection<Enchantment>
Gets a collection with a safe copy of all enchantments that are currently registered.int
已过时。static void
init()
boolean
isCompatibleWith
(Enchantment enchantment) Returns true if and only if this enchantment is compatible with the other and the other is also compatible with this enchantment.boolean
isItemAcceptable
(Item item) 已过时。boolean
isMajor()
setLevel
(int level) Changes the level of this enchantment.setLevel
(int level, boolean safe) Changes the level of this enchantment.
-
字段详细资料
-
EMPTY_ARRAY
-
enchantments
-
enchantmentName2IDMap
-
ID_PROTECTION_ALL
public static final int ID_PROTECTION_ALL- 另请参阅:
-
NAME_PROTECTION_ALL
- 另请参阅:
-
ID_PROTECTION_FIRE
public static final int ID_PROTECTION_FIRE- 另请参阅:
-
NAME_PROTECTION_FIRE
- 另请参阅:
-
ID_PROTECTION_FALL
public static final int ID_PROTECTION_FALL- 另请参阅:
-
NAME_PROTECTION_FALL
- 另请参阅:
-
ID_PROTECTION_EXPLOSION
public static final int ID_PROTECTION_EXPLOSION- 另请参阅:
-
NAME_PROTECTION_EXPLOSION
- 另请参阅:
-
ID_PROTECTION_PROJECTILE
public static final int ID_PROTECTION_PROJECTILE- 另请参阅:
-
NAME_PROTECTION_PROJECTILE
- 另请参阅:
-
ID_THORNS
public static final int ID_THORNS- 另请参阅:
-
NAME_THORNS
- 另请参阅:
-
ID_WATER_BREATHING
public static final int ID_WATER_BREATHING- 另请参阅:
-
NAME_WATER_BREATHING
- 另请参阅:
-
ID_WATER_WALKER
public static final int ID_WATER_WALKER- 另请参阅:
-
NAME_WATER_WALKER
- 另请参阅:
-
ID_WATER_WORKER
public static final int ID_WATER_WORKER- 另请参阅:
-
NAME_WATER_WORKER
- 另请参阅:
-
ID_DAMAGE_ALL
public static final int ID_DAMAGE_ALL- 另请参阅:
-
NAME_DAMAGE_ALL
- 另请参阅:
-
ID_DAMAGE_SMITE
public static final int ID_DAMAGE_SMITE- 另请参阅:
-
NAME_DAMAGE_SMITE
- 另请参阅:
-
ID_DAMAGE_ARTHROPODS
public static final int ID_DAMAGE_ARTHROPODS- 另请参阅:
-
NAME_DAMAGE_ARTHROPODS
- 另请参阅:
-
ID_KNOCKBACK
public static final int ID_KNOCKBACK- 另请参阅:
-
NAME_KNOCKBACK
- 另请参阅:
-
ID_FIRE_ASPECT
public static final int ID_FIRE_ASPECT- 另请参阅:
-
NAME_FIRE_ASPECT
- 另请参阅:
-
ID_LOOTING
public static final int ID_LOOTING- 另请参阅:
-
NAME_LOOTING
- 另请参阅:
-
ID_EFFICIENCY
public static final int ID_EFFICIENCY- 另请参阅:
-
NAME_EFFICIENCY
- 另请参阅:
-
ID_SILK_TOUCH
public static final int ID_SILK_TOUCH- 另请参阅:
-
NAME_SILK_TOUCH
- 另请参阅:
-
ID_DURABILITY
public static final int ID_DURABILITY- 另请参阅:
-
NAME_DURABILITY
- 另请参阅:
-
ID_FORTUNE_DIGGING
public static final int ID_FORTUNE_DIGGING- 另请参阅:
-
NAME_FORTUNE_DIGGING
- 另请参阅:
-
ID_BOW_POWER
public static final int ID_BOW_POWER- 另请参阅:
-
NAME_BOW_POWER
- 另请参阅:
-
ID_BOW_KNOCKBACK
public static final int ID_BOW_KNOCKBACK- 另请参阅:
-
NAME_BOW_KNOCKBACK
- 另请参阅:
-
ID_BOW_FLAME
public static final int ID_BOW_FLAME- 另请参阅:
-
NAME_BOW_FLAME
- 另请参阅:
-
ID_BOW_INFINITY
public static final int ID_BOW_INFINITY- 另请参阅:
-
NAME_BOW_INFINITY
- 另请参阅:
-
ID_FORTUNE_FISHING
public static final int ID_FORTUNE_FISHING- 另请参阅:
-
NAME_FORTUNE_FISHING
- 另请参阅:
-
ID_LURE
public static final int ID_LURE- 另请参阅:
-
NAME_LURE
- 另请参阅:
-
ID_FROST_WALKER
public static final int ID_FROST_WALKER- 另请参阅:
-
NAME_FROST_WALKER
- 另请参阅:
-
ID_MENDING
public static final int ID_MENDING- 另请参阅:
-
NAME_MENDING
- 另请参阅:
-
ID_BINDING_CURSE
public static final int ID_BINDING_CURSE- 另请参阅:
-
NAME_BINDING_CURSE
- 另请参阅:
-
ID_VANISHING_CURSE
public static final int ID_VANISHING_CURSE- 另请参阅:
-
NAME_VANISHING_CURSE
- 另请参阅:
-
ID_TRIDENT_IMPALING
public static final int ID_TRIDENT_IMPALING- 另请参阅:
-
NAME_TRIDENT_IMPALING
- 另请参阅:
-
ID_TRIDENT_RIPTIDE
public static final int ID_TRIDENT_RIPTIDE- 另请参阅:
-
NAME_TRIDENT_RIPTIDE
- 另请参阅:
-
ID_TRIDENT_LOYALTY
public static final int ID_TRIDENT_LOYALTY- 另请参阅:
-
NAME_TRIDENT_LOYALTY
- 另请参阅:
-
ID_TRIDENT_CHANNELING
public static final int ID_TRIDENT_CHANNELING- 另请参阅:
-
NAME_TRIDENT_CHANNELING
- 另请参阅:
-
ID_CROSSBOW_MULTISHOT
- 另请参阅:
-
NAME_CROSSBOW_MULTISHOT
- 另请参阅:
-
ID_CROSSBOW_PIERCING
- 另请参阅:
-
NAME_CROSSBOW_PIERCING
- 另请参阅:
-
ID_CROSSBOW_QUICK_CHARGE
- 另请参阅:
-
NAME_CROSSBOW_QUICK_CHARGE
- 另请参阅:
-
ID_SOUL_SPEED
- 另请参阅:
-
NAME_SOUL_SPEED
- 另请参阅:
-
ID_SWIFT_SNEAK
- 另请参阅:
-
NAME_SWIFT_SNEAK
- 另请参阅:
-
id
public final int idThe internal ID which this enchantment got registered. -
type
The group of objects that this enchantment can be applied. -
level
protected int levelThe level of this enchantment. Starting from1
. -
name
The name visible by the player, this is used in conjunction withgetName()
, unless modified with an override, the getter will automatically add "%enchantment." as prefix to grab the translation key -
words
-
-
构造器详细资料
-
Enchantment
@PowerNukkitOnly("Was removed from Nukkit in 1.4.0.0-PN, keeping it in PowerNukkit for backward compatibility") @Deprecated @DeprecationDetails(by="Cloudburst Nukkit", since="1.4.0.0-PN", reason="Changed the signature without backward compatibility", replaceWith="Enchantment(int, String, Rarity, EnchantmentType)") protected Enchantment(int id, String name, int weight, EnchantmentType type) 已过时。Constructs this instance using the given data and with level 1.- 参数:
id
- The enchantment IDname
- The translation key without the "%enchantment." suffixweight
- How rare this enchantment is, from1
to10
both inclusive where1
is the raresttype
- Where the enchantment can be applied
-
Enchantment
@Since("1.4.0.0-PN") protected Enchantment(int id, String name, Enchantment.Rarity rarity, EnchantmentType type) Constructs this instance using the given data and with level 1.- 参数:
id
- The enchantment IDname
- The translation key without the "%enchantment." suffixrarity
- How rare this enchantment istype
- Where the enchantment can be applied
-
-
方法详细资料
-
init
public static void init() -
get
@Deprecated @DeprecationDetails(by="PowerNukkit", reason="This is very insecure and can break the environment", since="1.4.0.0-PN", replaceWith="getEnchantment(int)") public static Enchantment get(int id) 已过时。Returns the enchantment object registered with this ID, any change to the returned object affects the creation of new enchantments as the returned object is not a copy.- 参数:
id
- The enchantment id.- 返回:
- The enchantment, if no enchantment is found with that id,
Enchantment.UnknownEnchantment
is returned. The UnknownEnchantment will be always a new instance and changes to it does not affects other calls.
-
getEnchantment
The same asget(int)
but returns a safe copy of the enchantment.- 参数:
id
- The enchantment id- 返回:
- A new enchantment object.
-
getEnchantment
-
getEnchantments
@Deprecated @DeprecationDetails(since="1.4.0.0-PN", by="PowerNukkit", reason="The objects returned by this method are not safe to use and the implementation may skip some enchantments", replaceWith="getRegisteredEnchantments()") public static Enchantment[] getEnchantments()已过时。Gets an array of all registered enchantments, the objects in the array are linked to the registry, it's not safe to change them. Changing them can cause the same issue as documented inget(int)
- 返回:
- An array with the enchantment objects, the array may contain null objects but is very unlikely.
-
getRegisteredEnchantments
@PowerNukkitOnly @Since("1.4.0.0-PN") public static Collection<Enchantment> getRegisteredEnchantments()Gets a collection with a safe copy of all enchantments that are currently registered.- 返回:
- The objects can be modified without affecting the registry and the collection will not have null values.
-
getEnchantmentName2IDMap
@PowerNukkitXOnly @Since("1.6.0.0-PNX") public static Map<String,Integer> getEnchantmentName2IDMap() -
getLevel
public int getLevel()The current level of this enchantment.0
means that the enchantment is not applied.- 返回:
- The level starting from
1
.
-
setLevel
Changes the level of this enchantment. The level is clamped between the values returned ingetMinLevel()
andgetMaxLevel()
.- 参数:
level
- The level starting from1
.- 返回:
- This object so you can do chained calls
-
setLevel
Changes the level of this enchantment. When thesafe
param istrue
, the level is clamped between the values returned ingetMinLevel()
andgetMaxLevel()
.- 参数:
level
- The level starting from1
.safe
- If the level should clamped or applied directly- 返回:
- This object so you can do chained calls
-
getId
public int getId()The ID of this enchantment. -
getRarity
How rare this enchantment is. -
getWeight
@DeprecationDetails(since="1.4.0.0-PN", by="Cloudburst Nukkit", reason="Refactored enchantments and now uses a Rarity enum", replaceWith="getRarity().getWeight()") @Deprecated public int getWeight()已过时。useEnchantment.Rarity.getWeight()
insteadHow rare this enchantment is, from1
to10
where1
is the rarest. -
getMinLevel
public int getMinLevel()The minimum safe level which is possible with this enchantment. It is usually1
. -
getMaxLevel
public int getMaxLevel()The maximum safe level which is possible with this enchantment. -
getMaxEnchantableLevel
public int getMaxEnchantableLevel()The maximum level that can be obtained using an enchanting table. -
getMinEnchantAbility
public int getMinEnchantAbility(int level) The minimum enchantability for the given level as described in https://minecraft.gamepedia.com/Enchanting/Levels- 参数:
level
- The level being checked- 返回:
- The minimum value
-
getMaxEnchantAbility
public int getMaxEnchantAbility(int level) The maximum enchantability for the given level as described in https://minecraft.gamepedia.com/Enchanting/Levels- 参数:
level
- The level being checked- 返回:
- The maximum value
-
getProtectionFactor
-
getDamageBonus
-
doPostAttack
-
doAttack
-
doPostHurt
-
isCompatibleWith
@PowerNukkitDifference(since="1.4.0.0-PN", info="Cloudburst Nukkit added the final modifier, we removed it to maintain backward compatibility. The right way to implement compatibility now is to override checkCompatibility(Enchantment enchantment) and also make sure to keep it protected! Some overrides was incorrectly made public, let\'s avoid this mistake.") public boolean isCompatibleWith(@Nonnull Enchantment enchantment) Returns true if and only if this enchantment is compatible with the other and the other is also compatible with this enchantment.- 参数:
enchantment
- The enchantment which is being checked- 返回:
- If both enchantments are compatible
-
checkCompatibility
Checks if this enchantment can be applied to an item that have the give enchantment without doing reverse check.- 参数:
enchantment
- The enchantment to be checked- 返回:
- If this enchantment is compatible with the other enchantment.
-
getName
-
getOriginalName
-
canEnchant
Checks if the given item have a type which is compatible with this enchantment. This method does not check if the item already have incompatible enchantments.- 参数:
item
- The item to be checked- 返回:
- If the type of the item is valid for this enchantment
-
isMajor
public boolean isMajor() -
getAttackSideEffects
@PowerNukkitOnly @Since("1.5.1.0-PN") @Nonnull public SideEffect[] getAttackSideEffects(@Nonnull Entity attacker, @Nonnull Entity entity) -
clone
-
isItemAcceptable
@PowerNukkitOnly @Since("1.2.1.0-PN") @Deprecated @DeprecationDetails(by="PowerNukkit", since="1.4.0.0-PN", reason="Does the same as canEnchant(item)", replaceWith="canEnchant(item)") public boolean isItemAcceptable(Item item) 已过时。Checks if an item can have this enchantment. It's not strict to the enchantment table. -
getRandomName
-
Enchantment.Rarity.getWeight()
instead