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

@ -537,12 +537,12 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
/** @var Durable[] $equipment */
$equipment = [];
if(($item = $this->inventory->getItemInHand()) instanceof Durable and $item->hasEnchantment(Enchantment::MENDING)){
if(($item = $this->inventory->getItemInHand()) instanceof Durable and $item->hasEnchantment(Enchantment::MENDING())){
$equipment[$mainHandIndex] = $item;
}
//TODO: check offhand
foreach($this->armorInventory->getContents() as $k => $item){
if($item instanceof Durable and $item->hasEnchantment(Enchantment::MENDING)){
if($item instanceof Durable and $item->hasEnchantment(Enchantment::MENDING())){
$equipment[$k] = $item;
}
}
@ -784,7 +784,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
return array_filter(array_merge(
$this->inventory !== null ? array_values($this->inventory->getContents()) : [],
$this->armorInventory !== null ? array_values($this->armorInventory->getContents()) : []
), function(Item $item) : bool{ return !$item->hasEnchantment(Enchantment::VANISHING); });
), function(Item $item) : bool{ return !$item->hasEnchantment(Enchantment::VANISHING()); });
}
public function saveNBT() : CompoundTag{