Removed code remove comments

This commit is contained in:
Shoghi Cervantes 2014-03-06 13:16:44 +01:00
parent bbd66e6ad1
commit c08bf3ef86
350 changed files with 6317 additions and 5559 deletions

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
abstract class Achievement{ abstract class Achievement{
@ -30,8 +31,7 @@ abstract class Achievement{
),*/ ),*/
"mineWood" => array( "mineWood" => array(
"name" => "Getting Wood", "name" => "Getting Wood",
"requires" => array( "requires" => array(//"openInventory",
//"openInventory",
), ),
), ),
"buildWorkBench" => array( "buildWorkBench" => array(
@ -108,8 +108,10 @@ abstract class Achievement{
$player->sendChat("You have just earned the achievement " . Achievement::$list[$achievementId]["name"]); $player->sendChat("You have just earned the achievement " . Achievement::$list[$achievementId]["name"]);
} }
} }
return true; return true;
} }
return false; return false;
} }
@ -119,8 +121,10 @@ abstract class Achievement{
"name" => $achievementName, "name" => $achievementName,
"requires" => $requires, "requires" => $requires,
); );
return true; return true;
} }
return false; return false;
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Utils\Config as Config; use PocketMine\Utils\Config as Config;
use PocketMine\Player as Player; use PocketMine\Player as Player;
@ -83,6 +84,7 @@ class BanAPI{
} elseif($this->ops->exists($username)){ } elseif($this->ops->exists($username)){
return true; return true;
} }
return false; return false;
} }
@ -108,6 +110,7 @@ class BanAPI{
return false; return false;
} }
} }
return; return;
case "console.command": //Checks if a command is allowed with the current user permissions. case "console.command": //Checks if a command is allowed with the current user permissions.
if(isset($this->cmdWhitelist[$data["cmd"]])){ if(isset($this->cmdWhitelist[$data["cmd"]])){
@ -121,6 +124,7 @@ class BanAPI{
} elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){ } elseif($data["issuer"] === "console" or $data["issuer"] === "rcon"){
return; return;
} }
return false; return false;
} }
} }
@ -148,7 +152,7 @@ class BanAPI{
break; break;
case "op": case "op":
$user = strtolower($params[0]); $user = strtolower($params[0]);
if($user == NULL){ if($user == null){
$output .= "Usage: /op <player>\n"; $output .= "Usage: /op <player>\n";
break; break;
} }
@ -310,6 +314,7 @@ class BanAPI{
} }
break; break;
} }
return $output; return $output;
} }
@ -400,6 +405,7 @@ class BanAPI{
} elseif($this->whitelist->exists($username, true)){ } elseif($this->whitelist->exists($username, true)){
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\Level\Position as Position; use PocketMine\Level\Position as Position;
use PocketMine\Block\GenericBlock as GenericBlock; use PocketMine\Block\GenericBlock as GenericBlock;
use PocketMine\Item\Item as Item; use PocketMine\Item\Item as Item;
@ -237,6 +238,7 @@ class BlockAPI{
foreach(explode(",", $str) as $b){ foreach(explode(",", $str) as $b){
$blocks[] = BlockAPI::fromString($b, false); $blocks[] = BlockAPI::fromString($b, false);
} }
return $blocks; return $blocks;
} else{ } else{
$b = explode(":", str_replace(" ", "_", trim($str))); $b = explode(":", str_replace(" ", "_", trim($str)));
@ -254,6 +256,7 @@ class BlockAPI{
} else{ } else{
$item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta); $item = BlockAPI::getItem(((int) $b[0]) & 0xFFFF, $meta);
} }
return $item; return $item;
} }
} }
@ -268,6 +271,7 @@ class BlockAPI{
if($v instanceof Position){ if($v instanceof Position){
$b->position($v); $b->position($v);
} }
return $b; return $b;
} }
@ -279,6 +283,7 @@ class BlockAPI{
} else{ } else{
$i = new Item($id, $meta, $count); $i = new Item($id, $meta, $count);
} }
return $i; return $i;
} }
@ -325,6 +330,7 @@ class BlockAPI{
break; break;
} }
return $output; return $output;
} }
@ -339,6 +345,7 @@ class BlockAPI{
if($send === true){ if($send === true){
$player->sendInventorySlot($player->slot); $player->sendInventorySlot($player->slot);
} }
return false; return false;
} }
@ -379,6 +386,7 @@ class BlockAPI{
//$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2])); //$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
} }
} }
return false; return false;
} }
@ -398,6 +406,7 @@ class BlockAPI{
if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE if($target->getID() === AIR and $this->server->api->dhandle("player.block.place.invalid", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ //If no block exists or not allowed in CREATIVE
if($this->server->api->dhandle("player.block.place.bypass", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){ if($this->server->api->dhandle("player.block.place.bypass", array("player" => $player, "block" => $block, "target" => $target, "item" => $item)) !== true){
$this->cancelAction($target, $player); $this->cancelAction($target, $player);
return $this->cancelAction($block, $player); return $this->cancelAction($block, $player);
} }
} }
@ -429,6 +438,7 @@ class BlockAPI{
if($item->getCount() <= 0){ if($item->getCount() <= 0){
$player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0)); $player->setSlot($player->slot, BlockAPI::getItem(AIR, 0, 0));
} }
return false; return false;
} }
@ -437,6 +447,7 @@ class BlockAPI{
$hand->position($block); $hand->position($block);
} elseif($block->getID() === FIRE){ } elseif($block->getID() === FIRE){
$player->level->setBlock($block, new Block\AirBlock(), true, false, true); $player->level->setBlock($block, new Block\AirBlock(), true, false, true);
return false; return false;
} else{ } else{
return $this->cancelAction($block, $player, false); return $this->cancelAction($block, $player, false);
@ -519,6 +530,7 @@ class BlockAPI{
if($level === BLOCK_UPDATE_NORMAL){ if($level === BLOCK_UPDATE_NORMAL){
$this->blockUpdateAround($block, $level); $this->blockUpdateAround($block, $level);
} }
return $level; return $level;
} }
@ -533,8 +545,10 @@ class BlockAPI{
if(!isset($this->scheduledUpdates[$index])){ if(!isset($this->scheduledUpdates[$index])){
$this->scheduledUpdates[$index] = $pos; $this->scheduledUpdates[$index] = $pos;
$this->server->query("INSERT INTO blockUpdates (x, y, z, level, type, delay) VALUES (" . $pos->x . ", " . $pos->y . ", " . $pos->z . ", '" . $pos->level->getName() . "', " . $type . ", " . $delay . ");"); $this->server->query("INSERT INTO blockUpdates (x, y, z, level, type, delay) VALUES (" . $pos->x . ", " . $pos->y . ", " . $pos->z . ", '" . $pos->level->getName() . "', " . $type . ", " . $delay . ");");
return true; return true;
} }
return false; return false;
} }

View File

@ -20,11 +20,13 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Player as Player; use PocketMine\Player as Player;
class ChatAPI{ class ChatAPI{
private $server; private $server;
function __construct(){ function __construct(){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
} }
@ -100,6 +102,7 @@ class ChatAPI{
} }
break; break;
} }
return $output; return $output;
} }

View File

@ -20,12 +20,14 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Utils\TextFormat as TextFormat; use PocketMine\Utils\TextFormat as TextFormat;
use PocketMine\Player as Player; use PocketMine\Player as Player;
class ConsoleAPI{ class ConsoleAPI{
private $loop, $server, $event, $help, $cmds, $alias; private $loop, $server, $event, $help, $cmds, $alias;
function __construct(){ function __construct(){
$this->help = array(); $this->help = array();
$this->cmds = array(); $this->cmds = array();
@ -151,11 +153,13 @@ class ConsoleAPI{
$output .= "Command doesn't exist! Use /help\n"; $output .= "Command doesn't exist! Use /help\n";
break; break;
} }
return $output; return $output;
} }
public function alias($alias, $cmd){ public function alias($alias, $cmd){
$this->alias[strtolower(trim($alias))] = trim($cmd); $this->alias[strtolower(trim($alias))] = trim($cmd);
return true; return true;
} }
@ -226,6 +230,7 @@ class ConsoleAPI{
$output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias); $output .= $this->run($cmd . " " . substr_replace($params, $p->getUsername(), $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1), $issuer, $alias);
} }
} }
return $output; return $output;
case "r": case "r":
case "random": case "random":
@ -252,7 +257,8 @@ class ConsoleAPI{
} }
if(($d1 = $this->server->api->dhandle("console.command." . $cmd, array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false if(($d1 = $this->server->api->dhandle("console.command." . $cmd, array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false
or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false){ or ($d2 = $this->server->api->dhandle("console.command", array("cmd" => $cmd, "parameters" => $params, "issuer" => $issuer, "alias" => $alias))) === false
){
$output = "You don't have permissions to use this command.\n"; $output = "You don't have permissions to use this command.\n";
} elseif($d1 !== true and (!isset($d2) or $d2 !== true)){ } elseif($d1 !== true and (!isset($d2) or $d2 !== true)){
if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){ if(isset($this->cmds[$cmd]) and is_callable($this->cmds[$cmd])){
@ -265,6 +271,7 @@ class ConsoleAPI{
if($output != "" and ($issuer instanceof Player)){ if($output != "" and ($issuer instanceof Player)){
$issuer->sendChat(trim($output)); $issuer->sendChat(trim($output));
} }
return $output; return $output;
} }
} }
@ -296,6 +303,7 @@ class ConsoleLoop extends \Thread{
public $base; public $base;
public $ev; public $ev;
public $fp; public $fp;
public function __construct(){ public function __construct(){
$this->line = false; $this->line = false;
$this->stop = false; $this->stop = false;
@ -315,6 +323,7 @@ class ConsoleLoop extends \Thread{
readline_add_history($line); readline_add_history($line);
} }
} }
return $line; return $line;
} }

View File

@ -20,10 +20,12 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine; use PocketMine;
class Container{ class Container{
private $payload = "", $whitelist = false, $blacklist = false; private $payload = "", $whitelist = false, $blacklist = false;
public function __construct($payload = "", $whitelist = false, $blacklist = false){ public function __construct($payload = "", $whitelist = false, $blacklist = false){
$this->payload = $payload; $this->payload = $payload;
if(is_array($whitelist)){ if(is_array($whitelist)){
@ -60,6 +62,7 @@ class Container{
if($w === false or $b === true){ if($w === false or $b === true){
return false; return false;
} }
return true; return true;
} }

View File

@ -22,6 +22,7 @@
//TODO: REMOVE //TODO: REMOVE
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
class Deprecation{ class Deprecation{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Level\Generator\Flat as Flat; use PocketMine\Level\Generator\Flat as Flat;
use PocketMine\Level\Generator\Normal as Normal; use PocketMine\Level\Generator\Normal as Normal;
@ -44,6 +45,7 @@ use PocketMine\Level\Position as Position;
class LevelAPI{ class LevelAPI{
private $server, $levels, $default; private $server, $levels, $default;
public function __construct(){ public function __construct(){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
$this->levels = array(); $this->levels = array();
@ -53,6 +55,7 @@ class LevelAPI{
if(isset($this->levels[$name])){ if(isset($this->levels[$name])){
return $this->levels[$name]; return $this->levels[$name];
} }
return false; return false;
} }
@ -99,6 +102,7 @@ class LevelAPI{
$output .= "Seed: " . $this->server->api->level->getDefault()->getSeed() . "\n"; $output .= "Seed: " . $this->server->api->level->getDefault()->getSeed() . "\n";
} }
} }
return $output; return $output;
} }
@ -123,6 +127,7 @@ class LevelAPI{
$gen = new WorldGenerator($generator, $name, $seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)) : (int) $seed); $gen = new WorldGenerator($generator, $name, $seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)) : (int) $seed);
$gen->generate(); $gen->generate();
$gen->close(); $gen->close();
return true; return true;
} }
@ -137,6 +142,7 @@ class LevelAPI{
return false; return false;
} }
} }
return true; return true;
} }
@ -153,6 +159,7 @@ class LevelAPI{
} }
$level->close(); $level->close();
unset($this->levels[$name]); unset($this->levels[$name]);
return true; return true;
} }
@ -161,6 +168,7 @@ class LevelAPI{
return true; return true;
} elseif($this->levelExists($name) === false){ } elseif($this->levelExists($name) === false){
console("[NOTICE] Level \"" . $name . "\" not found"); console("[NOTICE] Level \"" . $name . "\" not found");
return false; return false;
} }
$path = \PocketMine\DATA . "worlds/" . $name . "/"; $path = \PocketMine\DATA . "worlds/" . $name . "/";
@ -168,6 +176,7 @@ class LevelAPI{
$level = new LevelFormat($path . "level.pmf"); $level = new LevelFormat($path . "level.pmf");
if(!$level->isLoaded){ if(!$level->isLoaded){
console("[ERROR] Could not load level \"" . $name . "\""); console("[ERROR] Could not load level \"" . $name . "\"");
return false; return false;
} }
//$entities = new Config($path."entities.yml", Config::YAML); //$entities = new Config($path."entities.yml", Config::YAML);
@ -272,6 +281,7 @@ class LevelAPI{
foreach($blockUpdates->getAll() as $bupdate){ foreach($blockUpdates->getAll() as $bupdate){
$this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]); $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
} }
return true; return true;
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\Entity\RealHuman as RealHuman; use PocketMine\Entity\RealHuman as RealHuman;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\NBT\Tag\Compound as Compound; use PocketMine\NBT\Tag\Compound as Compound;
@ -273,23 +274,27 @@ class Player extends RealHuman{
if($this->server->api->dhandle("achievement.grant", array("player" => $this, "achievementId" => $achievementId)) !== false){ if($this->server->api->dhandle("achievement.grant", array("player" => $this, "achievementId" => $achievementId)) !== false){
$this->achievements[$achievementId] = true; $this->achievements[$achievementId] = true;
Achievement::broadcast($this, $achievementId); Achievement::broadcast($this, $achievementId);
return true; return true;
} else{ } else{
return false; return false;
} }
} }
return false; return false;
} }
public function hasAchievement($achievementId){ public function hasAchievement($achievementId){
if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){ if(!isset(Achievement::$list[$achievementId]) or !isset($this->achievements)){
$this->achievements = array(); $this->achievements = array();
return false; return false;
} }
if(!isset($this->achievements[$achievementId]) or $this->achievements[$achievementId] == false){ if(!isset($this->achievements[$achievementId]) or $this->achievements[$achievementId] == false){
return false; return false;
} }
return true; return true;
} }
@ -452,6 +457,7 @@ class Player extends RealHuman{
$this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk")); $this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk"));
++$this->chunkScheduled; ++$this->chunkScheduled;
} }
return; return;
} else{ } else{
unset($this->chunkCount[$count]); unset($this->chunkCount[$count]);
@ -478,6 +484,7 @@ class Player extends RealHuman{
if($this->chunkScheduled === 0){ if($this->chunkScheduled === 0){
$this->server->schedule(40, array($this, "getNextChunk")); $this->server->schedule(40, array($this, "getNextChunk"));
} }
return false; return false;
} }
$X = null; $X = null;
@ -489,6 +496,7 @@ class Player extends RealHuman{
$this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk")); $this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk"));
++$this->chunkScheduled; ++$this->chunkScheduled;
} }
return false; return false;
} }
unset($this->chunksOrder[$index]); unset($this->chunksOrder[$index]);
@ -604,6 +612,7 @@ class Player extends RealHuman{
}*/ }*/
$this->setSpawn($pos); $this->setSpawn($pos);
$this->server->schedule(60, array($this, "checkSleep")); $this->server->schedule(60, array($this, "checkSleep"));
return true; return true;
} }
@ -632,7 +641,8 @@ class Player extends RealHuman{
public function sendInventorySlot($s){ public function sendInventorySlot($s){
$this->sendInventory(); $this->sendInventory();
return;
return; //TODO: Check if Mojang adds this
$s = (int) $s; $s = (int) $s;
if(!isset($this->inventory[$s])){ if(!isset($this->inventory[$s])){
$pk = new Network\Protocol\ContainerSetSlotPacket; $pk = new Network\Protocol\ContainerSetSlotPacket;
@ -648,6 +658,7 @@ class Player extends RealHuman{
$pk->slot = (int) $s; $pk->slot = (int) $s;
$pk->item = $slot; $pk->item = $slot;
$this->dataPacket($pk); $this->dataPacket($pk);
return true; return true;
} }
@ -952,6 +963,7 @@ class Player extends RealHuman{
} }
} }
} }
return $res; return $res;
} }
@ -994,6 +1006,7 @@ class Player extends RealHuman{
$this->inventory = $inv; $this->inventory = $inv;
$this->sendSettings(); $this->sendSettings();
$this->sendInventory(); $this->sendInventory();
return true; return true;
} }
@ -1051,6 +1064,7 @@ class Player extends RealHuman{
$time = microtime(true); $time = microtime(true);
if($time > $this->timeout){ if($time > $this->timeout){
$this->close("timeout"); $this->close("timeout");
return false; return false;
} }
@ -1232,6 +1246,7 @@ class Player extends RealHuman{
$this->loginData = array("clientId" => $packet->clientId, "loginData" => $packet->loginData); $this->loginData = array("clientId" => $packet->clientId, "loginData" => $packet->loginData);
if(count(Player::$list) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){ if(count(Player::$list) > $this->server->maxClients and !$this->server->api->ban->isOp($this->iusername)){
$this->close("server is full!", false); $this->close("server is full!", false);
return; return;
} }
if($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){ if($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){
@ -1245,22 +1260,27 @@ class Player extends RealHuman{
$this->directDataPacket($pk); $this->directDataPacket($pk);
} }
$this->close("Incorrect protocol #" . $packet->protocol1, false); $this->close("Incorrect protocol #" . $packet->protocol1, false);
return; return;
} }
if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $this->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){ if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $this->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){
$this->close("Bad username", false); $this->close("Bad username", false);
return; return;
} }
if($this->server->api->handle("player.connect", $this) === false){ if($this->server->api->handle("player.connect", $this) === false){
$this->close("Unknown reason", false); $this->close("Unknown reason", false);
return; return;
} }
if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)){ if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)){
$this->close("Server is white-listed", false); $this->close("Server is white-listed", false);
return; return;
} elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){ } elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){
$this->close("You are banned!", false); $this->close("You are banned!", false);
return; return;
} }
$this->loggedIn = true; $this->loggedIn = true;
@ -1287,11 +1307,13 @@ class Player extends RealHuman{
if($this->server->api->handle("player.join", $this) === false){ if($this->server->api->handle("player.join", $this) === false){
$this->close("join cancelled", false); $this->close("join cancelled", false);
return; return;
} }
if(!($nbt instanceof Compound)){ if(!($nbt instanceof Compound)){
$this->close("no config created", false); $this->close("no config created", false);
return; return;
} }
@ -2019,7 +2041,8 @@ class Player extends RealHuman{
"slotdata" => $slot, "slotdata" => $slot,
"itemdata" => $item, "itemdata" => $item,
"player" => $this, "player" => $this,
)) === false){ )) === false
){
$pk = new Network\Protocol\ContainerSetSlotPacket; $pk = new Network\Protocol\ContainerSetSlotPacket;
$pk->windowid = $packet->windowid; $pk->windowid = $packet->windowid;
$pk->slot = $packet->slot; $pk->slot = $packet->slot;
@ -2071,7 +2094,8 @@ class Player extends RealHuman{
"slotdata" => $slot, "slotdata" => $slot,
"itemdata" => $item, "itemdata" => $item,
"player" => $this, "player" => $this,
)) === false){ )) === false
){
$pk = new Network\Protocol\ContainerSetSlotPacket; $pk = new Network\Protocol\ContainerSetSlotPacket;
$pk->windowid = $packet->windowid; $pk->windowid = $packet->windowid;
$pk->slot = $packet->slot; $pk->slot = $packet->slot;
@ -2213,6 +2237,7 @@ class Player extends RealHuman{
$this->recoveryQueue[$count] = $rk; $this->recoveryQueue[$count] = $rk;
$this->send($rk); $this->send($rk);
} }
return $cnts; return $cnts;
} }
@ -2234,6 +2259,7 @@ class Player extends RealHuman{
} }
$this->send($pk); $this->send($pk);
return array($pk->seqNumber); return array($pk->seqNumber);
} }
@ -2267,6 +2293,7 @@ class Player extends RealHuman{
$packet->reliability = 2; $packet->reliability = 2;
@$this->buffer->data[] = $packet; @$this->buffer->data[] = $packet;
$this->bufferLen += 6 + $len; $this->bufferLen += 6 + $len;
return array(); return array();
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Entity\Entity as Entity; use PocketMine\Entity\Entity as Entity;
use PocketMine\Player as Player; use PocketMine\Player as Player;
@ -29,6 +30,7 @@ use PocketMine\Level\Position as Position;
class PlayerAPI{ class PlayerAPI{
private $server; private $server;
function __construct(){ function __construct(){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
} }
@ -117,8 +119,10 @@ class PlayerAPI{
} }
} }
$this->server->api->chat->broadcast($data["player"]->getUsername() . $message); $this->server->api->chat->broadcast($data["player"]->getUsername() . $message);
return true; return true;
} }
return;
} }
public function commandHandler($cmd, $params, $issuer, $alias){ public function commandHandler($cmd, $params, $issuer, $alias){
@ -294,6 +298,7 @@ class PlayerAPI{
$output = substr($output, 0, -2) . "\n"; $output = substr($output, 0, -2) . "\n";
break; break;
} }
return $output; return $output;
} }
@ -304,6 +309,7 @@ class PlayerAPI{
$origin = Player::get($name); $origin = Player::get($name);
if($origin instanceof Player){ if($origin instanceof Player){
$name = $origin->getUsername(); $name = $origin->getUsername();
return $origin->teleport($lv->getSafeSpawn()); return $origin->teleport($lv->getSafeSpawn());
} }
} else{ } else{
@ -316,9 +322,11 @@ class PlayerAPI{
$origin = Player::get($name); $origin = Player::get($name);
if($origin instanceof Player){ if($origin instanceof Player){
$name = $origin->getUsername(); $name = $origin->getUsername();
return $origin->teleport($player->entity); return $origin->teleport($player->entity);
} }
} }
return false; return false;
} }
@ -330,8 +338,10 @@ class PlayerAPI{
$y = $y{0} === "~" ? $player->entity->y + floatval(substr($y, 1)) : floatval($y); $y = $y{0} === "~" ? $player->entity->y + floatval(substr($y, 1)) : floatval($y);
$z = $z{0} === "~" ? $player->entity->z + floatval(substr($z, 1)) : floatval($z); $z = $z{0} === "~" ? $player->entity->z + floatval(substr($z, 1)) : floatval($z);
$player->teleport(new Vector3($x, $y, $z)); $player->teleport(new Vector3($x, $y, $z));
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
use PocketMine\Utils\Utils as Utils; use PocketMine\Utils\Utils as Utils;
use PocketMine\Network\Protocol\Info as Info; use PocketMine\Network\Protocol\Info as Info;
@ -31,6 +32,7 @@ class PluginAPI extends \stdClass{
private $server; private $server;
private $plugins = array(); private $plugins = array();
private $randomNonce; private $randomNonce;
public function __construct(){ public function __construct(){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
$this->randomNonce = Utils::getRandomBytes(16, false); $this->randomNonce = Utils::getRandomBytes(16, false);
@ -57,6 +59,7 @@ class PluginAPI extends \stdClass{
$output .= "\n"; $output .= "\n";
break; break;
} }
return $output; return $output;
} }
@ -72,6 +75,7 @@ class PluginAPI extends \stdClass{
foreach($this->plugins as $p){ foreach($this->plugins as $p){
$list[] = $p[1]; $list[] = $p[1];
} }
return $list; return $list;
} }
@ -82,6 +86,7 @@ class PluginAPI extends \stdClass{
public function load($file){ public function load($file){
if(is_link($file) or is_dir($file) or !file_exists($file)){ if(is_link($file) or is_dir($file) or !file_exists($file)){
console("[ERROR] " . basename($file) . " is not a file"); console("[ERROR] " . basename($file) . " is not a file");
return false; return false;
} }
if(strtolower(substr($file, -3)) === "pmf"){ if(strtolower(substr($file, -3)) === "pmf"){
@ -93,6 +98,7 @@ class PluginAPI extends \stdClass{
$content = str_repeat(PHP_EOL, substr_count($info, "\n")) . substr(strstr($content, "*/"), 2); $content = str_repeat(PHP_EOL, substr_count($info, "\n")) . substr(strstr($content, "*/"), 2);
if(preg_match_all('#([a-zA-Z0-9\-_]*)=([^\r\n]*)#u', $info, $matches) == 0){ //false or 0 matches if(preg_match_all('#([a-zA-Z0-9\-_]*)=([^\r\n]*)#u', $info, $matches) == 0){ //false or 0 matches
console("[ERROR] Failed parsing of " . basename($file)); console("[ERROR] Failed parsing of " . basename($file));
return false; return false;
} }
$info = array(); $info = array();
@ -117,15 +123,18 @@ class PluginAPI extends \stdClass{
} }
if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){ if(!isset($info["name"]) or !isset($info["version"]) or !isset($info["class"]) or !isset($info["author"])){
console("[ERROR] Failed parsing of " . basename($file)); console("[ERROR] Failed parsing of " . basename($file));
return false; return false;
} }
console("[INFO] Loading plugin \"" . TextFormat::GREEN . $info["name"] . TextFormat::RESET . "\" " . TextFormat::AQUA . $info["version"] . TextFormat::RESET . " by " . TextFormat::AQUA . $info["author"] . TextFormat::RESET); console("[INFO] Loading plugin \"" . TextFormat::GREEN . $info["name"] . TextFormat::RESET . "\" " . TextFormat::AQUA . $info["version"] . TextFormat::RESET . " by " . TextFormat::AQUA . $info["author"] . TextFormat::RESET);
if($info["class"] !== "none" and class_exists($info["class"])){ if($info["class"] !== "none" and class_exists($info["class"])){
console("[ERROR] Failed loading plugin: class already exists"); console("[ERROR] Failed loading plugin: class already exists");
return false; return false;
} }
if(((!isset($pmf) and (include $file) === false) or (isset($pmf) and eval($info["code"]) === false)) and $info["class"] !== "none" and !class_exists($info["class"])){ if(((!isset($pmf) and (include $file) === false) or (isset($pmf) and eval($info["code"]) === false)) and $info["class"] !== "none" and !class_exists($info["class"])){
console("[ERROR] Failed loading {$info['name']}: evaluation error"); console("[ERROR] Failed loading {$info['name']}: evaluation error");
return false; return false;
} }
@ -152,6 +161,7 @@ class PluginAPI extends \stdClass{
} else{ } else{
$this->plugins[$identifier] = array(new DummyPlugin($this->server->api, false), $info); $this->plugins[$identifier] = array(new DummyPlugin($this->server->api, false), $info);
} }
return true; return true;
} }
@ -166,17 +176,20 @@ class PluginAPI extends \stdClass{
return $p; return $p;
} }
} }
return false; return false;
} }
if(isset($this->plugins[$identifier])){ if(isset($this->plugins[$identifier])){
return $this->plugins[$identifier]; return $this->plugins[$identifier];
} }
return false; return false;
} }
public function pluginsPath(){ public function pluginsPath(){
$path = join(DIRECTORY_SEPARATOR, array(\PocketMine\DATA . "plugins", "")); $path = join(DIRECTORY_SEPARATOR, array(\PocketMine\DATA . "plugins", ""));
@mkdir($path); @mkdir($path);
return $path; return $path;
} }
@ -190,6 +203,7 @@ class PluginAPI extends \stdClass{
$path = $this->pluginsPath() . $p[1]["name"] . DIRECTORY_SEPARATOR; $path = $this->pluginsPath() . $p[1]["name"] . DIRECTORY_SEPARATOR;
$this->plugins[$identifier][1]["path"] = $path; $this->plugins[$identifier][1]["path"] = $path;
@mkdir($path); @mkdir($path);
return $path; return $path;
} }
@ -201,6 +215,7 @@ class PluginAPI extends \stdClass{
$path = $this->configPath($plugin); $path = $this->configPath($plugin);
$cnf = new Config($path . "config.yml", Config::YAML, $default); $cnf = new Config($path . "config.yml", Config::YAML, $default);
$cnf->save(); $cnf->save();
return $path; return $path;
} }
@ -240,7 +255,9 @@ class PluginAPI extends \stdClass{
interface Plugin{ interface Plugin{
public function __construct(ServerAPI $api, $server = false); public function __construct(ServerAPI $api, $server = false);
public function init(); public function init();
public function __destruct(); public function __destruct();
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\Utils\VersionString as VersionString; use PocketMine\Utils\VersionString as VersionString;
use PocketMine\Utils\Utils as Utils; use PocketMine\Utils\Utils as Utils;
use PocketMine\Network\Handler as Handler; use PocketMine\Network\Handler as Handler;
@ -98,6 +99,7 @@ class Server{
public function getTPS(){ public function getTPS(){
$v = array_values($this->tickMeasure); $v = array_values($this->tickMeasure);
$tps = 40 / ($v[39] - $v[0]); $tps = 40 / ($v[39] - $v[0]);
return round($tps, 4); return round($tps, 4);
} }
@ -156,6 +158,7 @@ class Server{
if($fetch === true and ($result instanceof \SQLite3Result)){ if($fetch === true and ($result instanceof \SQLite3Result)){
$result = $result->fetchArray(SQLITE3_ASSOC); $result = $result->fetchArray(SQLITE3_ASSOC);
} }
return $result; return $result;
} }
@ -176,6 +179,7 @@ class Server{
if($console === true){ if($console === true){
console("[DEBUG] TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . "), Entities: " . $info["entities"] . ", Events: " . $info["events"] . ", Handlers: " . $info["handlers"] . ", Actions: " . $info["actions"] . ", Garbage: " . $info["garbage"], true, true, 2); console("[DEBUG] TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . "), Entities: " . $info["entities"] . ", Events: " . $info["events"] . ", Handlers: " . $info["handlers"] . ", Actions: " . $info["actions"] . ", Garbage: " . $info["garbage"], true, true, 2);
} }
return $info; return $info;
} }
@ -242,6 +246,7 @@ class Server{
$ID = $this->asyncID++; $ID = $this->asyncID++;
$this->async[$ID] = $callable; $this->async[$ID] = $callable;
$this->asyncThread->input .= Utils::writeInt($ID) . Utils::writeShort($type) . $d; $this->asyncThread->input .= Utils::writeInt($ID) . Utils::writeShort($type) . $d;
return $ID; return $ID;
} }
@ -306,6 +311,7 @@ class Server{
$this->handlers[$hnid] = $callable; $this->handlers[$hnid] = $callable;
$this->query("INSERT INTO handlers (ID, name, priority) VALUES (" . $hnid . ", '" . str_replace("'", "\\'", $event) . "', " . $priority . ");"); $this->query("INSERT INTO handlers (ID, name, priority) VALUES (" . $hnid . ", '" . str_replace("'", "\\'", $event) . "', " . $priority . ");");
console("[INTERNAL] New handler " . (is_array($callable) ? get_class($callable[0]) . "::" . $callable[1] : $callable) . " to special event " . $event . " (ID " . $hnid . ")", true, true, 3); console("[INTERNAL] New handler " . (is_array($callable) ? get_class($callable[0]) . "::" . $callable[1] : $callable) . " to special event " . $event . " (ID " . $hnid . ")", true, true, 3);
return $hnid; return $hnid;
} }
@ -349,6 +355,7 @@ class Server{
if($result !== false){ if($result !== false){
$this->trigger($event, $data); $this->trigger($event, $data);
} }
return $result; return $result;
} }
@ -375,7 +382,6 @@ class Server{
} }
public function init(){ public function init(){
register_tick_function(array($this, "tick")); register_tick_function(array($this, "tick"));
declare(ticks = 5000); //Minimum TPS for main thread locks declare(ticks = 5000); //Minimum TPS for main thread locks
@ -484,8 +490,10 @@ class Server{
$this->tickMeasure[] = $this->lastTick = $time; $this->tickMeasure[] = $this->lastTick = $time;
unset($this->tickMeasure[key($this->tickMeasure)]); unset($this->tickMeasure[key($this->tickMeasure)]);
++$this->ticks; ++$this->ticks;
return $this->tickerFunction($time); return $this->tickerFunction($time);
} }
return 0; return 0;
} }
@ -625,6 +633,7 @@ class Server{
$chcnt = $this->scheduleCnt++; $chcnt = $this->scheduleCnt++;
$this->schedule[$chcnt] = array($callback, $data, $eventName); $this->schedule[$chcnt] = array($callback, $data, $eventName);
$this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(" . $chcnt . ", " . ($ticks / 20) . ", " . microtime(true) . ", " . (((bool) $repeat) === true ? 1 : 0) . ");"); $this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(" . $chcnt . ", " . ($ticks / 20) . ", " . microtime(true) . ", " . (((bool) $repeat) === true ? 1 : 0) . ");");
return $chcnt; return $chcnt;
} }
@ -657,6 +666,7 @@ class Server{
} }
$actions->finalize(); $actions->finalize();
} }
return $actionCount; return $actionCount;
} }
@ -677,6 +687,7 @@ class Server{
$this->events[$event][$evid] = $func; $this->events[$event][$evid] = $func;
$this->eventsID[$evid] = $event; $this->eventsID[$evid] = $event;
console("[INTERNAL] Attached " . (is_array($func) ? get_class($func[0]) . "::" . $func[1] : $func) . " to event " . $event . " (ID " . $evid . ")", true, true, 3); console("[INTERNAL] Attached " . (is_array($func) ? get_class($func[0]) . "::" . $func[1] : $func) . " to event " . $event . " (ID " . $evid . ")", true, true, 3);
return $evid; return $evid;
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\Utils\VersionString as VersionString; use PocketMine\Utils\VersionString as VersionString;
use PocketMine\Utils\TextFormat as TextFormat; use PocketMine\Utils\TextFormat as TextFormat;
use PocketMine\Utils\Config as Config; use PocketMine\Utils\Config as Config;
@ -101,6 +102,7 @@ class ServerAPI{
public function run(){ public function run(){
$this->load(); $this->load();
return $this->init(); return $this->init();
} }
@ -257,6 +259,7 @@ class ServerAPI{
public function async(callable $callable, $params = array(), $remove = false){ public function async(callable $callable, $params = array(), $remove = false){
$cnt = $this->asyncCnt++; $cnt = $this->asyncCnt++;
$this->asyncCalls[$cnt] = new \Async($callable, $params); $this->asyncCalls[$cnt] = new \Async($callable, $params);
return $remove === true ? $this->getAsync($cnt) : $cnt; return $remove === true ? $this->getAsync($cnt) : $cnt;
} }
@ -266,8 +269,10 @@ class ServerAPI{
} }
$ob = $this->asyncCalls[$id]; $ob = $this->asyncCalls[$id];
unset($this->asyncCalls[$id]); unset($this->asyncCalls[$id]);
return $ob; return $ob;
} }
public function autoSave(){ public function autoSave(){
console("[DEBUG] Saving....", true, true, 2); console("[DEBUG] Saving....", true, true, 2);
$this->server->api->level->saveAll(); $this->server->api->level->saveAll();
@ -296,7 +301,7 @@ class ServerAPI{
"max" => $this->server->maxClients, "max" => $this->server->maxClients,
"plugins" => $plist, "plugins" => $plist,
), ),
), NULL); ), null);
} }
public function __destruct(){ public function __destruct(){
@ -398,6 +403,7 @@ class ServerAPI{
console("[INFO] [UPnP] Removing port forward..."); console("[INFO] [UPnP] Removing port forward...");
RemovePortForward($this->getProperty("server-port")); RemovePortForward($this->getProperty("server-port"));
} }
return $this->restart; return $this->restart;
} }
@ -472,8 +478,10 @@ class ServerAPI{
$v = (int) $v; $v = (int) $v;
break; break;
} }
return $v; return $v;
} }
return ($this->config->exists($name) ? $this->config->get($name) : $default); return ($this->config->exists($name) ? $this->config->get($name) : $default);
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine; namespace PocketMine;
use PocketMine\ServerAPI as ServerAPI; use PocketMine\ServerAPI as ServerAPI;
class TimeAPI{ class TimeAPI{
@ -30,6 +31,7 @@ class TimeAPI{
"sunrise" => 17800, "sunrise" => 17800,
); );
private $server; private $server;
function __construct(){ function __construct(){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
} }
@ -69,18 +71,22 @@ class TimeAPI{
} }
break; break;
} }
return $output; return $output;
} }
public function night(){ public function night(){
return $this->set("night"); return $this->set("night");
} }
public function day(){ public function day(){
return $this->set("day"); return $this->set("day");
} }
public function sunrise(){ public function sunrise(){
return $this->set("sunrise"); return $this->set("sunrise");
} }
public function sunset(){ public function sunset(){
return $this->set("sunset"); return $this->set("sunset");
} }
@ -89,6 +95,7 @@ class TimeAPI{
if(!($level instanceof Level)){ if(!($level instanceof Level)){
$level = $this->server->api->level->getDefault(); $level = $this->server->api->level->getDefault();
} }
return $raw === true ? $level->getTime() : abs($level->getTime()) % 19200; return $raw === true ? $level->getTime() : abs($level->getTime()) % 19200;
} }
@ -101,6 +108,7 @@ class TimeAPI{
public function getDate($time = false){ public function getDate($time = false){
$time = !is_integer($time) ? $this->get(false, $time) : $time; $time = !is_integer($time) ? $this->get(false, $time) : $time;
return str_pad(strval((floor($time / 800) + 6) % 24), 2, "0", STR_PAD_LEFT) . ":" . str_pad(strval(floor(($time % 800) / 13.33)), 2, "0", STR_PAD_LEFT); return str_pad(strval((floor($time / 800) + 6) % 24), 2, "0", STR_PAD_LEFT) . ":" . str_pad(strval(floor(($time % 800) / 13.33)), 2, "0", STR_PAD_LEFT);
} }
@ -115,6 +123,7 @@ class TimeAPI{
} else{ } else{
$time = "sunrise"; $time = "sunrise";
} }
return $time; return $time;
} }
@ -127,6 +136,7 @@ class TimeAPI{
} else{ } else{
$level->setTime((int) $time); $level->setTime((int) $time);
} }
return $level->getTime(); return $level->getTime();
} }

View File

@ -32,6 +32,7 @@ class BedBlock extends TransparentBlock{
$pk = new ChatPacket; $pk = new ChatPacket;
$pk->message = "You can only sleep at night"; $pk->message = "You can only sleep at night";
$player->dataPacket($pk); $player->dataPacket($pk);
return true; return true;
} }
@ -54,6 +55,7 @@ class BedBlock extends TransparentBlock{
$pk = new ChatPacket; $pk = new ChatPacket;
$pk->message = "This bed is incomplete"; $pk->message = "This bed is incomplete";
$player->dataPacket($pk); $player->dataPacket($pk);
return true; return true;
} }
} }
@ -63,6 +65,7 @@ class BedBlock extends TransparentBlock{
$pk->message = "This bed is occupied"; $pk->message = "This bed is occupied";
$player->dataPacket($pk); $player->dataPacket($pk);
} }
return true; return true;
} }
@ -82,9 +85,11 @@ class BedBlock extends TransparentBlock{
$meta = (($d + 3) % 4) & 0x03; $meta = (($d + 3) % 4) & 0x03;
$this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true); $this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true);
$this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08), true, false, true); $this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08), true, false, true);
return true; return true;
} }
} }
return false; return false;
} }
@ -116,6 +121,7 @@ class BedBlock extends TransparentBlock{
} }
} }
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return true; return true;
} }

View File

@ -30,6 +30,7 @@ class BedrockBlock extends SolidBlock{
if(($player->gamemode & 0x01) === 0x01){ if(($player->gamemode & 0x01) === 0x01){
return true; return true;
} }
return false; return false;
} }

View File

@ -31,8 +31,10 @@ class BeetrootBlock extends FlowableBlock{
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -43,8 +45,10 @@ class BeetrootBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
@ -53,6 +57,7 @@ class BeetrootBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(BEETROOT_SEEDS, 0, 1));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -60,12 +65,14 @@ class BeetrootBlock extends FlowableBlock{
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} else{ } else{
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }
@ -77,6 +84,7 @@ class BeetrootBlock extends FlowableBlock{
} else{ } else{
$drops[] = array(BEETROOT_SEEDS, 0, 1); $drops[] = array(BEETROOT_SEEDS, 0, 1);
} }
return $drops; return $drops;
} }
} }

View File

@ -211,6 +211,7 @@ abstract class Block extends Position{
if(($player->gamemode & 0x01) === 0x01){ if(($player->gamemode & 0x01) === 0x01){
return 0.15; return 0.15;
} }
return $this->breakTime; return $this->breakTime;
} }
@ -219,6 +220,7 @@ abstract class Block extends Position{
if($this->level instanceof Level){ if($this->level instanceof Level){
return $this->level->getBlock($v); return $this->level->getBlock($v);
} }
return $v; return $v;
} }

View File

@ -30,9 +30,11 @@ class BrownMushroomBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -40,8 +42,10 @@ class BrownMushroomBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent === false){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -44,11 +44,13 @@ class BurningFurnaceBlock extends SolidBlock{
)); ));
$nbt->Items->setTagType(NBT\Tag_Compound); $nbt->Items->setTagType(NBT\Tag_Compound);
$furnace = new Furnace($this->level, $nbt); $furnace = new Furnace($this->level, $nbt);
return true; return true;
} }
public function onBreak(Item $item, Player $player){ public function onBreak(Item $item, Player $player){
$this->level->setBlock($this, new AirBlock(), true, true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return true; return true;
} }
@ -75,6 +77,7 @@ class BurningFurnaceBlock extends SolidBlock{
} }
$furnace->openInventory($player); $furnace->openInventory($player);
return true; return true;
} }
@ -112,6 +115,7 @@ class BurningFurnaceBlock extends SolidBlock{
} }
} }
} }
return $drops; return $drops;
} }
} }

View File

@ -32,6 +32,7 @@ class CactusBlock extends TransparentBlock{
if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace with common break method if($down->getID() !== SAND and $down->getID() !== CACTUS){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -50,9 +51,11 @@ class CactusBlock extends TransparentBlock{
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, false); $this->level->setBlock($this, $this, false);
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }
@ -66,9 +69,11 @@ class CactusBlock extends TransparentBlock{
if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){ if($block0->isTransparent === true and $block1->isTransparent === true and $block2->isTransparent === true and $block3->isTransparent === true){
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
} }
return false; return false;
} }

View File

@ -32,8 +32,10 @@ class CakeBlock extends TransparentBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== AIR){ if($down->getID() !== AIR){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
@ -41,9 +43,11 @@ class CakeBlock extends TransparentBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -60,8 +64,10 @@ class CakeBlock extends TransparentBlock{
} else{ } else{
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
} }
return true; return true;
} }
return false; return false;
} }

View File

@ -50,8 +50,10 @@ class CarpetBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() !== AIR){ if($down->getID() !== AIR){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
@ -60,9 +62,11 @@ class CarpetBlock extends FlowableBlock{
if($this->getSide(0)->getID() === AIR){ //Replace with common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, $this->meta, 1));
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }

View File

@ -31,8 +31,10 @@ class CarrotBlock extends FlowableBlock{
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -43,8 +45,10 @@ class CarrotBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
@ -53,6 +57,7 @@ class CarrotBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(CARROT, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(CARROT, 0, 1));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -60,12 +65,14 @@ class CarrotBlock extends FlowableBlock{
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} else{ } else{
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }
@ -76,6 +83,7 @@ class CarrotBlock extends FlowableBlock{
} else{ } else{
$drops[] = array(CARROT, 0, 1); $drops[] = array(CARROT, 0, 1);
} }
return $drops; return $drops;
} }
} }

View File

@ -25,6 +25,7 @@ class ChestBlock extends TransparentBlock{
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 15; $this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array( $faces = array(
0 => 4, 0 => 4,
@ -66,6 +67,7 @@ class ChestBlock extends TransparentBlock{
$chest->pairWith($tile); $chest->pairWith($tile);
$tile->pairWith($chest); $tile->pairWith($chest);
} }
return true; return true;
} }
@ -75,6 +77,7 @@ class ChestBlock extends TransparentBlock{
$t->unpair(); $t->unpair();
} }
$this->level->setBlock($this, new AirBlock(), true, true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return true; return true;
} }
@ -101,12 +104,12 @@ class ChestBlock extends TransparentBlock{
} }
if(($player->gamemode & 0x01) === 0x01){ if(($player->gamemode & 0x01) === 0x01){
return true; return true;
} }
$chest->openInventory($player); $chest->openInventory($player);
return true; return true;
} }
@ -123,6 +126,7 @@ class ChestBlock extends TransparentBlock{
} }
} }
} }
return $drops; return $drops;
} }
} }

View File

@ -26,6 +26,7 @@ class CobwebBlock extends FlowableBlock{
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 25; $this->hardness = 25;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array(); return array();
} }

View File

@ -29,8 +29,10 @@ class CyanFlowerBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
@ -39,9 +41,11 @@ class CyanFlowerBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
} }

View File

@ -29,8 +29,10 @@ class DandelionBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){ if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
@ -39,9 +41,11 @@ class DandelionBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
} }

View File

@ -30,9 +30,11 @@ class DeadBushBlock extends FlowableBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }

View File

@ -32,8 +32,10 @@ class DirtBlock extends SolidBlock{
$item->useOn($this); $item->useOn($this);
} }
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0), true, false, true); $this->level->setBlock($this, BlockAPI::get(FARMLAND, 0), true, false, true);
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -42,9 +42,11 @@ class DoorBlock extends TransparentBlock{
if($this->getSide(1) instanceof DoorBlock){ if($this->getSide(1) instanceof DoorBlock){
$this->level->setBlock($this->getSide(1), new AirBlock(), false); $this->level->setBlock($this->getSide(1), new AirBlock(), false);
} }
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -86,6 +88,7 @@ class DoorBlock extends TransparentBlock{
$this->level->setBlock($block, $this, true, false, true); //Bottom $this->level->setBlock($block, $this, true, false, true); //Bottom
return true; return true;
} }
return false; return false;
} }
@ -108,6 +111,7 @@ class DoorBlock extends TransparentBlock{
} }
} }
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return true; return true;
} }
@ -132,8 +136,10 @@ class DoorBlock extends TransparentBlock{
$pk->evid = 1003; $pk->evid = 1003;
$pk->data = 0; $pk->data = 0;
ServerAPI::request()->api->player->broadcastPacket($players, $pk); ServerAPI::request()->api->player->broadcastPacket($players, $pk);
return true; return true;
} }
return false; return false;
} else{ } else{
$this->meta ^= 0x04; $this->meta ^= 0x04;
@ -148,6 +154,7 @@ class DoorBlock extends TransparentBlock{
$pk->data = 0; $pk->data = 0;
ServerAPI::request()->api->player->broadcastPacket($players, $pk); ServerAPI::request()->api->player->broadcastPacket($players, $pk);
} }
return true; return true;
} }
} }

View File

@ -45,6 +45,7 @@ class FallableBlock extends SolidBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$ret = $this->level->setBlock($this, $this, true, false, true); $ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL);
return $ret; return $ret;
} }
} }

View File

@ -24,6 +24,7 @@ class FarmlandBlock extends SolidBlock{
parent::__construct(FARMLAND, $meta, "Farmland"); parent::__construct(FARMLAND, $meta, "Farmland");
$this->hardness = 3; $this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array(DIRT, 0, 1), array(DIRT, 0, 1),

View File

@ -30,6 +30,7 @@ class FenceGateBlock extends TransparentBlock{
} }
$this->hardness = 15; $this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array( $faces = array(
0 => 3, 0 => 3,
@ -39,13 +40,16 @@ class FenceGateBlock extends TransparentBlock{
); );
$this->meta = $faces[$player->entity->getDirection()] & 0x03; $this->meta = $faces[$player->entity->getDirection()] & 0x03;
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array($this->id, 0, 1), array($this->id, 0, 1),
); );
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$faces = array( $faces = array(
0 => 3, 0 => 3,
@ -60,6 +64,7 @@ class FenceGateBlock extends TransparentBlock{
$this->isFullBlock = false; $this->isFullBlock = false;
} }
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -41,13 +41,16 @@ class FireBlock extends FlowableBlock{
} }
} }
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== NETHERRACK){ if($this->getSide(0)->getID() !== NETHERRACK){
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }

View File

@ -88,8 +88,10 @@ class GenericBlock extends Block{
$e->spawnToAll(); $e->spawnToAll();
$server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1); $server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1);
} }
return false; return false;
} }
return false; return false;
} }

View File

@ -28,10 +28,12 @@ class GlowingRedstoneOreBlock extends SolidBlock{
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){ if($type === BLOCK_UPDATE_SCHEDULED or $type === BLOCK_UPDATE_RANDOM){
$this->level->setBlock($this, BlockAPI::get(REDSTONE_ORE, $this->meta), false, false, true); $this->level->setBlock($this, BlockAPI::get(REDSTONE_ORE, $this->meta), false, false, true);
return BLOCK_UPDATE_WEAK; return BLOCK_UPDATE_WEAK;
} else{ } else{
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
} }
return false; return false;
} }

View File

@ -25,6 +25,7 @@ class GrassBlock extends SolidBlock{
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 3; $this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array(DIRT, 0, 1), array(DIRT, 0, 1),
@ -37,14 +38,17 @@ class GrassBlock extends SolidBlock{
$item->count--; $item->count--;
} }
TallGrassObject::growGrass($this->level, $this, new Random(), 8, 2); TallGrassObject::growGrass($this->level, $this, new Random(), 8, 2);
return true; return true;
} elseif($item->isHoe()){ } elseif($item->isHoe()){
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->useOn($this); $item->useOn($this);
} }
$this->level->setBlock($this, new FarmlandBlock()); $this->level->setBlock($this, new FarmlandBlock());
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -31,6 +31,7 @@ class GravelBlock extends FallableBlock{
array(FLINT, 0, 1), array(FLINT, 0, 1),
); );
} }
return array( return array(
array(GRAVEL, 0, 1), array(GRAVEL, 0, 1),
); );

View File

@ -37,6 +37,7 @@ class HayBaleBlock extends SolidBlock{
$this->meta = ($this->meta & 0x03) | $faces[$face]; $this->meta = ($this->meta & 0x03) | $faces[$face];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -31,6 +31,7 @@ class IceBlock extends TransparentBlock{
} else{ } else{
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
} }
return true; return true;
} }

View File

@ -26,6 +26,7 @@ class LadderBlock extends TransparentBlock{
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 2; $this->hardness = 2;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->isTransparent === false){ if($target->isTransparent === false){
$faces = array( $faces = array(
@ -37,9 +38,11 @@ class LadderBlock extends TransparentBlock{
if(isset($faces[$face])){ if(isset($faces[$face])){
$this->meta = $faces[$face]; $this->meta = $faces[$face];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
} }
return false; return false;
} }
@ -51,6 +54,7 @@ class LadderBlock extends TransparentBlock{
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
}*/ }*/
} }
return false; return false;
} }

View File

@ -28,6 +28,7 @@ class LavaBlock extends LiquidBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$ret = $this->level->setBlock($this, $this, true, false, true); $ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 40, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 40, BLOCK_UPDATE_NORMAL);
return $ret; return $ret;
} }
@ -42,6 +43,7 @@ class LavaBlock extends LiquidBlock{
} }
} }
} }
return $count; return $count;
} }
@ -70,6 +72,7 @@ class LavaBlock extends LiquidBlock{
} }
} }
} }
return null; return null;
} }
@ -136,6 +139,7 @@ class LavaBlock extends LiquidBlock{
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
} }
return false; return false;
} }

View File

@ -23,6 +23,7 @@ class LeavesBlock extends TransparentBlock{
const OAK = 0; const OAK = 0;
const SPRUCE = 1; const SPRUCE = 1;
const BIRCH = 2; const BIRCH = 2;
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(LEAVES, $meta, "Leaves"); parent::__construct(LEAVES, $meta, "Leaves");
$names = array( $names = array(
@ -123,10 +124,12 @@ class LeavesBlock extends TransparentBlock{
//TODO //TODO
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(APPLE, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(APPLE, 0, 1));
} }
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
} }
return false; return false;
} }
@ -147,6 +150,7 @@ class LeavesBlock extends TransparentBlock{
$drops[] = array(APPLE, 0, 1); $drops[] = array(APPLE, 0, 1);
} }
} }
return $drops; return $drops;
} }
} }

View File

@ -34,6 +34,7 @@ class LitPumpkinBlock extends SolidBlock{
); );
$this->meta = $faces[$player->entity->getDirection()]; $this->meta = $faces[$player->entity->getDirection()];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -24,6 +24,7 @@ class MelonBlock extends TransparentBlock{
parent::__construct(MELON_BLOCK, 0, "Melon Block"); parent::__construct(MELON_BLOCK, 0, "Melon Block");
$this->hardness = 5; $this->hardness = 5;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array(MELON_SLICE, 0, mt_rand(3, 7)), array(MELON_SLICE, 0, mt_rand(3, 7)),

View File

@ -25,13 +25,16 @@ class MelonStemBlock extends FlowableBlock{
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 0; $this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -40,6 +43,7 @@ class MelonStemBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2))); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -47,6 +51,7 @@ class MelonStemBlock extends FlowableBlock{
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} else{ } else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
@ -62,8 +67,10 @@ class MelonStemBlock extends FlowableBlock{
} }
} }
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
return false; return false;
} }
@ -74,8 +81,10 @@ class MelonStemBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }

View File

@ -31,8 +31,10 @@ class PotatoBlock extends FlowableBlock{
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -43,8 +45,10 @@ class PotatoBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
@ -53,6 +57,7 @@ class PotatoBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(POTATO, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(POTATO, 0, 1));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -60,12 +65,14 @@ class PotatoBlock extends FlowableBlock{
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} else{ } else{
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }
@ -76,6 +83,7 @@ class PotatoBlock extends FlowableBlock{
} else{ } else{
$drops[] = array(POTATO, 0, 1); $drops[] = array(POTATO, 0, 1);
} }
return $drops; return $drops;
} }
} }

View File

@ -25,13 +25,16 @@ class PumpkinStemBlock extends FlowableBlock{
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 0; $this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -40,6 +43,7 @@ class PumpkinStemBlock extends FlowableBlock{
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2))); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2)));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -47,6 +51,7 @@ class PumpkinStemBlock extends FlowableBlock{
if($this->meta < 0x07){ if($this->meta < 0x07){
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} else{ } else{
for($side = 2; $side <= 5; ++$side){ for($side = 2; $side <= 5; ++$side){
@ -62,8 +67,10 @@ class PumpkinStemBlock extends FlowableBlock{
} }
} }
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
return false; return false;
} }
@ -74,8 +81,10 @@ class PumpkinStemBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }

View File

@ -31,9 +31,11 @@ class RedMushroomBlock extends FlowableBlock{
//TODO //TODO
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false); $this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -41,8 +43,10 @@ class RedMushroomBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->isTransparent === false){ if($down->isTransparent === false){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -29,8 +29,10 @@ class RedstoneOreBlock extends SolidBlock{
if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){ if($type === BLOCK_UPDATE_NORMAL or $type === BLOCK_UPDATE_TOUCH){
$this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false, false, true); $this->level->setBlock($this, BlockAPI::get(GLOWING_REDSTONE_ORE, $this->meta), false, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return BLOCK_UPDATE_WEAK; return BLOCK_UPDATE_WEAK;
} }
return false; return false;
} }

View File

@ -44,8 +44,10 @@ class SaplingBlock extends FlowableBlock{
if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){ if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -55,16 +57,20 @@ class SaplingBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
public function onUpdate($type){ public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
//TODO //TODO
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ //Growth } elseif($type === BLOCK_UPDATE_RANDOM){ //Growth
@ -74,12 +80,14 @@ class SaplingBlock extends FlowableBlock{
} else{ } else{
$this->meta |= 0x08; $this->meta |= 0x08;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} else{ } else{
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }

View File

@ -38,13 +38,16 @@ class SignPostBlock extends TransparentBlock{
if(!isset($faces[$face])){ if(!isset($faces[$face])){
$this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F; $this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
$this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);
return true; return true;
} else{ } else{
$this->meta = $faces[$face]; $this->meta = $faces[$face];
$this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta), true, false, true);
return true; return true;
} }
} }
return false; return false;
} }
@ -53,14 +56,17 @@ class SignPostBlock extends TransparentBlock{
if($this->getSide(0)->getID() === AIR){ //Replace with common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SIGN, 0, 1));
$this->level->setBlock($this, new AirBlock(), true, true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
public function onBreak(Item $item, Player $player){ public function onBreak(Item $item, Player $player){
$this->level->setBlock($this, new AirBlock(), true, true, true); $this->level->setBlock($this, new AirBlock(), true, true, true);
return true; return true;
} }

View File

@ -46,9 +46,11 @@ class SlabBlock extends TransparentBlock{
if($face === 0){ if($face === 0){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true); $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ } elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} else{ } else{
$this->meta |= 0x08; $this->meta |= 0x08;
@ -56,17 +58,21 @@ class SlabBlock extends TransparentBlock{
} elseif($face === 1){ } elseif($face === 1){
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true); $this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ } elseif($block->getID() === SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} }
} elseif(!$player->entity->inBlock($block)){ } elseif(!$player->entity->inBlock($block)){
if($block->getID() === SLAB){ if($block->getID() === SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} }
return false; return false;
} else{ } else{
if($fy > 0.5){ if($fy > 0.5){
@ -80,6 +86,7 @@ class SlabBlock extends TransparentBlock{
return false; return false;
} }
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -32,8 +32,10 @@ class SnowLayerBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down instanceof SolidBlock){ if($down instanceof SolidBlock){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
@ -41,9 +43,11 @@ class SnowLayerBlock extends FlowableBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->getID() === AIR){ //Replace with common break method if($this->getSide(0)->getID() === AIR){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -53,6 +57,7 @@ class SnowLayerBlock extends FlowableBlock{
array(SNOWBALL, 0, 1), array(SNOWBALL, 0, 1),
); );
} }
return array(); return array();
} }
} }

View File

@ -59,6 +59,7 @@ class StairBlock extends TransparentBlock{
$this->meta |= 0x04; //Upside-down stairs $this->meta |= 0x04; //Upside-down stairs
} }
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -27,6 +27,7 @@ class StonecutterBlock extends SolidBlock{
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$player->toCraft[-1] = 2; $player->toCraft[-1] = 2;
return true; return true;
} }

View File

@ -47,8 +47,10 @@ class SugarcaneBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
@ -59,6 +61,7 @@ class SugarcaneBlock extends FlowableBlock{
//TODO //TODO
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -77,9 +80,11 @@ class SugarcaneBlock extends FlowableBlock{
++$this->meta; ++$this->meta;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
} }
return BLOCK_UPDATE_RANDOM; return BLOCK_UPDATE_RANDOM;
} }
} }
return false; return false;
} }
@ -87,6 +92,7 @@ class SugarcaneBlock extends FlowableBlock{
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === SUGARCANE_BLOCK){ if($down->getID() === SUGARCANE_BLOCK){
$this->level->setBlock($block, new SugarcaneBlock(), true, false, true); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
return true; return true;
} elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){ } elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
$block0 = $down->getSide(2); $block0 = $down->getSide(2);
@ -96,9 +102,11 @@ class SugarcaneBlock extends FlowableBlock{
if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){ if(($block0 instanceof WaterBlock) or ($block1 instanceof WaterBlock) or ($block2 instanceof WaterBlock) or ($block3 instanceof WaterBlock)){
$this->level->setBlock($block, new SugarcaneBlock(), true, false, true); $this->level->setBlock($block, new SugarcaneBlock(), true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
} }
return false; return false;
} }
} }

View File

@ -42,8 +42,10 @@ class TNTBlock extends SolidBlock{
//TODO //TODO
$e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data); $e = ServerAPI::request()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
$e->spawnToAll(); $e->spawnToAll();
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -36,9 +36,11 @@ class TallGrassBlock extends FlowableBlock{
if($type === BLOCK_UPDATE_NORMAL){ if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -63,6 +65,7 @@ class TallGrassBlock extends FlowableBlock{
if(($item = $possibleDrops[mt_rand(0, count($possibleDrops) - 1)]) !== 0){ if(($item = $possibleDrops[mt_rand(0, count($possibleDrops) - 1)]) !== 0){
$drops[] = $item; $drops[] = $item;
} }
return $drops; return $drops;
} }

View File

@ -41,9 +41,11 @@ class TorchBlock extends FlowableBlock{
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)){ //Replace with common break method if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === FENCE)){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
$this->level->setBlock($this, new AirBlock(), true, false, true); $this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} }
return false; return false;
} }
@ -58,14 +60,18 @@ class TorchBlock extends FlowableBlock{
); );
$this->meta = $faces[$face]; $this->meta = $faces[$face];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} elseif($this->getSide(0)->isTransparent === false or $this->getSide(0)->getID() === FENCE){ } elseif($this->getSide(0)->isTransparent === false or $this->getSide(0)->getID() === FENCE){
$this->meta = 0; $this->meta = 0;
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array($this->id, 0, 1), array($this->id, 0, 1),

View File

@ -30,6 +30,7 @@ class TrapdoorBlock extends TransparentBlock{
} }
$this->hardness = 15; $this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){ if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){
$faces = array( $faces = array(
@ -43,18 +44,23 @@ class TrapdoorBlock extends TransparentBlock{
$this->meta |= 0x08; $this->meta |= 0x08;
} }
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }
return false; return false;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(
array($this->id, 0, 1), array($this->id, 0, 1),
); );
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$this->meta ^= 0x04; $this->meta ^= 0x04;
$this->level->setBlock($this, $this, true, false, true); $this->level->setBlock($this, $this, true, false, true);
return true; return true;
} }
} }

View File

@ -28,6 +28,7 @@ class WaterBlock extends LiquidBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$ret = $this->level->setBlock($this, $this, true, false, true); $ret = $this->level->setBlock($this, $this, true, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL); ServerAPI::request()->api->block->scheduleBlockUpdate(clone $this, 10, BLOCK_UPDATE_NORMAL);
return $ret; return $ret;
} }
@ -42,6 +43,7 @@ class WaterBlock extends LiquidBlock{
} }
} }
} }
return $count; return $count;
} }
@ -58,9 +60,11 @@ class WaterBlock extends LiquidBlock{
} else{ } else{
$this->level->setBlock($b, new CobblestoneBlock(), false, false, true); $this->level->setBlock($b, new CobblestoneBlock(), false, false, true);
} }
return true; return true;
} }
} }
return false; return false;
} }
@ -75,6 +79,7 @@ class WaterBlock extends LiquidBlock{
} }
} }
} }
return null; return null;
} }
@ -141,6 +146,7 @@ class WaterBlock extends LiquidBlock{
} }
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
} }
return false; return false;
} }
} }

View File

@ -31,8 +31,10 @@ class WheatBlock extends FlowableBlock{
if($down->getID() === FARMLAND){ if($down->getID() === FARMLAND){
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM); $this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true; return true;
} }
return false; return false;
} }
@ -43,8 +45,10 @@ class WheatBlock extends FlowableBlock{
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;
} }
return true; return true;
} }
return false; return false;
} }
@ -54,6 +58,7 @@ class WheatBlock extends FlowableBlock{
//TODO //TODO
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1)); ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL; return BLOCK_UPDATE_NORMAL;
} }
} elseif($type === BLOCK_UPDATE_RANDOM){ } elseif($type === BLOCK_UPDATE_RANDOM){
@ -64,6 +69,7 @@ class WheatBlock extends FlowableBlock{
} }
} }
} }
return false; return false;
} }
@ -75,6 +81,7 @@ class WheatBlock extends FlowableBlock{
} else{ } else{
$drops[] = array(WHEAT_SEEDS, 0, 1); $drops[] = array(WHEAT_SEEDS, 0, 1);
} }
return $drops; return $drops;
} }
} }

View File

@ -49,6 +49,7 @@ class WoodBlock extends SolidBlock{
$this->meta = ($this->meta & 0x03) | $faces[$face]; $this->meta = ($this->meta & 0x03) | $faces[$face];
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -42,9 +42,11 @@ class WoodSlabBlock extends TransparentBlock{
if($face === 0){ if($face === 0){
if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ } elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} else{ } else{
$this->meta |= 0x08; $this->meta |= 0x08;
@ -52,17 +54,21 @@ class WoodSlabBlock extends TransparentBlock{
} elseif($face === 1){ } elseif($face === 1){
if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ } elseif($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} }
} elseif(!$player->entity->inBlock($block)){ } elseif(!$player->entity->inBlock($block)){
if($block->getID() === WOOD_SLAB){ if($block->getID() === WOOD_SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
$this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} }
return false; return false;
} else{ } else{
if($fy > 0.5){ if($fy > 0.5){
@ -76,6 +82,7 @@ class WoodSlabBlock extends TransparentBlock{
return false; return false;
} }
$this->level->setBlock($block, $this, true, false, true); $this->level->setBlock($block, $this, true, false, true);
return true; return true;
} }

View File

@ -28,6 +28,7 @@ class WorkbenchBlock extends SolidBlock{
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){
$player->toCraft[-1] = 1; $player->toCraft[-1] = 1;
return true; return true;
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Ageable{ interface Ageable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Animal extends Creature implements Ageable{ abstract class Animal extends Creature implements Ageable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Arrow extends Projectile{ class Arrow extends Projectile{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Attachable{ interface Attachable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Chicken extends Animal{ class Chicken extends Animal{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Colorable{ interface Colorable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Cow extends Animal{ class Cow extends Animal{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Creature extends Living{ abstract class Creature extends Living{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Creeper extends Monster implements Explosive{ class Creeper extends Monster implements Explosive{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Damageable{ interface Damageable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class DroppedItem extends Entity{ class DroppedItem extends Entity{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Egg extends Projectile{ class Egg extends Projectile{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class EnderPearl extends Projectile{ class EnderPearl extends Projectile{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Enderman extends Monster implements InventorySource{ class Enderman extends Monster implements InventorySource{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
use PocketMine\Level\Position as Position; use PocketMine\Level\Position as Position;
use PocketMine\Level\Level as Level; use PocketMine\Level\Level as Level;
@ -244,6 +245,7 @@ abstract class Entity extends Position{
} }
$this->lastUpdate = $timeNow; $this->lastUpdate = $timeNow;
return false; return false;
} }
@ -364,8 +366,10 @@ abstract class Entity extends Position{
public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch){ public function setPositionAndRotation(Vector3 $pos, $yaw, $pitch){
if($this->setPosition($pos) === true){ if($this->setPosition($pos) === true){
$this->setRotation($yaw, $pitch); $this->setRotation($yaw, $pitch);
return true; return true;
} }
return false; return false;
} }
@ -413,6 +417,7 @@ abstract class Entity extends Position{
$this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius); $this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
$this->scheduleUpdate(); $this->scheduleUpdate();
return true; return true;
} }
@ -462,8 +467,10 @@ abstract class Entity extends Position{
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
return true; return true;
} }
return false; return false;
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Explosive{ interface Explosive{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class FallingBlock extends Entity{ class FallingBlock extends Entity{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Hanging extends Entity implements Attachable{ abstract class Hanging extends Entity implements Attachable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
use PocketMine\Item\Item as Item; use PocketMine\Item\Item as Item;
use PocketMine\BlockAPI as BlockAPI; use PocketMine\BlockAPI as BlockAPI;
@ -196,6 +197,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if($this instanceof Player){ if($this instanceof Player){
$this->sendArmor(); $this->sendArmor();
} }
return true; return true;
} }
@ -204,6 +206,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if(!isset($this->armor[$slot])){ if(!isset($this->armor[$slot])){
$this->armor[$slot] = BlockAPI::getItem(AIR, 0, 0); $this->armor[$slot] = BlockAPI::getItem(AIR, 0, 0);
} }
return $this->armor[$slot]; return $this->armor[$slot];
} }
@ -241,6 +244,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
16 => array("type" => 0, "value" => 0), 16 => array("type" => 0, "value" => 0),
17 => array("type" => 6, "value" => array(0, 0, 0)), 17 => array("type" => 6, "value" => array(0, 0, 0)),
); );
/*if($this->class === ENTITY_MOB and $this->type === MOB_SHEEP){ /*if($this->class === ENTITY_MOB and $this->type === MOB_SHEEP){
if(!isset($this->data["Sheared"])){ if(!isset($this->data["Sheared"])){
$this->data["Sheared"] = 0; $this->data["Sheared"] = 0;
@ -255,6 +259,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$d[17]["value"] = array($this->player->sleeping->x, $this->player->sleeping->y, $this->player->sleeping->z); $d[17]["value"] = array($this->player->sleeping->x, $this->player->sleeping->y, $this->player->sleeping->z);
} }
}*/ }*/
return $d; return $d;
} }
@ -272,6 +277,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
return $i; return $i;
} }
} }
return false; return false;
} }
@ -300,6 +306,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
} }
$item->setCount($item->getCount() - $add); $item->setCount($item->getCount() - $add);
} }
return true; return true;
} }
@ -329,6 +336,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
} }
$item->setCount($item->getCount() - $add); $item->setCount($item->getCount() - $add);
} }
return true; return true;
} }
@ -356,6 +364,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
} }
$item->setCount($item->getCount() - $remove); $item->setCount($item->getCount() - $remove);
} }
return true; return true;
} }
@ -364,6 +373,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
return false; return false;
} }
$this->inventory[(int) $slot] = $ev->getNewItem(); $this->inventory[(int) $slot] = $ev->getNewItem();
return true; return true;
} }
@ -372,6 +382,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if(!isset($this->inventory[$slot])){ if(!isset($this->inventory[$slot])){
$this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0); $this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0);
} }
return $this->inventory[$slot]; return $this->inventory[$slot];
} }

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
use PocketMine\Item\Item as Item; use PocketMine\Item\Item as Item;

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Living extends Entity implements Damageable{ abstract class Living extends Entity implements Damageable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Minecart extends Vehicle{ class Minecart extends Vehicle{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Monster extends Creature{ abstract class Monster extends Creature{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Ocelot extends Animal implements Tameable{ class Ocelot extends Animal implements Tameable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Painting extends Hanging{ class Painting extends Hanging{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Pig extends Animal implements Rideable{ class Pig extends Animal implements Rideable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class PigZombie extends Zombie{ class PigZombie extends Zombie{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class Projectile extends Entity{ abstract class Projectile extends Entity{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface ProjectileSource{ interface ProjectileSource{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
abstract class RealHuman extends Human{ abstract class RealHuman extends Human{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
interface Rideable{ interface Rideable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Sheep extends Animal implements Colorable{ class Sheep extends Animal implements Colorable{

View File

@ -20,6 +20,7 @@
*/ */
namespace PocketMine\Entity; namespace PocketMine\Entity;
use PocketMine; use PocketMine;
class Silverfish extends Monster{ class Silverfish extends Monster{

Some files were not shown because too many files have changed in this diff Show More