PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Fallable.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17  * @link http://www.pocketmine.net/
18  *
19  *
20 */
21 
22 namespace pocketmine\block;
23 
34 
35 abstract class Fallable extends Solid{
36 
37  public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
38  $ret = $this->getLevel()->setBlock($this, $this, true, true);
39 
40  return $ret;
41  }
42 
43  public function onUpdate($type){
44  if($type === Level::BLOCK_UPDATE_NORMAL){
45  $down = $this->getSide(0);
46  if($down->getId() === self::AIR or ($down instanceof Liquid)){
47  $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
48  "Pos" => new Enum("Pos", [
49  new Double("", $this->x + 0.5),
50  new Double("", $this->y),
51  new Double("", $this->z + 0.5)
52  ]),
53  "Motion" => new Enum("Motion", [
54  new Double("", 0),
55  new Double("", 0),
56  new Double("", 0)
57  ]),
58  "Rotation" => new Enum("Rotation", [
59  new Float("", 0),
60  new Float("", 0)
61  ]),
62  "TileID" => new Int("TileID", $this->getId()),
63  "Data" => new Byte("Data", $this->getDamage()),
64  ]));
65 
66  $fall->spawnToAll();
67  }
68  }
69  }
70 }
static createEntity($type, FullChunk $chunk, Compound $nbt,...$args)
Definition: Entity.php:239
getSide($side, $step=1)
Definition: Block.php:1028