Fixed mess of entity ID 0 for players, fixed emeralds

This commit is contained in:
Dylan K. Taylor 2017-02-20 19:40:28 +00:00
parent d25c8d93ca
commit 1ee689e759
4 changed files with 14 additions and 26 deletions

View File

@ -1117,7 +1117,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->level->sleepTicks = 0;
$pk = new AnimatePacket();
$pk->eid = 0;
$pk->eid = $this->id;
$pk->action = 3; //Wake up
$this->dataPacket($pk);
}
@ -1343,15 +1343,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->eid = $this->id;
$pk->target = $entity->getId();
$this->server->broadcastPacket($entity->getViewers(), $pk);
$pk = new TakeItemEntityPacket();
$pk->eid = 0;
$pk->target = $entity->getId();
$this->dataPacket($pk);
$this->inventory->addItem(clone $item);
$entity->kill();
}elseif($entity instanceof DroppedItem){
@ -1378,15 +1373,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->eid = $this->id;
$pk->target = $entity->getId();
$this->server->broadcastPacket($entity->getViewers(), $pk);
$pk = new TakeItemEntityPacket();
$pk->eid = 0;
$pk->target = $entity->getId();
$this->dataPacket($pk);
$this->inventory->addItem(clone $item);
$entity->kill();
}
@ -1523,7 +1513,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
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->eid = 0;
$pk->eid = $this->id;
$pk->motionX = $mot->x;
$pk->motionY = $mot->y;
$pk->motionZ = $mot->z;
@ -1547,7 +1537,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$entries = $sendAll ? $this->attributeMap->getAll() : $this->attributeMap->needSend();
if(count($entries) > 0){
$pk = new UpdateAttributesPacket();
$pk->entityId = 0;
$pk->entityId = $this->id;
$pk->entries = $entries;
$this->dataPacket($pk);
foreach($entries as $entry){
@ -1785,8 +1775,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$spawnPosition = $this->getSpawn();
$pk = new StartGamePacket();
$pk->entityUniqueId = 0;
$pk->entityRuntimeId = 0;
$pk->entityUniqueId = $this->id;
$pk->entityRuntimeId = $this->id;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
@ -2176,7 +2166,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
break;
}
$packet->eid = $this->id;
$pos = new Vector3($packet->x, $packet->y, $packet->z);
switch($packet->action){
@ -3407,7 +3396,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return;
}elseif($this->getLastDamageCause() === $source and $this->spawned){
$pk = new EntityEventPacket();
$pk->eid = 0;
$pk->eid = $this->id;
$pk->event = EntityEventPacket::HURT_ANIMATION;
$this->dataPacket($pk);
@ -3434,7 +3423,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
if($targets !== null){
$this->server->broadcastPacket($targets, $pk);
}else{
$pk->eid = 0;
$this->dataPacket($pk);
}

View File

@ -259,7 +259,7 @@ class Effect{
}
if($entity instanceof Player){
$pk = new MobEffectPacket();
$pk->eid = 0;
$pk->eid = $entity->getId();
$pk->effectId = $this->getId();
$pk->amplifier = $this->getAmplifier();
$pk->particles = $this->isVisible();
@ -304,7 +304,7 @@ class Effect{
}
if($entity instanceof Player){
$pk = new MobEffectPacket();
$pk->eid = 0;
$pk->eid = $entity->getId();
$pk->eventId = MobEffectPacket::EVENT_REMOVE;
$pk->effectId = $this->getId();

View File

@ -661,7 +661,7 @@ abstract class Entity extends Location implements Metadatable{
public function sendPotionEffects(Player $player){
foreach($this->effects as $effect){
$pk = new MobEffectPacket();
$pk->eid = 0;
$pk->eid = $this->id;
$pk->effectId = $effect->getId();
$pk->amplifier = $effect->getAmplifier();
$pk->particles = $effect->isVisible();
@ -691,8 +691,8 @@ abstract class Entity extends Location implements Metadatable{
}
$p->dataPacket(clone $pk);
}
if($this instanceof Player){
$pk->eid = 0;
$this->dataPacket($pk);
}
}
@ -703,7 +703,7 @@ abstract class Entity extends Location implements Metadatable{
public function despawnFrom(Player $player){
if(isset($this->hasSpawned[$player->getLoaderId()])){
$pk = new RemoveEntityPacket();
$pk->eid = $this->getId();
$pk->eid = $this->id;
$player->dataPacket($pk);
unset($this->hasSpawned[$player->getLoaderId()]);
}

View File

@ -126,7 +126,7 @@ class PlayerInventory extends BaseInventory{
$item = $this->getItemInHand();
$pk = new MobEquipmentPacket();
$pk->eid = ($target === $this->getHolder() ? 0 : $this->getHolder()->getId());
$pk->eid = $this->getHolder()->getId();
$pk->item = $item;
$pk->slot = $this->getHeldItemSlot();
$pk->selectedSlot = $this->getHeldItemIndex();