Enchantment API changes, understandable constant names

This commit is contained in:
Dylan K. Taylor
2017-05-03 12:07:38 +01:00
parent ecba80fd63
commit 3b7fc21839
3 changed files with 110 additions and 57 deletions

View File

@ -543,8 +543,10 @@ class Item implements ItemIds, \JsonSerializable{
foreach($this->getNamedTag()->ench as $entry){
if($entry["id"] === $id){
$e = Enchantment::getEnchantment($entry["id"]);
$e->setLevel($entry["lvl"]);
return $e;
if($e !== null){
$e->setLevel($entry["lvl"]);
return $e;
}
}
}
@ -627,8 +629,10 @@ class Item implements ItemIds, \JsonSerializable{
if($this->hasEnchantments()){
foreach($this->getNamedTag()->ench as $entry){
$e = Enchantment::getEnchantment($entry["id"]);
$e->setLevel($entry["lvl"]);
$enchantments[] = $e;
if($e !== null){
$e->setLevel($entry["lvl"]);
$enchantments[] = $e;
}
}
}