The same blocks, simply better. For PocketMine & forks.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.0 KiB

  1. <?php
  2. # ____ _ _ ____ _ _
  3. # | __ ) ___ | |_ | |_ ___ _ __ | __ ) | | ___ ___ | | __ ___
  4. # | _ \ / _ \ | __| | __| / _ \ | '__| | _ \ | | / _ \ / __| | |/ / / __|
  5. # | |_) | | __/ | |_ | |_ | __/ | | | |_) | | | | (_) | | (__ | < \__ \
  6. # |____/ \___| \__| \__| \___| |_| |____/ |_| \___/ \___| |_|\_\ |___/
  7. #
  8. # Extends your Minecraft PE blocks palette ! For PocketMine.
  9. namespace Ad5001\BetterBlocks\tasks;
  10. use pocketmine\Server;
  11. use pocketmine\scheduler\PluginTask;
  12. use pocketmine\Player;
  13. use pocketmine\nbt\NBT;
  14. use pocketmine\tile\Tile;
  15. use pocketmine\item\Item;
  16. use pocketmine\entity\Item as EtItem;
  17. use Ad5001\BetterBlocks\CustomBlockData;
  18. use Ad5001\BetterBlocks\CustomBlockData\FallableTile;
  19. use Ad5001\BetterBlocks\CustomBlockData\RedstonePoweringTile;
  20. use Ad5001\BetterBlocks\CustomBlockData\SoundHolderTile;
  21. class Drop2CraftTask extends PluginTask {
  22. public function __construct(Main $main) {
  23. parent::__construct($main);
  24. $this->main = $main;
  25. $this->server = $main->getServer();
  26. }
  27. public function onRun($tick) {
  28. foreach($this->server->getLevels() as $level) {
  29. foreach($level->getEntities() as $et) {
  30. if($et instanceof EtItem && isset($et->getItem()->getNamedTag()->isDropedByPlayer)) {
  31. switch($et->getItem()->getId()) {
  32. case 152: // Redstone block: For the Redstone Powering Block
  33. $v3 = $et->round();
  34. $v3->y--;
  35. if($et->getLevel()->getBlock($v3)->isSolid()) {
  36. Tile::createTile("RedstonePoweringTile", $this->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y, $v3->z])));
  37. $et->close();
  38. }
  39. break;
  40. case 25: // Note block: For the Sound Holding block.
  41. $v3 = $et->round();
  42. $v3->y--;
  43. if($et->getLevel()->getBlock($v3)->isSolid()) {
  44. Tile::createTile("SoundHolderTile", $this->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y, $v3->z])));
  45. $et->close();
  46. }
  47. break;
  48. case 69: // Levers drops
  49. $v3 = $et->round();
  50. $v3->y--;
  51. if($et->getLevel()->getBlock($v3)->isSolid() && isset($et->getItem()->getNamedTag()->isTrapper)) {
  52. Tile::createTile("TrapTile", $v3->getLevel()->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode([$v3->x, $v3->y - 1, $v3->z])));
  53. $et->close();
  54. }
  55. break;
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }