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.

Drop2CraftTask.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. use Ad5001\BetterBlocks\Main;
  22. class Drop2CraftTask extends PluginTask {
  23. public function __construct(Main $main) {
  24. parent::__construct($main);
  25. $this->main = $main;
  26. $this->server = $main->getServer();
  27. }
  28. public function onRun($tick) {
  29. foreach($this->server->getLevels() as $level) {
  30. foreach($level->getEntities() as $et) {
  31. if($et instanceof EtItem && isset($et->getItem()->getNamedTag()->isDropedByPlayer)) {
  32. switch($et->getItem()->getId()) {
  33. case 152: // Redstone block: For the Redstone Powering Block
  34. $v3 = $et->round();
  35. $v3->y--;
  36. if($et->getLevel()->getBlock($v3)->isSolid()) {
  37. Tile::createTile("RedstonePoweringTile", $et->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y, "z" => $v3->z], JSON_FORCE_OBJECT)));
  38. $et->close();
  39. }
  40. break;
  41. case 25: // Note block: For the Sound Holding block.
  42. $v3 = $et->round();
  43. $v3->y--;
  44. if($et->getLevel()->getBlock($v3)->isSolid()) {
  45. Tile::createTile("SoundHolderTile", $et->getLevel()->getChunk($et->x >> 4, $et->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y, "z" => $v3->z], JSON_FORCE_OBJECT)));
  46. $et->close();
  47. }
  48. break;
  49. case 69: // Levers drops
  50. $v3 = $et->round();
  51. $v3->y--;
  52. if(isset($et->getItem()->getNamedTag()->isTrapper)) $this->main->getLogger()->debug("Found trapper");
  53. if($et->getLevel()->getBlock($v3)->isSolid() && isset($et->getItem()->getNamedTag()->isTrapper)) {
  54. Tile::createTile("TrapTile", $et->getLevel()->getChunk($v3->x >> 4, $v3->z >> 4), NBT::parseJSON(json_encode(["x" => $v3->x, "y" => $v3->y - 1, "z" => $v3->z], JSON_FORCE_OBJECT)));
  55. $et->close();
  56. }
  57. break;
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }