From fea155970f4ede48f92a76d434dd9703ab43a6ed Mon Sep 17 00:00:00 2001 From: "Mr. Piggy" Date: Sat, 3 Jun 2017 19:47:51 -0700 Subject: [PATCH] Magma walker --- .../CustomEnchants/CustomEnchants.php | 1 + src/PiggyCustomEnchants/EventListener.php | 20 +++++++++++++++++++ src/PiggyCustomEnchants/Main.php | 1 + 3 files changed, 22 insertions(+) diff --git a/src/PiggyCustomEnchants/CustomEnchants/CustomEnchants.php b/src/PiggyCustomEnchants/CustomEnchants/CustomEnchants.php index c4d39e44..95435569 100644 --- a/src/PiggyCustomEnchants/CustomEnchants/CustomEnchants.php +++ b/src/PiggyCustomEnchants/CustomEnchants/CustomEnchants.php @@ -88,6 +88,7 @@ class CustomEnchants extends Enchantment const SPRINGS = 501; const STOMP = 502; const JETPACK = 503; + const MAGMAWALKER = 504; //COMPASS const RADAR = 700; diff --git a/src/PiggyCustomEnchants/EventListener.php b/src/PiggyCustomEnchants/EventListener.php index d80816eb..5c5330c8 100644 --- a/src/PiggyCustomEnchants/EventListener.php +++ b/src/PiggyCustomEnchants/EventListener.php @@ -206,6 +206,7 @@ public function onMove(PlayerMoveEvent $event) return false; } $this->checkGlobalEnchants($player, null, $event); + $this->checkArmorEnchants($player, $event); return true; } @@ -914,6 +915,25 @@ public function checkArmorEnchants(Entity $entity, Event $event) } } } + if ($event instanceof PlayerMoveEvent) { + $enchantment = $this->plugin->getEnchantment($entity->getInventory()->getBoots(), CustomEnchants::MAGMAWALKER); + if ($enchantment !== null) { + $block = $entity->getLevel()->getBlock($entity); + if ($block->getId() !== Block::LAVA && $block->getId() !== Block::STILL_LAVA) { + $radius = $enchantment->getLevel() + 2; + for ($x = -$radius; $x <= $radius; $x++) { + for ($z = -$radius; $z <= $radius; $z++) { + $b = $entity->getLevel()->getBlock(new Vector3($entity->x + $x, $entity->y - 1, $entity->z + $z)); + if ($b->getId() == Block::LAVA || $b->getId() == Block::STILL_LAVA) { + if ($entity->getLevel()->getBlock($b->floor()->add(0, 1))->getId() !== Block::LAVA && $entity->getLevel()->getBlock($b->floor()->add(0, 1))->getId() !== Block::STILL_LAVA) { + $entity->getLevel()->setBlock($b, Block::get(Block::OBSIDIAN)); + } + } + } + } + } + } + } if ($event instanceof PlayerToggleSneakEvent) { $shrinkpoints = 0; $growpoints = 0; diff --git a/src/PiggyCustomEnchants/Main.php b/src/PiggyCustomEnchants/Main.php index 837b1e32..ce899d7d 100644 --- a/src/PiggyCustomEnchants/Main.php +++ b/src/PiggyCustomEnchants/Main.php @@ -95,6 +95,7 @@ class Main extends PluginBase CustomEnchants::JETPACK => ["Jetpack", "Boots", "Sneak", "Rare", 5], CustomEnchants::LIFESTEAL => ["Lifesteal", "Weapons", "Damage", "Common", 5], CustomEnchants::LUMBERJACK => ["Lumberjack", "Axe", "Break", "Rare", 1], + CustomEnchants::MAGMAWALKER => ["Magma Walker", "Boots", "Move", "", 2], //TODO: Pick rarity CustomEnchants::MOLOTOV => ["Molotov", "Bow", "Projectile_Hit", "Uncommon", 5], CustomEnchants::MOLTEN => ["Molten", "Armor", "Damaged", "Rare", 5], CustomEnchants::OBSIDIANSHIELD => ["Obsidian Shield", "Armor", "Equip", "Common", 5],