mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Merge changes from master
This commit is contained in:
commit
af06d78725
@ -1918,6 +1918,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->username = TextFormat::clean($packet->username);
|
||||||
|
$this->displayName = $this->username;
|
||||||
|
$this->iusername = strtolower($this->username);
|
||||||
|
$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
|
||||||
|
|
||||||
|
if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if($packet->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
if($packet->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
if($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL){
|
if($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
$message = "disconnectionScreen.outdatedClient";
|
$message = "disconnectionScreen.outdatedClient";
|
||||||
@ -1931,19 +1940,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$packet->decodeAdditional();
|
|
||||||
|
|
||||||
//TODO: check MCEE
|
|
||||||
|
|
||||||
$this->username = TextFormat::clean($packet->username);
|
|
||||||
$this->displayName = $this->username;
|
|
||||||
$this->iusername = strtolower($this->username);
|
|
||||||
$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
|
|
||||||
|
|
||||||
if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->randomClientId = $packet->clientId;
|
$this->randomClientId = $packet->clientId;
|
||||||
|
|
||||||
$this->uuid = UUID::fromString($packet->clientUUID);
|
$this->uuid = UUID::fromString($packet->clientUUID);
|
||||||
@ -2437,6 +2433,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{
|
||||||
|
if($this->isCreative()){
|
||||||
$tile = $this->getLevel()->getTile($this->temporalVector->setComponents($packet->tileX, $packet->tileY, $packet->tileZ));
|
$tile = $this->getLevel()->getTile($this->temporalVector->setComponents($packet->tileX, $packet->tileY, $packet->tileZ));
|
||||||
if($tile instanceof Tile){ //TODO: check if the held item matches the target tile
|
if($tile instanceof Tile){ //TODO: check if the held item matches the target tile
|
||||||
$nbt = $tile->getCleanedNBT();
|
$nbt = $tile->getCleanedNBT();
|
||||||
@ -2449,6 +2446,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3403,16 +3402,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$timings->startTiming();
|
$timings->startTiming();
|
||||||
|
|
||||||
$packet->decode();
|
$packet->decode();
|
||||||
|
assert($packet->feof(), "Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet));
|
||||||
|
|
||||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
||||||
if(!$ev->isCancelled() and !$packet->handle($this)){
|
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->getName() . ": 0x" . bin2hex($packet->buffer));
|
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$packet->feof()){
|
|
||||||
$this->server->getLogger()->debug("Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet) . " from " . $this->getName() . ": " . bin2hex($packet->get(true)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$timings->stopTiming();
|
$timings->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,6 +498,7 @@ namespace pocketmine {
|
|||||||
|
|
||||||
$killer = new ServerKiller(8);
|
$killer = new ServerKiller(8);
|
||||||
$killer->start();
|
$killer->start();
|
||||||
|
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
||||||
|
|
||||||
$erroredThreads = 0;
|
$erroredThreads = 0;
|
||||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||||
|
@ -76,7 +76,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
const DATA_FLAGS = 0;
|
const DATA_FLAGS = 0;
|
||||||
const DATA_HEALTH = 1; //int (minecart/boat)
|
const DATA_HEALTH = 1; //int (minecart/boat)
|
||||||
const DATA_VARIANT = 2; //int
|
const DATA_VARIANT = 2; //int
|
||||||
const DATA_COLOUR = 3; //byte
|
const DATA_COLOR = 3, DATA_COLOUR = 3; //byte
|
||||||
const DATA_NAMETAG = 4; //string
|
const DATA_NAMETAG = 4; //string
|
||||||
const DATA_OWNER_EID = 5; //long
|
const DATA_OWNER_EID = 5; //long
|
||||||
const DATA_TARGET_EID = 6; //long
|
const DATA_TARGET_EID = 6; //long
|
||||||
|
@ -112,7 +112,8 @@ class FallingSand extends Entity{
|
|||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$this->kill();
|
$this->kill();
|
||||||
$block = $this->level->getBlock($pos);
|
$block = $this->level->getBlock($pos);
|
||||||
if($block->getId() > 0 and !$block->isSolid() and !($block instanceof Liquid)){
|
if($block->getId() > 0 and $block->isTransparent() and !$block->canBeReplaced()){
|
||||||
|
//FIXME: anvils are supposed to destroy torches
|
||||||
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
|
$this->getLevel()->dropItem($this, ItemItem::get($this->getBlock(), $this->getDamage(), 1));
|
||||||
}else{
|
}else{
|
||||||
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||||
|
@ -156,6 +156,10 @@ class Anvil extends McRegion{
|
|||||||
return "anvil";
|
return "anvil";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPcWorldFormatVersion() : int{
|
||||||
|
return 19133; //anvil
|
||||||
|
}
|
||||||
|
|
||||||
public function getWorldHeight() : int{
|
public function getWorldHeight() : int{
|
||||||
//TODO: add world height options
|
//TODO: add world height options
|
||||||
return 256;
|
return 256;
|
||||||
|
@ -210,6 +210,14 @@ class McRegion extends BaseLevelProvider{
|
|||||||
return "mcregion";
|
return "mcregion";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the storage version as per Minecraft PC world formats.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getPcWorldFormatVersion() : int{
|
||||||
|
return 19132; //mcregion
|
||||||
|
}
|
||||||
|
|
||||||
public function getWorldHeight() : int{
|
public function getWorldHeight() : int{
|
||||||
//TODO: add world height options
|
//TODO: add world height options
|
||||||
return 128;
|
return 128;
|
||||||
@ -251,7 +259,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
"SpawnX" => new IntTag("SpawnX", 256),
|
"SpawnX" => new IntTag("SpawnX", 256),
|
||||||
"SpawnY" => new IntTag("SpawnY", 70),
|
"SpawnY" => new IntTag("SpawnY", 70),
|
||||||
"SpawnZ" => new IntTag("SpawnZ", 256),
|
"SpawnZ" => new IntTag("SpawnZ", 256),
|
||||||
"version" => new IntTag("version", 19133),
|
"version" => new IntTag("version", static::getPcWorldFormatVersion()),
|
||||||
"DayTime" => new IntTag("DayTime", 0),
|
"DayTime" => new IntTag("DayTime", 0),
|
||||||
"LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
|
"LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
|
||||||
"RandomSeed" => new LongTag("RandomSeed", $seed),
|
"RandomSeed" => new LongTag("RandomSeed", $seed),
|
||||||
|
@ -150,4 +150,8 @@ class PMAnvil extends Anvil{
|
|||||||
public static function getProviderName() : string{
|
public static function getProviderName() : string{
|
||||||
return "pmanvil";
|
return "pmanvil";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPcWorldFormatVersion() : int{
|
||||||
|
return -1; //Not a PC format, only PocketMine-MP
|
||||||
|
}
|
||||||
}
|
}
|
@ -50,9 +50,12 @@ class LoginPacket extends DataPacket{
|
|||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
$this->protocol = $this->getInt();
|
$this->protocol = $this->getInt();
|
||||||
|
|
||||||
|
if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
$this->buffer = null;
|
||||||
|
return; //Do not attempt to decode for non-accepted protocols
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decodeAdditional(){
|
|
||||||
$this->gameEdition = $this->getByte();
|
$this->gameEdition = $this->getByte();
|
||||||
|
|
||||||
$this->setBuffer($this->getString(), 0);
|
$this->setBuffer($this->getString(), 0);
|
||||||
|
@ -16,23 +16,35 @@
|
|||||||
* @author PocketMine Team
|
* @author PocketMine Team
|
||||||
* @link http://www.pocketmine.net/
|
* @link http://www.pocketmine.net/
|
||||||
*
|
*
|
||||||
* This file is generated automatically, do not edit it manually.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Minecraft: PE multiplayer protocol implementation
|
|
||||||
*/
|
|
||||||
namespace pocketmine\network\mcpe\protocol;
|
namespace pocketmine\network\mcpe\protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version numbers and packet IDs for the current Minecraft PE protocol
|
||||||
|
*/
|
||||||
interface ProtocolInfo{
|
interface ProtocolInfo{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE TO DEVELOPERS
|
||||||
|
* Do not waste your time or ours submitting pull requests changing game and/or protocol version numbers.
|
||||||
|
* Pull requests changing game and/or protocol version numbers will be closed.
|
||||||
|
*
|
||||||
|
* This file is generated automatically, do not edit it manually.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actual Minecraft: PE protocol version
|
* Actual Minecraft: PE protocol version
|
||||||
*/
|
*/
|
||||||
const CURRENT_PROTOCOL = 112;
|
const CURRENT_PROTOCOL = 112;
|
||||||
|
/**
|
||||||
|
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
|
||||||
|
*/
|
||||||
const MINECRAFT_VERSION = 'v1.1.0.9 beta';
|
const MINECRAFT_VERSION = 'v1.1.0.9 beta';
|
||||||
|
/**
|
||||||
|
* Version number sent to clients in ping responses.
|
||||||
|
*/
|
||||||
const MINECRAFT_VERSION_NETWORK = '1.1.0.9';
|
const MINECRAFT_VERSION_NETWORK = '1.1.0.9';
|
||||||
|
|
||||||
const LOGIN_PACKET = 0x01;
|
const LOGIN_PACKET = 0x01;
|
||||||
|
@ -139,7 +139,7 @@ abstract class AsyncTask extends Collectable{
|
|||||||
*/
|
*/
|
||||||
public function getFromThreadStore($identifier){
|
public function getFromThreadStore($identifier){
|
||||||
global $store;
|
global $store;
|
||||||
return $this->isGarbage() ? null : $store[$identifier];
|
return ($this->isGarbage() or !isset($store[$identifier])) ? null : $store[$identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user