diff --git a/src/core/BlockReformSystem.php b/src/core/BlockReformSystem.php index 9983d38..19d13e7 100644 --- a/src/core/BlockReformSystem.php +++ b/src/core/BlockReformSystem.php @@ -27,6 +27,20 @@ protected function onEnable() : void{ $this->setup(); } + /** + * @priority LOWEST + */ + public function changeXpDropAmount(BlockBreakEvent $event) : void{ + $block = $event->getBlock(); + $stringId = LegacyBlockIdToStringIdMap::getInstance()->legacyToString($block->getId()); + $stringId = str_replace("minecraft:", "", $stringId); + if(isset($this->reformableBlocks[$stringId])){ + $option = $this->reformableBlocks[$stringId]; + $xp = is_null($option->getXpClosure()) ? $event->getXpDropAmount() : $option->getXpClosure()(); + $event->setXpDropAmount($xp); + } + } + /** * @handleCancelled * @priority HIGHEST @@ -75,7 +89,7 @@ public function onBlockBreak(BlockBreakEvent $event) : void{ } } $event->setDrops([]); - $earnXp = is_null($option->getXpClosure()) ? $event->getXpDropAmount() : $option->getXpClosure()(); + $earnXp = $event->getXpDropAmount(); if($earnXp > 0) $player->getXpManager()->onPickupXp($earnXp); $event->setXpDropAmount(0); }