This commit is contained in:
GameHerobrine 2022-09-26 00:16:46 +03:00
commit 140e9bcaa4
12 changed files with 35 additions and 12 deletions

View file

@ -32,7 +32,6 @@ class PocketMinecraftServer{
console("[INFO] Starting Minecraft PE server on " . ($this->serverip === "0.0.0.0" ? "*" : $this->serverip) . ":" . $this->port);
EntityRegistry::registerEntities();
define("BOOTUP_RANDOM", Utils::getRandomBytes(16));
$this->serverID = $this->serverID === false ? Utils::readLong(substr(Utils::getUniqueID(true, $this->serverip . $this->port), 8)) : $this->serverID;
$this->seed = $this->seed === false ? Utils::readInt(Utils::getRandomBytes(4, false)) : $this->seed;

View file

@ -123,6 +123,29 @@ class Entity extends Position{
}
}
/**
* @param mixed $e Entity instance or EID
*/
public static function getNameOf($e){
if($e instanceof Entity){
return $e->getName();
}elseif(($ent = ServerAPI::request()->api->entity->get($e)) != false){
return $ent->getName();
}
}
public static function getSizeOf($e){
if($e instanceof Entity){
return $e->getSize();
}elseif(($ent = ServerAPI::request()->api->entity->get($e)) != false){
return $ent->getSize();
}
}
public function getSize(){
return $this->size;
}
public function lookOn($entity){
$horizontal = sqrt(pow(($target->entity->x - $entity->x), 2) + pow(($target->entity->z - $entity->z) , 2));
$vertical = $target->entity->y - ($entity->y + -0.5); /*0.5 = $entity->getEyeHeight()*/
@ -683,7 +706,7 @@ class Entity extends Position{
public function setName($name){
$this->name = $name;
$this->server->query("UPDATE entities SET name = '".str_replace("'", "", $this->name)."' WHERE EID = ".$this->eid.";");
//$this->server->query("UPDATE entities SET name = '".str_replace("'", "", $this->name)."' WHERE EID = ".$this->eid.";"); is this neccessary for database?
}
public function look($pos2){

View file

@ -19,6 +19,7 @@ class PropertyEntity{
return $this->name;
}
}
class EntityList{
public function getEntities(){
return $this->entities;
@ -26,12 +27,12 @@ class EntityList{
public function addEntity(PropertyEntity $property){
$this->entities[$property->getEntityType()] = $property;
}
public function getEntityFromTypeAndClass($type, $class){
return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
}
private $entities = [];
}
class EntityRegistry{
public static $entityList;
/*Register all entities*/

View file

@ -8,7 +8,7 @@ class Chicken extends Animal{
$server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg"));
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic");
$this->update();
//$this->setName('Chicken');
$this->setName('Chicken');
$this->size = $this->isBaby() ? 0.35 : 0.7;
}
public function isFood($id){

View file

@ -6,7 +6,7 @@ class Cow extends Animal{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
$this->update();
//$this->setName('Cow');
$this->setName('Cow');
$this->size = $this->isBaby() ? 0.65 : 1.4;
}
public function isFood($id){

View file

@ -9,7 +9,7 @@ class Pig extends Animal{
$this->update();
$this->server = ServerAPI::request();
//$this->server->schedule(60, array($this, "testMovement"));
//$this->setName('Pig');
$this->setName('Pig');
$this->size = $this->isBaby() ? 0.60 : 1.1875;
}
public function isFood($id){

View file

@ -8,7 +8,7 @@ class Sheep extends Animal{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
$this->update();
//$this->setName('Sheep');
$this->setName('Sheep');
$this->size = $this->isBaby() ? 0.65 : 1.3;
}

View file

@ -6,7 +6,7 @@ class Creeper extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Creeper');
$this->setName('Creeper');
$this->size = 1.6; //not original
}

View file

@ -5,7 +5,7 @@ class PigZombie extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Pigman');
$this->setName('Pigman');
$this->size = 1.8; //not original
}

View file

@ -6,7 +6,7 @@ class Skeleton extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Skeleton');
$this->setName('Skeleton');
$this->size = 1.9;
}

View file

@ -6,7 +6,7 @@ class Spider extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Spider');
$this->setName('Spider');
$this->size = 0.6; //not original
}

View file

@ -6,7 +6,7 @@ class Zombie extends Monster{
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Zombie');
$this->setName('Zombie');
$this->size = 1.95;
}