MeleeWeaponEnchantment
extends Enchantment
in package
Classes extending this class can be applied to weapons and activate when used by a mob to attack another mob in melee combat.
Table of Contents
- $maxLevel : int
- $name : Translatable|string
- $primaryItemFlags : int
- $rarity : int
- $secondaryItemFlags : int
- __clone() : mixed
- __construct() : mixed
- __serialize() : array<string|int, mixed>
- __unserialize() : void
- getDamageBonus() : float
- Returns the amount of additional damage caused by this enchantment to applicable targets.
- getMaxLevel() : int
- Returns the maximum level of this enchantment that can be found on an enchantment table.
- getName() : Translatable|string
- Returns a translation key for this enchantment's name.
- getPrimaryItemFlags() : int
- Returns a bitset indicating what item types can have this item applied from an enchanting table.
- getRarity() : int
- Returns an int constant indicating how rare this enchantment type is.
- getSecondaryItemFlags() : int
- Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from an anvil.
- hasPrimaryItemType() : bool
- Returns whether this enchantment can apply to the item type from an enchanting table.
- hasSecondaryItemType() : bool
- Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
- isApplicableTo() : bool
- Returns whether this melee enchantment has an effect on the target entity. For example, Smite only applies to undead mobs.
- onPostAttack() : void
- Called after damaging the entity to apply any post damage effects to the target.
Properties
$maxLevel
private
int
$maxLevel
$name
private
Translatable|string
$name
$primaryItemFlags
private
int
$primaryItemFlags
$rarity
private
int
$rarity
$secondaryItemFlags
private
int
$secondaryItemFlags
Methods
__clone()
public
final __clone() : mixed
Return values
mixed —__construct()
public
__construct(Translatable|string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel) : mixed
Parameters
- $name : Translatable|string
- $rarity : int
- $primaryItemFlags : int
- $secondaryItemFlags : int
- $maxLevel : int
Return values
mixed —__serialize()
public
final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —getDamageBonus()
Returns the amount of additional damage caused by this enchantment to applicable targets.
public
abstract getDamageBonus(int $enchantmentLevel) : float
Parameters
- $enchantmentLevel : int
Return values
float —getMaxLevel()
Returns the maximum level of this enchantment that can be found on an enchantment table.
public
getMaxLevel() : int
Return values
int —getName()
Returns a translation key for this enchantment's name.
public
getName() : Translatable|string
Return values
Translatable|string —getPrimaryItemFlags()
Returns a bitset indicating what item types can have this item applied from an enchanting table.
public
getPrimaryItemFlags() : int
Return values
int —getRarity()
Returns an int constant indicating how rare this enchantment type is.
public
getRarity() : int
Return values
int —getSecondaryItemFlags()
Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from an anvil.
public
getSecondaryItemFlags() : int
Return values
int —hasPrimaryItemType()
Returns whether this enchantment can apply to the item type from an enchanting table.
public
hasPrimaryItemType(int $flag) : bool
Parameters
- $flag : int
Return values
bool —hasSecondaryItemType()
Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
public
hasSecondaryItemType(int $flag) : bool
Parameters
- $flag : int
Return values
bool —isApplicableTo()
Returns whether this melee enchantment has an effect on the target entity. For example, Smite only applies to undead mobs.
public
abstract isApplicableTo(Entity $victim) : bool
Parameters
- $victim : Entity
Return values
bool —onPostAttack()
Called after damaging the entity to apply any post damage effects to the target.
public
onPostAttack(Entity $attacker, Entity $victim, int $enchantmentLevel) : void