Enchantment: more static getters, firehose magic numbers

This is similar in nature to 646fea5a4e.

On a side note: Migrating this way is a pain in the ass due to lack of types. What the heck is int supposed to mean?!?!?!?! At least if we wanted to go _back_ to magic numbers, it would be easy to locate everything with an Enchantment typehint...
This commit is contained in:
Dylan K. Taylor
2019-02-20 13:45:50 +00:00
parent 646fea5a4e
commit 7170d9009d
11 changed files with 111 additions and 31 deletions

View File

@ -526,7 +526,7 @@ class Block extends Position implements BlockIds, Metadatable{
*/
public function getDrops(Item $item) : array{
if($this->isCompatibleWithTool($item)){
if($this->isAffectedBySilkTouch() and $item->hasEnchantment(Enchantment::SILK_TOUCH)){
if($this->isAffectedBySilkTouch() and $item->hasEnchantment(Enchantment::SILK_TOUCH())){
return $this->getSilkTouchDrops($item);
}
@ -566,7 +566,7 @@ class Block extends Position implements BlockIds, Metadatable{
* @return int
*/
public function getXpDropForTool(Item $item) : int{
if($item->hasEnchantment(Enchantment::SILK_TOUCH) or !$this->isCompatibleWithTool($item)){
if($item->hasEnchantment(Enchantment::SILK_TOUCH()) or !$this->isCompatibleWithTool($item)){
return 0;
}

View File

@ -56,7 +56,7 @@ class Ice extends Transparent{
}
public function onBreak(Item $item, Player $player = null) : bool{
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH)){
if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){
return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER));
}
return parent::onBreak($item, $player);

View File

@ -55,7 +55,7 @@ class TNT extends Solid{
}
public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($item instanceof FlintSteel or $item->hasEnchantment(Enchantment::FIRE_ASPECT)){
if($item instanceof FlintSteel or $item->hasEnchantment(Enchantment::FIRE_ASPECT())){
if($item instanceof Durable){
$item->applyDamage(1);
}