mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
Spawn unleashed, movement fixed and some Player DataProperty cleanup
This commit is contained in:
parent
ef8227a074
commit
df8e1e8702
@ -1207,9 +1207,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return [];
|
||||
}
|
||||
|
||||
public function setDataProperty($id, $type, $value){
|
||||
if(parent::setDataProperty($id, $type, $value)){
|
||||
$this->sendData($this, [$id => $this->dataProperties[$id]]);
|
||||
public function setDataProperty($id, $type, $value, $send = true){
|
||||
if(parent::setDataProperty($id, $type, $value, $send)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1618,7 +1617,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setNameTag($this->username);
|
||||
|
||||
$nbt = $this->server->getOfflinePlayerData($this->username);
|
||||
$this->playedBefore = ($nbt["lastPlayed"] - $nbt["firstPlayed"]) > 1; // microtime(true) - microtime(true) may have less than one millisecond difference
|
||||
@ -1793,6 +1791,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$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)){
|
||||
break;
|
||||
@ -2204,7 +2203,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->setSneaking(false);
|
||||
|
||||
$this->extinguish();
|
||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
|
||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300, false);
|
||||
$this->deadTicks = 0;
|
||||
$this->noDamageTicks = 60;
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace pocketmine {
|
||||
|
||||
const VERSION = "1.6dev";
|
||||
const API_VERSION = "2.0.0";
|
||||
const CODENAME = "[REDACTED]";
|
||||
const CODENAME = "Unleashed";
|
||||
const MINECRAFT_VERSION = "v0.15.0.0 alpha";
|
||||
const MINECRAFT_VERSION_NETWORK = "0.15.0.0";
|
||||
|
||||
|
@ -73,8 +73,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
const DATA_TYPE_STRING = 4;
|
||||
const DATA_TYPE_SLOT = 5;
|
||||
const DATA_TYPE_POS = 6;
|
||||
const DATA_TYPE_ROTATION = 7;
|
||||
const DATA_TYPE_LONG = 8;
|
||||
const DATA_TYPE_LONG = 7;
|
||||
|
||||
const DATA_FLAGS = 0;
|
||||
const DATA_AIR = 1;
|
||||
@ -84,6 +83,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
const DATA_POTION_COLOR = 7;
|
||||
const DATA_POTION_AMBIENT = 8;
|
||||
const DATA_NO_AI = 15;
|
||||
const DATA_LINKED_EID = 23;
|
||||
|
||||
|
||||
const DATA_FLAG_ONFIRE = 0;
|
||||
@ -117,6 +117,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
self::DATA_SHOW_NAMETAG => [self::DATA_TYPE_BYTE, 1],
|
||||
self::DATA_SILENT => [self::DATA_TYPE_BYTE, 0],
|
||||
self::DATA_NO_AI => [self::DATA_TYPE_BYTE, 0],
|
||||
self::DATA_LINKED_EID => [self::DATA_TYPE_LONG, -1],
|
||||
];
|
||||
|
||||
public $passenger = null;
|
||||
@ -254,7 +255,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if(!isset($this->namedtag->Air)){
|
||||
$this->namedtag->Air = new ShortTag("Air", 300);
|
||||
}
|
||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
|
||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"], false);
|
||||
|
||||
if(!isset($this->namedtag->OnGround)){
|
||||
$this->namedtag->OnGround = new ByteTag("OnGround", 0);
|
||||
@ -1529,11 +1530,12 @@ abstract class Entity extends Location implements Metadatable{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setDataProperty($id, $type, $value){
|
||||
public function setDataProperty($id, $type, $value, $send = true){
|
||||
if($this->getDataProperty($id) !== $value){
|
||||
$this->dataProperties[$id] = [$type, $value];
|
||||
|
||||
$this->sendData($this->hasSpawned, [$id => $this->dataProperties[$id]]);
|
||||
if($send === true) {
|
||||
$this->sendData($this->hasSpawned, [$id => $this->dataProperties[$id]]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
protected function initEntity(){
|
||||
|
||||
$this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false);
|
||||
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0]);
|
||||
$this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
|
||||
|
||||
$this->inventory = new PlayerInventory($this);
|
||||
if($this instanceof Player){
|
||||
|
@ -715,9 +715,17 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
foreach($this->moveToSend as $index => $entry){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$pk = new MoveEntityPacket();
|
||||
$pk->entities = $entry;
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
foreach($entry as $e) {
|
||||
$pk = new MoveEntityPacket();
|
||||
$pk->eid = $e[0];
|
||||
$pk->x = $e[1];
|
||||
$pk->y = $e[2];
|
||||
$pk->z = $e[3];
|
||||
$pk->yaw = $e[4];
|
||||
$pk->headYaw = $e[5];
|
||||
$pk->pitch = $e[6];
|
||||
$this->addChunkPacket($chunkX, $chunkZ, $pk);
|
||||
}
|
||||
}
|
||||
$this->moveToSend = [];
|
||||
|
||||
|
@ -27,32 +27,33 @@ namespace pocketmine\network\protocol;
|
||||
class MoveEntityPacket extends DataPacket{
|
||||
const NETWORK_ID = Info::MOVE_ENTITY_PACKET;
|
||||
|
||||
|
||||
// eid, x, y, z, yaw, pitch
|
||||
/** @var array[] */
|
||||
public $entities = [];
|
||||
|
||||
public function clean(){
|
||||
$this->entities = [];
|
||||
return parent::clean();
|
||||
}
|
||||
public $eid;
|
||||
public $x;
|
||||
public $y;
|
||||
public $z;
|
||||
public $yaw;
|
||||
public $headYaw;
|
||||
public $pitch;
|
||||
|
||||
public function decode(){
|
||||
|
||||
$this->eid = $this->getLong();
|
||||
$this->x = $this->getFloat();
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
$this->pitch = $this->getByte()*(360.0/256);
|
||||
$this->yaw = $this->getByte()*(360.0/256);
|
||||
$this->headYaw = $this->getByte()*(360.0/256);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt(count($this->entities));
|
||||
foreach($this->entities as $d){
|
||||
$this->putLong($d[0]); //eid
|
||||
$this->putFloat($d[1]); //x
|
||||
$this->putFloat($d[2]); //y
|
||||
$this->putFloat($d[3]); //z
|
||||
$this->putFloat($d[4]); //yaw
|
||||
$this->putFloat($d[5]); //headYaw
|
||||
$this->putFloat($d[6]); //pitch
|
||||
}
|
||||
$this->putLong($this->eid);
|
||||
$this->putFloat($this->x);
|
||||
$this->putFloat($this->y);
|
||||
$this->putFloat($this->z);
|
||||
$this->putByte($this->pitch/(360.0/256));
|
||||
$this->putByte($this->yaw/(360.0/256));
|
||||
$this->putByte($this->headYaw/(360.0/256));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user