mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
small change to packet sending method, entities are spawning again, raised mob spawner limit to 50
This commit is contained in:
parent
d9c096357a
commit
ddc7bea48b
4 changed files with 14 additions and 7 deletions
|
|
@ -50,6 +50,6 @@ class UDPSocket{
|
|||
return false;
|
||||
}
|
||||
|
||||
return @socket_sendto($this->sock, $data, strlen($data), 0, $dest, $port);
|
||||
return socket_sendto($this->sock, $data, strlen($data), MSG_DONTROUTE, $dest, $port);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,13 @@ class MoveEntityPacket_PosRot extends RakNetDataPacket{
|
|||
}
|
||||
|
||||
public function decode(){
|
||||
|
||||
$this->get(7);
|
||||
$this->eid = $this->getInt();
|
||||
$this->x = $this->getFloat();
|
||||
$this->y = $this->getFloat();
|
||||
$this->z = $this->getFloat();
|
||||
$this->yaw = $this->getFloat();
|
||||
$this->pitch = $this->getFloat();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ class RotateHeadPacket extends RakNetDataPacket{
|
|||
}
|
||||
|
||||
public function decode(){
|
||||
|
||||
$this->get(7); //id + data
|
||||
$this->eid = $this->getInt();
|
||||
$this->yaw = $this->getByte();
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class MobSpawner{
|
||||
private $server;
|
||||
public $level;
|
||||
const MOB_LIMIT = 25; //constant for now
|
||||
const MOB_LIMIT = 50; //constant for now
|
||||
public function __construct(Level $level){
|
||||
$this->server = ServerAPI::request();
|
||||
$this->level = $level;
|
||||
|
|
@ -20,8 +20,7 @@ class MobSpawner{
|
|||
}
|
||||
|
||||
public function handle(){
|
||||
return false;
|
||||
if($this->countEntities() > self::MOB_LIMIT && count($this->level->players) <= 0){
|
||||
if($this->countEntities() > self::MOB_LIMIT || count($this->level->players) <= 0){
|
||||
return false; //not spawning
|
||||
}
|
||||
return $this->spawnMobs();
|
||||
|
|
@ -46,7 +45,7 @@ class MobSpawner{
|
|||
if(!$y || $y < 0){
|
||||
return false;
|
||||
}
|
||||
$data = $this->genPosData($x, $y, $z);
|
||||
$data = $this->genPosData($x, $y + 1, $z);
|
||||
if($baby != 2) $data["IsBaby"] = $baby;
|
||||
$e = $this->server->api->entity->add($this->level, 2, $type, $data);
|
||||
if($e instanceof Entity){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue