mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Added BlockMetadataStore to Level and Block
This commit is contained in:
parent
694ccf2bc5
commit
f3e6c726b0
@ -25,12 +25,14 @@
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\metadata\Metadatable;
|
use pocketmine\metadata\Metadatable;
|
||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
abstract class Block extends Position implements Metadatable{
|
abstract class Block extends Position implements Metadatable{
|
||||||
const AIR = 0;
|
const AIR = 0;
|
||||||
@ -774,21 +776,27 @@ abstract class Block extends Position implements Metadatable{
|
|||||||
*/
|
*/
|
||||||
abstract function onUpdate($type);
|
abstract function onUpdate($type);
|
||||||
|
|
||||||
//TODO: Level block metadata
|
|
||||||
|
|
||||||
public function setMetadata($metadataKey, MetadataValue $metadataValue){
|
public function setMetadata($metadataKey, MetadataValue $metadataValue){
|
||||||
//$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $metadataValue);
|
if($this->getLevel() instanceof Level){
|
||||||
|
$this->getLevel()->getBlockMetadata()->setMetadata($this, $metadataKey, $metadataValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetadata($metadataKey){
|
public function getMetadata($metadataKey){
|
||||||
return null; //return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey);
|
if($this->getLevel() instanceof Level){
|
||||||
|
$this->getLevel()->getBlockMetadata()->getMetadata($this, $metadataKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasMetadata($metadataKey){
|
public function hasMetadata($metadataKey){
|
||||||
return false; //return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
|
if($this->getLevel() instanceof Level){
|
||||||
|
$this->getLevel()->getBlockMetadata()->hasMetadata($this, $metadataKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeMetadata($metadataKey, Plugin $plugin){
|
public function removeMetadata($metadataKey, Plugin $plugin){
|
||||||
//$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $plugin);
|
if($this->getLevel() instanceof Level){
|
||||||
|
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ use pocketmine\level\generator\populator\Populator;
|
|||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector2;
|
use pocketmine\math\Vector2;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\metadata\BlockMetadataStore;
|
||||||
use pocketmine\metadata\Metadatable;
|
use pocketmine\metadata\Metadatable;
|
||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
use pocketmine\nbt\tag\Byte;
|
use pocketmine\nbt\tag\Byte;
|
||||||
@ -67,11 +68,6 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
private static $levelIdCounter = 1;
|
private static $levelIdCounter = 1;
|
||||||
|
|
||||||
/** @var Generator */
|
|
||||||
private $generator;
|
|
||||||
/** @var Populator[] */
|
|
||||||
private $populators;
|
|
||||||
|
|
||||||
|
|
||||||
const BLOCK_UPDATE_NORMAL = 1;
|
const BLOCK_UPDATE_NORMAL = 1;
|
||||||
const BLOCK_UPDATE_RANDOM = 2;
|
const BLOCK_UPDATE_RANDOM = 2;
|
||||||
@ -121,6 +117,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
private $autoSave = true;
|
private $autoSave = true;
|
||||||
|
|
||||||
|
/** @var BlockMetadataStore */
|
||||||
|
private $blockMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the chunk unique hash/key
|
* Returns the chunk unique hash/key
|
||||||
*
|
*
|
||||||
@ -151,6 +150,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
*/
|
*/
|
||||||
public function __construct(Server $server, $name, $path, $provider){
|
public function __construct(Server $server, $name, $path, $provider){
|
||||||
$this->levelId = static::$levelIdCounter++;
|
$this->levelId = static::$levelIdCounter++;
|
||||||
|
$this->blockMetadata = new BlockMetadataStore($this);
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
if(is_subclass_of($provider, "pocketmine\\level\\format\\LevelProvider", true)){
|
if(is_subclass_of($provider, "pocketmine\\level\\format\\LevelProvider", true)){
|
||||||
$this->provider = new $provider($this, $path);
|
$this->provider = new $provider($this, $path);
|
||||||
@ -168,6 +168,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->nextSave = microtime(true) + 90;
|
$this->nextSave = microtime(true) + 90;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BlockMetadataStore
|
||||||
|
*/
|
||||||
|
public function getBlockMetadata(){
|
||||||
|
return $this->blockMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Server
|
* @return Server
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user