mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
0.9.x setentitymotion packet added
This commit is contained in:
parent
532acb549d
commit
6cbc3824f3
7 changed files with 20 additions and 44 deletions
|
|
@ -774,11 +774,8 @@ class Player{
|
|||
if(($data->speedX === 0 && $data->speedY === 0 && $data->speedZ === 0) || ($data->speedX === $data->lastSpeedX && $data->speedY === $data->lastSpeedY && $data->lastSpeedZ === $data->speedZ)){ //causer of packet flood is eliminated.
|
||||
break;
|
||||
}
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $data->eid;
|
||||
$pk->speedX = $data->speedX;
|
||||
$pk->speedY = $data->speedY;
|
||||
$pk->speedZ = $data->speedZ;
|
||||
$pk = new SetEntityMotionPacket; //TODO one packet for all entities if possible
|
||||
$pk->entities = [[$data->eid, $data->speedX, $data->speedY, $data->speedZ]];
|
||||
$this->dataPacket($pk);
|
||||
$data->lastSpeedZ = $data->speedZ;
|
||||
$data->lastSpeedY = $data->speedY;
|
||||
|
|
|
|||
|
|
@ -50,10 +50,7 @@ abstract class Creature extends Living{
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -940,10 +940,7 @@ class Entity extends Position
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new PlayerEquipmentPacket();
|
||||
|
|
@ -968,10 +965,7 @@ class Entity extends Position
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
break;
|
||||
case ENTITY_FALLING:
|
||||
|
|
@ -985,10 +979,7 @@ class Entity extends Position
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,11 +54,8 @@ class Arrow extends Projectile{
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ class Minecart extends Vehicle{
|
|||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,7 @@ class PrimedTNT extends Entity{
|
|||
$pk->did = 0;
|
||||
$player->dataPacket($pk);
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
class SetEntityMotionPacket extends RakNetDataPacket{
|
||||
public $eid;
|
||||
public $speedX;
|
||||
public $speedY;
|
||||
public $speedZ;
|
||||
public $entities;
|
||||
|
||||
public function pid(){
|
||||
return ProtocolInfo::SET_ENTITY_MOTION_PACKET;
|
||||
|
|
@ -16,10 +13,13 @@ class SetEntityMotionPacket extends RakNetDataPacket{
|
|||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putInt($this->eid);
|
||||
$this->putShort((int) ($this->speedX * 400));
|
||||
$this->putShort((int) ($this->speedY * 400));
|
||||
$this->putShort((int) ($this->speedZ * 400));
|
||||
$this->putInt(count($this->entities));
|
||||
foreach($this->entities as $d){
|
||||
$this->putInt($d[0]);
|
||||
$this->putShort((int) ($d[1]*8000));
|
||||
$this->putShort((int) ($d[2]*8000));
|
||||
$this->putShort((int) ($d[3]*8000));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue