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.

62 lines
1.5 KiB

  1. <?php
  2. # ____ _ _ ____ _ _
  3. # | __ ) ___ | |_ | |_ ___ _ __ | __ ) | | ___ ___ | | __ ___
  4. # | _ \ / _ \ | __| | __| / _ \ | '__| | _ \ | | / _ \ / __| | |/ / / __|
  5. # | |_) | | __/ | |_ | |_ | __/ | | | |_) | | | | (_) | | (__ | < \__ \
  6. # |____/ \___| \__| \__| \___| |_| |____/ |_| \___/ \___| |_|\_\ |___/
  7. #
  8. # Extends your Minecraft PE blocks palette ! For PocketMine.
  9. namespace Ad5001\BetterBlocks\CustomBlockData;
  10. use pocketmine\Server;
  11. use pocketmine\Player;
  12. use pocketmine\level\format\Chunk;
  13. use pocketmine\nbt\tag\CompoundTag;
  14. use pocketmine\nbt\tag\StringTag;
  15. use Ad5001\BetterBlocks\CustomBlockData;
  16. class StickTile extends CustomBlockData {
  17. public function __construct(Chunk $chunk, CompoundTag $nbt){
  18. if(!isset($nbt->Stickable)) $nbt->Stickable = new StringTag("Stickable", "true");
  19. parent::__construct($chunk, $nbt);
  20. }
  21. /*
  22. Sets if the block can stick when a player walks on it.
  23. @param $stickable bool
  24. */
  25. public function setStickable(bool $stickable) {
  26. if($stickable) {
  27. $this->namedtag->Stickable->setValue("true");
  28. } else {
  29. $this->namedtag->Stickable->setValue("false");
  30. }
  31. return $this;
  32. }
  33. /*
  34. Check if the block is stickable.
  35. @return bool
  36. */
  37. public function isStickable() : bool {
  38. if($this->namedtag->Stickable->getValue() == "false") {
  39. return false;
  40. }
  41. return true;
  42. }
  43. }