Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Fourtune because already registered ☠️ #8

Open
wants to merge 2 commits into
base: pm5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions src/DavidGlitch04/VanillaEC/Enchantment/FortuneEnchantment.php

This file was deleted.

45 changes: 0 additions & 45 deletions src/DavidGlitch04/VanillaEC/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace DavidGlitch04\VanillaEC;

use DavidGlitch04\VanillaEC\Enchantment\{BaneOfArthropodsEnchantment,
FortuneEnchantment,
LootingEnchantment,
SmiteEnchantment};
use pocketmine\block\VanillaBlocks;
Expand Down Expand Up @@ -44,7 +43,6 @@ public function onLoad(): void
{
$this->saveDefaultConfig();
$enchants = [
new FortuneEnchantment(),
new LootingEnchantment(),
new SmiteEnchantment(),
new BaneOfArthropodsEnchantment()
Expand All @@ -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
*/
Expand Down