mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +00:00
parent
ed65e91a3c
commit
8239c67b1a
@ -90,29 +90,29 @@ class Enchantment{
|
|||||||
public static function init(){
|
public static function init(){
|
||||||
self::$enchantments = new \SplFixedArray(256);
|
self::$enchantments = new \SplFixedArray(256);
|
||||||
|
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, 4, 0.75, null));
|
self::registerEnchantment(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 0.75, null));
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::SLOT_ARMOR, 4, 1.25, [
|
self::registerEnchantment(new ProtectionEnchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.25, [
|
||||||
EntityDamageEvent::CAUSE_FIRE,
|
EntityDamageEvent::CAUSE_FIRE,
|
||||||
EntityDamageEvent::CAUSE_FIRE_TICK,
|
EntityDamageEvent::CAUSE_FIRE_TICK,
|
||||||
EntityDamageEvent::CAUSE_LAVA
|
EntityDamageEvent::CAUSE_LAVA
|
||||||
//TODO: check fireballs
|
//TODO: check fireballs
|
||||||
]));
|
]));
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::SLOT_FEET, 4, 2.5, [
|
self::registerEnchantment(new ProtectionEnchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::SLOT_FEET, self::SLOT_NONE, 4, 2.5, [
|
||||||
EntityDamageEvent::CAUSE_FALL
|
EntityDamageEvent::CAUSE_FALL
|
||||||
]));
|
]));
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::BLAST_PROTECTION, "%enchantment.protect.explosion", self::RARITY_RARE, self::SLOT_ARMOR, 4, 1.5, [
|
self::registerEnchantment(new ProtectionEnchantment(self::BLAST_PROTECTION, "%enchantment.protect.explosion", self::RARITY_RARE, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||||
EntityDamageEvent::CAUSE_BLOCK_EXPLOSION,
|
EntityDamageEvent::CAUSE_BLOCK_EXPLOSION,
|
||||||
EntityDamageEvent::CAUSE_ENTITY_EXPLOSION
|
EntityDamageEvent::CAUSE_ENTITY_EXPLOSION
|
||||||
]));
|
]));
|
||||||
self::registerEnchantment(new ProtectionEnchantment(self::PROJECTILE_PROTECTION, "%enchantment.protect.projectile", self::RARITY_UNCOMMON, self::SLOT_ARMOR, 4, 1.5, [
|
self::registerEnchantment(new ProtectionEnchantment(self::PROJECTILE_PROTECTION, "%enchantment.protect.projectile", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||||
EntityDamageEvent::CAUSE_PROJECTILE
|
EntityDamageEvent::CAUSE_PROJECTILE
|
||||||
]));
|
]));
|
||||||
|
|
||||||
self::registerEnchantment(new Enchantment(self::RESPIRATION, "%enchantment.oxygen", self::RARITY_RARE, self::SLOT_HEAD, 3));
|
self::registerEnchantment(new Enchantment(self::RESPIRATION, "%enchantment.oxygen", self::RARITY_RARE, self::SLOT_HEAD, self::SLOT_NONE, 3));
|
||||||
|
|
||||||
self::registerEnchantment(new Enchantment(self::EFFICIENCY, "%enchantment.digging", self::RARITY_COMMON, self::SLOT_DIG | self::SLOT_SHEARS, 5));
|
self::registerEnchantment(new Enchantment(self::EFFICIENCY, "%enchantment.digging", self::RARITY_COMMON, self::SLOT_DIG, self::SLOT_SHEARS, 5));
|
||||||
self::registerEnchantment(new Enchantment(self::SILK_TOUCH, "%enchantment.untouching", self::RARITY_MYTHIC, self::SLOT_DIG | self::SLOT_SHEARS, 1));
|
self::registerEnchantment(new Enchantment(self::SILK_TOUCH, "%enchantment.untouching", self::RARITY_MYTHIC, self::SLOT_DIG, self::SLOT_SHEARS, 1));
|
||||||
self::registerEnchantment(new Enchantment(self::UNBREAKING, "%enchantment.durability", self::RARITY_UNCOMMON, self::SLOT_ALL, 3)); //TODO: item type flags need to be split up
|
self::registerEnchantment(new Enchantment(self::UNBREAKING, "%enchantment.durability", self::RARITY_UNCOMMON, self::SLOT_DIG | self::SLOT_ARMOR | self::SLOT_FISHING_ROD | self::SLOT_BOW, self::SLOT_TOOL | self::SLOT_CARROT_STICK | self::SLOT_ELYTRA, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +153,9 @@ class Enchantment{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $rarity;
|
private $rarity;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $slot;
|
private $primaryItemFlags;
|
||||||
|
/** @var int */
|
||||||
|
private $secondaryItemFlags;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $maxLevel;
|
private $maxLevel;
|
||||||
|
|
||||||
@ -161,14 +163,16 @@ class Enchantment{
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $rarity
|
* @param int $rarity
|
||||||
* @param int $slot
|
* @param int $primaryItemFlags
|
||||||
|
* @param int $secondaryItemFlags
|
||||||
* @param int $maxLevel
|
* @param int $maxLevel
|
||||||
*/
|
*/
|
||||||
public function __construct(int $id, string $name, int $rarity, int $slot, int $maxLevel){
|
public function __construct(int $id, string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel){
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->rarity = $rarity;
|
$this->rarity = $rarity;
|
||||||
$this->slot = $slot;
|
$this->primaryItemFlags = $primaryItemFlags;
|
||||||
|
$this->secondaryItemFlags = $secondaryItemFlags;
|
||||||
$this->maxLevel = $maxLevel;
|
$this->maxLevel = $maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,21 +201,44 @@ class Enchantment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an int with bitflags set to indicate what item types this enchantment can apply to.
|
* Returns a bitset indicating what item types can have this item applied from an enchanting table.
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSlot() : int{
|
public function getPrimaryItemFlags() : int{
|
||||||
return $this->slot;
|
return $this->primaryItemFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this enchantment can apply to the specified item type.
|
* Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from
|
||||||
* @param int $slot
|
* an anvil.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getSecondaryItemFlags() : int{
|
||||||
|
return $this->secondaryItemFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this enchantment can apply to the item type from an enchanting table.
|
||||||
|
*
|
||||||
|
* @param int $flag
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasSlot(int $slot) : bool{
|
public function hasPrimaryItemType(int $flag) : bool{
|
||||||
return ($this->slot & $slot) > 0;
|
return ($this->primaryItemFlags & $flag) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item.
|
||||||
|
*
|
||||||
|
* @param int $flag
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasSecondaryItemType(int $flag) : bool{
|
||||||
|
return ($this->secondaryItemFlags & $flag) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,13 +37,14 @@ class ProtectionEnchantment extends Enchantment{
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param int $rarity
|
* @param int $rarity
|
||||||
* @param int $slot
|
* @param int $primaryItemFlags
|
||||||
|
* @param int $secondaryItemFlags
|
||||||
* @param int $maxLevel
|
* @param int $maxLevel
|
||||||
* @param float $typeModifier
|
* @param float $typeModifier
|
||||||
* @param int[]|null $applicableDamageTypes EntityDamageEvent::CAUSE_* constants which this enchantment type applies to, or null if it applies to all types of damage.
|
* @param int[]|null $applicableDamageTypes EntityDamageEvent::CAUSE_* constants which this enchantment type applies to, or null if it applies to all types of damage.
|
||||||
*/
|
*/
|
||||||
public function __construct(int $id, string $name, int $rarity, int $slot, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes){
|
public function __construct(int $id, string $name, int $rarity, int $primaryItemFlags, int $secondaryItemFlags, int $maxLevel, float $typeModifier, ?array $applicableDamageTypes){
|
||||||
parent::__construct($id, $name, $rarity, $slot, $maxLevel);
|
parent::__construct($id, $name, $rarity, $primaryItemFlags, $secondaryItemFlags, $maxLevel);
|
||||||
|
|
||||||
$this->typeModifier = $typeModifier;
|
$this->typeModifier = $typeModifier;
|
||||||
if($applicableDamageTypes !== null){
|
if($applicableDamageTypes !== null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user