More docs

This commit is contained in:
Shoghi Cervantes 2014-03-14 03:11:23 +01:00
parent 3ff8ddc652
commit 6f0f86dc0c
8 changed files with 972 additions and 725 deletions

View File

@ -21,7 +21,13 @@
namespace PocketMine; namespace PocketMine;
/**
* Handles the achievement list and a bit more
*/
abstract class Achievement{ abstract class Achievement{
/**
* @var array[]
*/
public static $list = array( public static $list = array(
/*"openInventory" => array( /*"openInventory" => array(
"name" => "Taking Inventory", "name" => "Taking Inventory",

View File

@ -22,6 +22,10 @@
namespace PocketMine; namespace PocketMine;
class ChatAPI{ class ChatAPI{
/**
* @var Server
*/
private $server; private $server;
function __construct(){ function __construct(){

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,9 @@ namespace PocketMine\Block;
use PocketMine; use PocketMine;
/**
* Air block
*/
class Air extends Transparent{ class Air extends Transparent{
public function __construct(){ public function __construct(){
parent::__construct(self::AIR, 0, "Air"); parent::__construct(self::AIR, 0, "Air");

View File

@ -31,6 +31,8 @@ interface InventorySource{
public function canAddItem(Item $item); public function canAddItem(Item $item);
/** /**
* @param Item $item
*
* @return boolean hasBeenAdded * @return boolean hasBeenAdded
*/ */
public function addItem(Item $item); public function addItem(Item $item);
@ -38,6 +40,9 @@ interface InventorySource{
public function canRemoveItem(Item $item, $checkDamage = true); public function canRemoveItem(Item $item, $checkDamage = true);
/** /**
* @param Item $item
* @param boolean $checkDamage
*
* @return boolean hasBeenRemoved * @return boolean hasBeenRemoved
*/ */
public function removeItem(Item $item, $checkDamage = true); public function removeItem(Item $item, $checkDamage = true);

View File

@ -23,6 +23,9 @@ namespace PocketMine\Event;
use PocketMine; use PocketMine;
/**
* Triggers events and its handlers in the correct order, attaching and removing from them
*/
abstract class EventHandler{ abstract class EventHandler{
public static function callEvent(Event $event){ public static function callEvent(Event $event){

View File

@ -23,6 +23,9 @@ namespace PocketMine\Event;
use PocketMine; use PocketMine;
/**
* List of event prioritoes
*/
abstract class EventPriority{ abstract class EventPriority{
/** /**
* Event call is of very low importance and should be ran first, to allow * Event call is of very low importance and should be ran first, to allow

View File

@ -818,26 +818,65 @@ class Level{
return true; return true;
} }
/**
* Gets the biome ID of a column
*
* @param int $x
* @param int $z
*
* @return int
*/
public function getBiome($x, $z){ public function getBiome($x, $z){
return $this->level->getBiome((int) $x, (int) $z); return $this->level->getBiome((int) $x, (int) $z);
} }
/**
* Sets the biome ID for a column
*
* @param int $x
* @param int $z
* @param int $biome
*
* @return int
*/
public function setBiome($x, $z, $biome){ public function setBiome($x, $z, $biome){
return $this->level->getBiome((int) $x, (int) $z, $biome); return $this->level->getBiome((int) $x, (int) $z, $biome);
} }
/**
* Gets the list of all the entitites in this level
*
* @return Entity[]
*/
public function getEntities(){ public function getEntities(){
return $this->entities; return $this->entities;
} }
/**
* Returns a list of the Tile entities in this level
*
* @return Tile[]
*/
public function getTiles(){ public function getTiles(){
return $this->tiles; return $this->tiles;
} }
/**
* Returns a list of the players in this level
*
* @return Player[]
*/
public function getPlayers(){ public function getPlayers(){
return $this->players; return $this->players;
} }
/**
* Returns the Tile in a position, or false if not found
*
* @param Vector3 $pos
*
* @return bool|Tile
*/
public function getTile(Vector3 $pos){ public function getTile(Vector3 $pos){
if($pos instanceof Position and $pos->level !== $this){ if($pos instanceof Position and $pos->level !== $this){
return false; return false;
@ -854,10 +893,29 @@ class Level{
return false; return false;
} }
/**
* Gets a raw minichunk
*
* @param int $X
* @param int $Z
* @param int $Y
*
* @return string
*/
public function getMiniChunk($X, $Z, $Y){ public function getMiniChunk($X, $Z, $Y){
return $this->level->getMiniChunk($X, $Z, $Y); return $this->level->getMiniChunk($X, $Z, $Y);
} }
/**
* Sets a raw minichunk
*
* @param int $X
* @param int $Z
* @param int $Y
* @param string $data (must be 4096 bytes)
*
* @return bool
*/
public function setMiniChunk($X, $Z, $Y, $data){ public function setMiniChunk($X, $Z, $Y, $data){
$this->changedCount[$X . ":" . $Y . ":" . $Z] = 4096; $this->changedCount[$X . ":" . $Y . ":" . $Z] = 4096;
if(ADVANCED_CACHE == true){ if(ADVANCED_CACHE == true){
@ -867,6 +925,14 @@ class Level{
return $this->level->setMiniChunk($X, $Z, $Y, $data); return $this->level->setMiniChunk($X, $Z, $Y, $data);
} }
/**
* Returns a list of the entities on a given chunk
*
* @param int $X
* @param int $Z
*
* @return array
*/
public function getChunkEntities($X, $Z){ public function getChunkEntities($X, $Z){
$index = LevelFormat::getIndex($X, $Z); $index = LevelFormat::getIndex($X, $Z);
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){ if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
@ -876,6 +942,14 @@ class Level{
return array(); return array();
} }
/**
* Gives a list of the Tile entities on a given chunk
*
* @param int $X
* @param int $Z
*
* @return array
*/
public function getChunkTiles($X, $Z){ public function getChunkTiles($X, $Z){
$index = LevelFormat::getIndex($X, $Z); $index = LevelFormat::getIndex($X, $Z);
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){ if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
@ -885,7 +959,14 @@ class Level{
return array(); return array();
} }
/**
* Loads a chunk
*
* @param int $X
* @param int $Z
*
* @return bool
*/
public function loadChunk($X, $Z){ public function loadChunk($X, $Z){
$index = LevelFormat::getIndex($X, $Z); $index = LevelFormat::getIndex($X, $Z);
if(isset($this->usedChunks[$index])){ if(isset($this->usedChunks[$index])){
@ -927,6 +1008,15 @@ class Level{
return false; return false;
} }
/**
* Unloads a chunk
*
* @param int $X
* @param int $Z
* @param bool $force
*
* @return bool
*/
public function unloadChunk($X, $Z, $force = false){ public function unloadChunk($X, $Z, $force = false){
if(!isset($this->level)){ if(!isset($this->level)){
return false; return false;
@ -944,6 +1034,14 @@ class Level{
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled); return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
} }
/**
* Returns true if the spawn is part of the spawn
*
* @param int $X
* @param int $Z
*
* @return bool
*/
public function isSpawnChunk($X, $Z){ public function isSpawnChunk($X, $Z){
$spawnX = $this->level->getData("spawnX") >> 4; $spawnX = $this->level->getData("spawnX") >> 4;
$spawnZ = $this->level->getData("spawnZ") >> 4; $spawnZ = $this->level->getData("spawnZ") >> 4;
@ -951,6 +1049,15 @@ class Level{
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1; return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
} }
/**
* Gets a full chunk or parts of it for networking usage, allows cache usage
*
* @param int $X
* @param int $Z
* @param int $Yndex bitmap of chunks to be returned
*
* @return bool|mixed|string
*/
public function getOrderedChunk($X, $Z, $Yndex){ public function getOrderedChunk($X, $Z, $Yndex){
if(!isset($this->level)){ if(!isset($this->level)){
return false; return false;
@ -985,6 +1092,15 @@ class Level{
return $ordered; return $ordered;
} }
/**
* Returns the network minichunk for a given Y
*
* @param int $X
* @param int $Z
* @param int $Y
*
* @return bool|string
*/
public function getOrderedMiniChunk($X, $Z, $Y){ public function getOrderedMiniChunk($X, $Z, $Y){
if(!isset($this->level)){ if(!isset($this->level)){
return false; return false;
@ -999,6 +1115,11 @@ class Level{
return $ordered; return $ordered;
} }
/**
* Returns the raw spawnpoint
*
* @return Position
*/
public function getSpawn(){ public function getSpawn(){
return new Position($this->level->getData("spawnX"), $this->level->getData("spawnY"), $this->level->getData("spawnZ"), $this); return new Position($this->level->getData("spawnX"), $this->level->getData("spawnY"), $this->level->getData("spawnZ"), $this);
} }
@ -1042,42 +1163,80 @@ class Level{
return false; return false;
} }
/**
* Sets the spawnpoint
*
* @param Vector3 $pos
*/
public function setSpawn(Vector3 $pos){ public function setSpawn(Vector3 $pos){
$this->level->setData("spawnX", $pos->x); $this->level->setData("spawnX", $pos->x);
$this->level->setData("spawnY", $pos->y); $this->level->setData("spawnY", $pos->y);
$this->level->setData("spawnZ", $pos->z); $this->level->setData("spawnZ", $pos->z);
} }
/**
* Gets the current time
*
* @return int
*/
public function getTime(){ public function getTime(){
return (int) ($this->time); return (int) $this->time;
} }
/**
* Returns the Level name
*
* @return string
*/
public function getName(){ public function getName(){
return $this->name; //return $this->level->getData("name"); return $this->name; //return $this->level->getData("name");
} }
/**
* Sets the current time on the level
*
* @param int $time
*/
public function setTime($time){ public function setTime($time){
$this->startTime = $this->time = (int) $time; $this->startTime = $this->time = (int) $time;
$this->startCheck = microtime(true); $this->startCheck = microtime(true);
$this->checkTime(); $this->checkTime();
} }
/**
* Stops the time for the level, will not save the lock state to disk
*/
public function stopTime(){ public function stopTime(){
$this->stopTime = true; $this->stopTime = true;
$this->startCheck = 0; $this->startCheck = 0;
$this->checkTime(); $this->checkTime();
} }
/**
* Start the time again, if it was stopped
*/
public function startTime(){ public function startTime(){
$this->stopTime = false; $this->stopTime = false;
$this->startCheck = microtime(true); $this->startCheck = microtime(true);
$this->checkTime(); $this->checkTime();
} }
/**
* Gets the level seed
*
* @return int
*/
public function getSeed(){ public function getSeed(){
return (int) $this->level->getData("seed"); return (int) $this->level->getData("seed");
} }
/**
* Sets the seed for the level
*
* @param int $seed
*
* @return bool
*/
public function setSeed($seed){ public function setSeed($seed){
if(!isset($this->level)){ if(!isset($this->level)){
return false; return false;