extra changes

This commit is contained in:
Shoghi Cervantes 2014-02-28 00:00:04 +01:00
parent 2bf3f0de73
commit 6d5e2648cf
3 changed files with 57 additions and 2 deletions

View File

@ -50,6 +50,8 @@ abstract class Entity extends Position{
public $lastUpdate;
public $maxFireTicks;
public $fireTicks;
public $namedtag;
protected $inWater;
public $noDamageTicks;
private $justCreated;
@ -75,7 +77,7 @@ abstract class Entity extends Position{
$this->level = $level;
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
$this->setPosition(new Vector3($this->namedtag->x, $this->namedtag->y, $this->namedtag->z));
$this->setPosition(new Vector3($this->namedtag->Pos[0], $this->namedtag->Pos[1], $this->namedtag->Pos[2]));
$index = PMFLevel::getIndex($this->x >> 4, $this->z >> 4);
$this->chunkIndex = $index;
Entity::$list[$this->id] = $this;
@ -85,6 +87,12 @@ abstract class Entity extends Position{
$this->initEntity();
$this->server->api->dhandle("entity.add", $this);
}
public function saveNBT(){
$this->namedtag->Pos[0] = $this->x;
$this->namedtag->Pos[1] = $this->y;
$this->namedtag->Pos[2] = $this->z;
}
protected abstract function initEntity();
@ -138,6 +146,8 @@ abstract class Entity extends Position{
Entity::$needUpdate[$this->id] = $this;
}
public abstract function getMetadata();
public function setOnFire($seconds){
$ticks = $seconds * 20;
if($ticks > $this->fireTicks){

View File

@ -959,7 +959,7 @@ class Player{
$this->dataPacket($pk);
$terrain = true;
foreach($this->server->api->player->getAll($this->level) as $player){
foreach($this->level->getPlayers() as $player){
if($player !== $this and $player->entity instanceof Entity){
$pk = new MoveEntityPacket_PosRot;
$pk->eid = $player->entity->eid;

View File

@ -20,5 +20,50 @@
*/
class HumanEntity extends CreatureEntity implements ProjectileSourceEntity{
protected $nameTag;
protected function initEntity(){
if(isset($this->namedtag->nameTag)){
$this->nameTag = $this->namedtag->nameTag;
}
}
public function spawnTo(Player $player){
$pk = new AddPlayerPacket;
$pk->clientID = 0;
$pk->username = $this->nameTag;
$pk->eid = $this->id;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->yaw = 0;
$pk->pitch = 0;
$pk->unknown1 = 0;
$pk->unknown2 = 0;
$pk->metadata = $this->getMetadata();
$player->dataPacket($pk);
/*
$pk = new SetEntityMotionPacket;
$pk->eid = $this->id;
$pk->speedX = $this->velocity->x;
$pk->speedY = $this->velocity->y;
$pk->speedZ = $this->velocity->z;
$player->dataPacket($pk);*/
$this->sendMotion($player);
/*
$pk = new PlayerEquipmentPacket;
$pk->eid = $this->id;
$pk->item = $this->player->getSlot($this->player->slot)->getID();
$pk->meta = $this->player->getSlot($this->player->slot)->getMetadata();
$pk->slot = 0;
$player->dataPacket($pk);*/
$this->sendEquipment($player)
$this->sendArmor($player);
}
}