From dcf344ced9ee8c21864988ebc98b737b696fdbc2 Mon Sep 17 00:00:00 2001 From: banira4649 Date: Sat, 19 Nov 2022 22:35:55 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF?= =?UTF-8?q?=E7=A0=B4=E5=A3=8A=E6=99=82=E3=81=AE=E7=8D=B2=E5=BE=97=E7=B5=8C?= =?UTF-8?q?=E9=A8=93=E5=80=A4=E9=87=8F=E3=82=92=E6=97=A9=E3=81=84=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=9F=E3=83=B3=E3=82=B0=E3=81=A7=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E5=A4=89=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/BlockReformSystem.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/BlockReformSystem.php b/src/core/BlockReformSystem.php index 9983d38..7956c22 100644 --- a/src/core/BlockReformSystem.php +++ b/src/core/BlockReformSystem.php @@ -27,6 +27,18 @@ 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); + $option = $this->reformableBlocks[$stringId]; + $xp = is_null($option->getXpClosure()) ? $event->getXpDropAmount() : $option->getXpClosure()(); + $event->setXpDropAmount($xp); + } + /** * @handleCancelled * @priority HIGHEST @@ -75,7 +87,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); } From 90f5cb39fc393290af289c7718b655b3636f9173 Mon Sep 17 00:00:00 2001 From: banira4649 Date: Sat, 19 Nov 2022 22:58:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?reformableBlocks=E3=81=AB=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E5=AD=98=E5=9C=A8=E3=81=99=E3=82=8B=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E5=87=A6=E7=90=86=E3=82=92=E8=A1=8C=E3=81=86?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/BlockReformSystem.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/BlockReformSystem.php b/src/core/BlockReformSystem.php index 7956c22..19d13e7 100644 --- a/src/core/BlockReformSystem.php +++ b/src/core/BlockReformSystem.php @@ -34,9 +34,11 @@ public function changeXpDropAmount(BlockBreakEvent $event) : void{ $block = $event->getBlock(); $stringId = LegacyBlockIdToStringIdMap::getInstance()->legacyToString($block->getId()); $stringId = str_replace("minecraft:", "", $stringId); - $option = $this->reformableBlocks[$stringId]; - $xp = is_null($option->getXpClosure()) ? $event->getXpDropAmount() : $option->getXpClosure()(); - $event->setXpDropAmount($xp); + if(isset($this->reformableBlocks[$stringId])){ + $option = $this->reformableBlocks[$stringId]; + $xp = is_null($option->getXpClosure()) ? $event->getXpDropAmount() : $option->getXpClosure()(); + $event->setXpDropAmount($xp); + } } /**