mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Players now have entity id 0
This commit is contained in:
@ -884,7 +884,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
* @return int|bool
|
||||
*/
|
||||
public function dataPacket(DataPacket $packet, $needACK = false){
|
||||
if($this->connected === false){
|
||||
if(!$this->connected){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1010,7 +1010,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->level->sleepTicks = 0;
|
||||
|
||||
$pk = new AnimatePacket();
|
||||
$pk->eid = $this->getId();
|
||||
$pk->eid = 0;
|
||||
$pk->action = 3; //Wake up
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
}
|
||||
@ -1099,7 +1099,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->spawnZ = (int) $spawnPosition->z;
|
||||
$pk->generator = 1; //0 old, 1 infinite, 2 flat
|
||||
$pk->gamemode = $this->gamemode & 0x01;
|
||||
$pk->eid = $this->getId();
|
||||
$pk->eid = 0;
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
$this->sendSettings();
|
||||
|
||||
@ -1274,6 +1274,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->eid = $this->getId();
|
||||
$pk->target = $entity->getId();
|
||||
Server::broadcastPacket($entity->getViewers(), $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
|
||||
$pk = new TakeItemEntityPacket();
|
||||
$pk->eid = 0;
|
||||
$pk->target = $entity->getId();
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
|
||||
$this->inventory->addItem(clone $item);
|
||||
$entity->kill();
|
||||
}elseif($entity instanceof DroppedItem){
|
||||
@ -1303,6 +1309,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->eid = $this->getId();
|
||||
$pk->target = $entity->getId();
|
||||
Server::broadcastPacket($entity->getViewers(), $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
|
||||
$pk = new TakeItemEntityPacket();
|
||||
$pk->eid = 0;
|
||||
$pk->target = $entity->getId();
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
|
||||
|
||||
$this->inventory->addItem(clone $item);
|
||||
$entity->kill();
|
||||
}
|
||||
@ -1400,7 +1412,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination
|
||||
$this->teleport($ev->getTo());
|
||||
}else{
|
||||
$this->sendPosition($this, null, null, MovePlayerPacket::MODE_NORMAL, Network::CHANNEL_MOVEMENT, $this->hasSpawned);
|
||||
$this->level->addEntityMovement($this->x >> 4, $this->z >> 4, $this->getId(), $this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->yaw);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1439,6 +1451,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if(parent::setMotion($mot)){
|
||||
if($this->chunk !== null){
|
||||
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ);
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->entities[] = [0, $mot->x, $mot->y, $mot->z];
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_MOVEMENT));
|
||||
}
|
||||
|
||||
if($this->motionY > 0){
|
||||
@ -1764,7 +1779,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->spawnZ = (int) $spawnPosition->z;
|
||||
$pk->generator = 1; //0 old, 1 infinite, 2 flat
|
||||
$pk->gamemode = $this->gamemode & 0x01;
|
||||
$pk->eid = $this->getId(); //Always use EntityID as zero for the actual player
|
||||
$pk->eid = 0; //Always use EntityID as zero for the actual player
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
|
||||
|
||||
$pk = new SetTimePacket();
|
||||
@ -2122,7 +2137,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
if ($this->isSurvival()) {
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
--$slot->count;
|
||||
$this->inventory->setItemInHand($slot, $this);
|
||||
$this->inventory->setItemInHand($slot);
|
||||
$this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
|
||||
}
|
||||
|
||||
@ -3139,7 +3154,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return;
|
||||
}elseif($this->getLastDamageCause() === $source and $this->spawned){
|
||||
$pk = new EntityEventPacket();
|
||||
$pk->eid = $this->getId();
|
||||
$pk->eid = 0;
|
||||
$pk->event = EntityEventPacket::HURT_ANIMATION;
|
||||
$this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
|
||||
}
|
||||
@ -3160,8 +3175,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$pk->mode = $mode;
|
||||
|
||||
if($targets !== null){
|
||||
Server::broadcastPacket($targets, $pk);
|
||||
Server::broadcastPacket($targets, $pk->setChannel($channel));
|
||||
}else{
|
||||
$pk->eid = 0;
|
||||
$this->dataPacket($pk->setChannel($channel));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user