mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
namespace pocketmine\block;
|
|
|
|
use pocketmine\entity\Entity;
|
|
use pocketmine\item\Item;
|
|
use pocketmine\level\Level;
|
|
use pocketmine\math\Vector3;
|
|
use pocketmine\nbt\tag\Byte;
|
|
use pocketmine\nbt\tag\Compound;
|
|
use pocketmine\nbt\tag\Double;
|
|
use pocketmine\nbt\tag\Enum;
|
|
use pocketmine\nbt\tag\Float;
|
|
use pocketmine\nbt\tag\Int;
|
|
use pocketmine\Player;
|
|
|
|
abstract class Fallable extends Solid{
|
|
|
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
|
$ret = $this->getLevel()->setBlock($this, $this, true, true);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
public function onUpdate($type){
|
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
|
$down = $this->getSide(Vector3::SIDE_DOWN);
|
|
if($down->getId() === self::AIR or ($down instanceof Liquid)){
|
|
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
|
"Pos" => new Enum("Pos", [
|
|
new Double("", $this->x + 0.5),
|
|
new Double("", $this->y),
|
|
new Double("", $this->z + 0.5)
|
|
]),
|
|
"Motion" => new Enum("Motion", [
|
|
new Double("", 0),
|
|
new Double("", 0),
|
|
new Double("", 0)
|
|
]),
|
|
"Rotation" => new Enum("Rotation", [
|
|
new Float("", 0),
|
|
new Float("", 0)
|
|
]),
|
|
"TileID" => new Int("TileID", $this->getId()),
|
|
"Data" => new Byte("Data", $this->getDamage()),
|
|
]));
|
|
|
|
$fall->spawnToAll();
|
|
}
|
|
}
|
|
}
|
|
} |