From 77411edf1a09e9e10128d202fe1b25191c7c22dc Mon Sep 17 00:00:00 2001 From: Biswajit <121815367+GabBiswajit@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:12:26 +0530 Subject: [PATCH 1/2] Delete src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php --- .../Enchantment/FortuneEnchantment.php | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php diff --git a/src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php b/src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php deleted file mode 100644 index 8a4c577..0000000 --- a/src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php +++ /dev/null @@ -1,56 +0,0 @@ - Date: Thu, 11 Jan 2024 13:13:50 +0530 Subject: [PATCH 2/2] =?UTF-8?q?Fourtune=20is=20already=20registered=20?= =?UTF-8?q?=E2=98=A0=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DavidGlitch04/VanillaEC/Main.php | 45 ---------------------------- 1 file changed, 45 deletions(-) diff --git a/src/DavidGlitch04/VanillaEC/Main.php b/src/DavidGlitch04/VanillaEC/Main.php index 339374e..f0eadf5 100644 --- a/src/DavidGlitch04/VanillaEC/Main.php +++ b/src/DavidGlitch04/VanillaEC/Main.php @@ -5,7 +5,6 @@ namespace DavidGlitch04\VanillaEC; use DavidGlitch04\VanillaEC\Enchantment\{BaneOfArthropodsEnchantment, - FortuneEnchantment, LootingEnchantment, SmiteEnchantment}; use pocketmine\block\VanillaBlocks; @@ -44,7 +43,6 @@ public function onLoad(): void { $this->saveDefaultConfig(); $enchants = [ - new FortuneEnchantment(), new LootingEnchantment(), new SmiteEnchantment(), new BaneOfArthropodsEnchantment() @@ -59,49 +57,6 @@ public function onEnable(): void { $this->getServer()->getPluginManager()->registerEvents($this, $this); } - - /** - * @param BlockBreakEvent $event - */ - public function onBreak(BlockBreakEvent $event): void - { - $block = $event->getBlock(); - $item = $event->getItem(); - $enchantment = new FortuneEnchantment(); - - if ($block->isSameState(VanillaBlocks::OAK_LEAVES())) { - if (mt_rand(1, 99) <= 10) { - $event->setDrops([VanillaItems::APPLE()]); - } - } - - if (($level = $item->getEnchantmentLevel(EnchantmentIdMap::getInstance()->fromId($enchantment->getMcpeId()))) > 0) { - $add = mt_rand(0, $level + 1); - - if ($block->isSameState(VanillaBlocks::OAK_LEAVES())) { - if (mt_rand(1, 99) <= 10) { - $event->setDrops([VanillaItems::APPLE()]); - } - } - - foreach ($this->getConfig()->get("fortune.blocks", []) as $str) { - $itemFortune = LegacyStringToItemParser::getInstance()->parse($str); - - if ($block->asItem()->equals($itemFortune)) { - if (mt_rand(1, 99) <= 10 * $level) { - if (!empty($event->getDrops())) { - $event->setDrops(array_map(function (Item $drop) use ($add) { - $drop->setCount($drop->getCount() + $add); - return $drop; - }, $event->getDrops())); - } - } - break; - } - } - } - } - /** * @param EntityDamageByEntityEvent $event */