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

View File

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

View File

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

View File

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