Skip to content

Commit

Permalink
Magma walker
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jun 4, 2017
1 parent 726c893 commit fea1559
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PiggyCustomEnchants/CustomEnchants/CustomEnchants.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class CustomEnchants extends Enchantment
const SPRINGS = 501;
const STOMP = 502;
const JETPACK = 503;
const MAGMAWALKER = 504;

//COMPASS
const RADAR = 700;
Expand Down
20 changes: 20 additions & 0 deletions src/PiggyCustomEnchants/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public function onMove(PlayerMoveEvent $event)
return false;
}
$this->checkGlobalEnchants($player, null, $event);
$this->checkArmorEnchants($player, $event);
return true;
}

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/PiggyCustomEnchants/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit fea1559

Please sign in to comment.