From 6a321aabe058cf7c5fa27d4a530018b01c125cee Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 7 Jun 2022 00:06:56 +0300 Subject: [PATCH 1/3] simple entity registering, tested on pig, some classes were created, althrough they are still not implemented --- src/API/EntityAPI.php | 9 ++++- src/PocketMinecraftServer.php | 1 + src/config.php | 2 +- src/dependencies.php | 6 +++ src/entity/Ageable.php | 5 +++ src/entity/Animal.php | 8 ++++ src/entity/Creature.php | 8 ++++ src/entity/Damageable.php | 5 +++ src/entity/Entity.php | 3 +- src/entity/EntityRegistry.php | 56 +++++++++++++++++++++++++++ src/entity/Living.php | 3 ++ src/entity/animal/Pig.php | 12 ++++++ src/material/block/solid/Obsidian.php | 2 +- 13 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 src/entity/EntityRegistry.php diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index e4a83231..d9d2ef83 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -270,7 +270,14 @@ class EntityAPI{ public function add(Level $level, $class, $type = 0, $data = array()){ $eid = $this->eCnt++; - $this->entities[$eid] = new Entity($level, $eid, $class, $type, $data); + $efl = EntityRegistry::$entityList->getEntityFromType($type); + if($efl instanceof PropertyEntity){ + $class = $efl->getEntityName(); + console("yey"); + $this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data); + }else{ + $this->entities[$eid] = new Entity($level, $eid, $class, $type, $data); + } $this->server->handle("entity.add", $this->entities[$eid]); return $this->entities[$eid]; } diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 4b00b49e..129debdc 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -31,6 +31,7 @@ class PocketMinecraftServer{ private function load(){ global $dolog; + EntityRegistry::registerEntities(); $this->version = new VersionString(); /*if(defined("DEBUG") and DEBUG >= 0){ @cli_set_process_title("NostalgiaCore ".MAJOR_VERSION); diff --git a/src/config.php b/src/config.php index c2a417bd..bd234c48 100644 --- a/src/config.php +++ b/src/config.php @@ -67,7 +67,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH); ini_set("memory_limit", "256M"); //Default define("LOG", true); define("START_TIME", microtime(true)); -define("MAJOR_VERSION", "1.0.2 (Alpha_1.3.12)"); +define("MAJOR_VERSION", "1.0.2dev (Alpha_1.3.12)"); define("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha"); define("CURRENT_API_VERSION", '12.1'); diff --git a/src/dependencies.php b/src/dependencies.php index 59a4fd15..9b9383a0 100644 --- a/src/dependencies.php +++ b/src/dependencies.php @@ -95,6 +95,12 @@ $sha1sum = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; require_once(FILE_PATH."/src/math/Vector3.php"); require_once(FILE_PATH."/src/world/Position.php"); require_once(FILE_PATH."/src/pmf/PMF.php"); +require_once(FILE_PATH."/src/entity/Entity.php"); +require_once(FILE_PATH."/src/entity/Damageable.php"); +require_once(FILE_PATH."/src/entity/Living.php"); +require_once(FILE_PATH."/src/entity/Creature.php"); +require_once(FILE_PATH."/src/entity/Ageable.php"); +require_once(FILE_PATH."/src/entity/Animal.php"); require_all(FILE_PATH . "src/"); diff --git a/src/entity/Ageable.php b/src/entity/Ageable.php index e69de29b..46a48934 100644 --- a/src/entity/Ageable.php +++ b/src/entity/Ageable.php @@ -0,0 +1,5 @@ +level = $level; $this->fallY = false; diff --git a/src/entity/EntityRegistry.php b/src/entity/EntityRegistry.php new file mode 100644 index 00000000..99372db6 --- /dev/null +++ b/src/entity/EntityRegistry.php @@ -0,0 +1,56 @@ +class = $class; + $this->type = $type; + $this->name = $name; + } + + public function getEntityClass(){ + return $this->class; + } + public function getEntityType(){ + return $this->type; + } + public function getEntityName(){ + return $this->name; + } +} +class EntityList{ + public function getEntities(){ + return $this->entities; + } + public function addEntity(PropertyEntity $property){ + $this->entities[$property->getEntityType()] = $property; + } + + public function getEntityFromType($type){ + return isset($this->entities[$type]) ? $this->entities[$type] : 0; + } + private $entities = []; +} +class EntityRegistry{ + public static $entityList; + /*Register all entities*/ + public static function registerEntities(){ + self::$entityList = new EntityList; + self::registerEntity(Pig::class); + } + + /*Register an Entity*/ + public static function registerEntity($className){ + $class = new \ReflectionClass($className); + if(is_a($className, Entity::class, true) and !$class->isAbstract()){ + //self::$entityList[$className::TYPE] = $className; + self::$entityList->addEntity(new PropertyEntity($className::CLASS_TYPE, $className::TYPE, $className)); + //self::$shortNames[$className] = $class->getShortName(); what is this even supposed to do? + console("Registered a ".$className); + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/src/entity/Living.php b/src/entity/Living.php index e69de29b..a177696d 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -0,0 +1,3 @@ +isPickaxe() >= 5){ - return 9.4; + return 3.5;//from wiki }else{ return 250; } From 327e74e7aa3c417dd520d6d1004489054204d29a Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 7 Jun 2022 12:59:33 +0300 Subject: [PATCH 2/3] classes for all animals, moved construcors --- src/entity/Ageable.php | 2 +- src/entity/Animal.php | 4 +++- src/entity/Entity.php | 37 +---------------------------------- src/entity/EntityRegistry.php | 3 +++ src/entity/animal/Chicken.php | 20 +++++++++++++++++++ src/entity/animal/Cow.php | 13 ++++++++++++ src/entity/animal/Pig.php | 10 +++++----- src/entity/animal/Sheep.php | 13 ++++++++++++ 8 files changed, 59 insertions(+), 43 deletions(-) diff --git a/src/entity/Ageable.php b/src/entity/Ageable.php index 46a48934..7d90d4c8 100644 --- a/src/entity/Ageable.php +++ b/src/entity/Ageable.php @@ -1,5 +1,5 @@ data["isBaby"]; + } } \ No newline at end of file diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 6c2c65a5..76a69333 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -114,38 +114,6 @@ class Entity extends Position{ break; case ENTITY_MOB: switch($this->type){ - - //Animals - case MOB_CHICKEN: - $this->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'); - if(isset($this->data['isBaby'])) $this->size = 0.35; - else $this->size = 0.7; - break; - case MOB_COW: - $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); - $this->update(); - //$this->setName('Cow'); - if(isset($this->data['isBaby'])) $this->size = 0.65; - else $this->size = 1.4; - break; - case MOB_PIG: - $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); - $this->update(); - //$this->setName('Pig'); - if(isset($this->data['isBaby'])) $this->size = 0.60; //not original - else $this->size = 1.1875; - break; - case MOB_SHEEP: - $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:8, "generic"); - $this->update(); - //$this->setName('Sheep'); - if(isset($this->data['isBaby'])) $this->size = 0.65; - else $this->size = 1.3; - break; - //Monsters case MOB_CREEPER: $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic"); @@ -219,10 +187,7 @@ class Entity extends Position{ $this->close(); } } - public function dropAnEgg(){ - ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG,0,1)); - $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); - } + public function updateFuse(){ if($this->closed === true){ return false; diff --git a/src/entity/EntityRegistry.php b/src/entity/EntityRegistry.php index 99372db6..83e85e55 100644 --- a/src/entity/EntityRegistry.php +++ b/src/entity/EntityRegistry.php @@ -38,6 +38,9 @@ class EntityRegistry{ public static function registerEntities(){ self::$entityList = new EntityList; self::registerEntity(Pig::class); + self::registerEntity(Chicken::class); + self::registerEntity(Sheep::class); + self::registerEntity(Cow::class); } /*Register an Entity*/ diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php index e69de29b..5dc85a4b 100644 --- a/src/entity/animal/Chicken.php +++ b/src/entity/animal/Chicken.php @@ -0,0 +1,20 @@ +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->size = $this->isBaby() ? 0.35 : 0.7; + } + + public function dropAnEgg(){ + ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG,0,1)); + $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); + } +} \ No newline at end of file diff --git a/src/entity/animal/Cow.php b/src/entity/animal/Cow.php index e69de29b..2f7914f4 100644 --- a/src/entity/animal/Cow.php +++ b/src/entity/animal/Cow.php @@ -0,0 +1,13 @@ +setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); + $this->update(); + //$this->setName('Cow'); + $this->size = $this->isBaby() ? 0.65 : 1.4; + } +} \ No newline at end of file diff --git a/src/entity/animal/Pig.php b/src/entity/animal/Pig.php index c78017d9..0b9c8815 100644 --- a/src/entity/animal/Pig.php +++ b/src/entity/animal/Pig.php @@ -1,12 +1,12 @@ setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); + $this->update(); + //$this->setName('Pig'); + $this->size = $this->isBaby() ? 0.60 : 1.1875; } } \ No newline at end of file diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index e69de29b..cda6cc48 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -0,0 +1,13 @@ +setHealth(isset($this->data["Health"]) ? $this->data["Health"]:8, "generic"); + $this->update(); + //$this->setName('Sheep'); + $this->size = $this->isBaby() ? 0.65 : 1.3; + } +} \ No newline at end of file From eb1f1e3d0265cf81fb4681f38610b96bc9b5bd12 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 7 Jun 2022 21:39:23 +0300 Subject: [PATCH 3/3] isBaby changed to IsBaby, methods for animals were added --- src/API/EntityAPI.php | 6 +-- src/entity/Animal.php | 10 +++- src/entity/Entity.php | 75 +++----------------------- src/entity/animal/Chicken.php | 9 +++- src/entity/animal/Cow.php | 11 +++- src/entity/animal/Pig.php | 9 +++- src/entity/animal/Sheep.php | 43 ++++++++++++++- src/material/item/generic/SpawnEgg.php | 2 +- src/world/Level.php | 2 +- 9 files changed, 88 insertions(+), 79 deletions(-) diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index d9d2ef83..d81a6ee4 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -133,7 +133,7 @@ class EntityAPI{ $isBaby = 0; if(strtolower($args[2]) == 'baby'){//summon [amount] [baby] if($type > 13){ - $output .= "Baby can be only animals!"; + $output .= "This mob cant be baby!"; break; } $isBaby = 1; @@ -150,7 +150,7 @@ class EntityAPI{ "y" => $spawnY, "z" => $spawnZ, "Health" => $this->hp[$type], - "isBaby" => $isBaby, + "IsBaby" => $isBaby, )); $this->spawnToAll($entityit, $level); } @@ -272,8 +272,8 @@ class EntityAPI{ $eid = $this->eCnt++; $efl = EntityRegistry::$entityList->getEntityFromType($type); if($efl instanceof PropertyEntity){ + console(json_encode($data)); $class = $efl->getEntityName(); - console("yey"); $this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data); }else{ $this->entities[$eid] = new Entity($level, $eid, $class, $type, $data); diff --git a/src/entity/Animal.php b/src/entity/Animal.php index 513e5002..c6fc9641 100644 --- a/src/entity/Animal.php +++ b/src/entity/Animal.php @@ -5,6 +5,14 @@ move methods */ class Animal extends Creature implements Ageable{ public function isBaby(){ - return $this->data["isBaby"]; + return $this->data["IsBaby"]; + } + + public function environmentUpdate(){ + if($this->server->api->getProperty("spawn-animals") !== true){ + $this->close(); + return false; + } + parent::environmentUpdate(); } } \ No newline at end of file diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 76a69333..1c9a6e9b 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -49,7 +49,7 @@ class Entity extends Position{ public $fallStart; private $tickCounter; private $speedMeasure = array(0, 0, 0, 0, 0, 0, 0); - private $server; + protected $server; private $isStatic; public $level; public $isInMinecart = false; @@ -232,7 +232,7 @@ class Entity extends Position{ ); } }elseif($this->class === ENTITY_MOB){ - if($this->data["isBaby"]){ + if($this->data["IsBaby"]){ return array( array(AIR, 0, 0), ); @@ -264,26 +264,6 @@ class Entity extends Position{ array(ARROW, 0, mt_rand(0,2)), array(BONE, 0, mt_rand(0,2)), ); - - //Animals - case MOB_CHICKEN: - return array( - array(FEATHER, 0, mt_rand(0,2)), - array(($this->fire > 0 ? COOKED_CHICKEN:RAW_CHICKEN), 0, 1), - ); - case MOB_COW: - return array( - array(LEATHER, 0, mt_rand(0,2)), - array(($this->fire > 0 ? STEAK:BEEF), 0, 1), - ); - case MOB_PIG: - return array( - array(($this->fire > 0 ? COOKED_PORKCHOP:RAW_PORKCHOP), 0, 1), - ); - case MOB_SHEEP: - return array( - array(WOOL, $this->data["Color"] & 0x0F, 1), - ); } } return array(); @@ -329,15 +309,6 @@ class Entity extends Position{ if($this->class === ENTITY_MOB){ switch($this->type){ - case MOB_CHICKEN: - case MOB_SHEEP: - case MOB_COW: - case MOB_PIG: - if($this->server->api->getProperty("spawn-animals") !== true){ - $this->close(); - return false; - } - break; case MOB_ZOMBIE: case MOB_CREEPER: case MOB_PIGMAN: @@ -689,36 +660,10 @@ class Entity extends Position{ ****************** 0 => array("type" => 0, "value" => $flags) --> Unknown 1 => array("type" => 1, "value" => $this->air) --> Entity Air - 14 => array("type" => 0, "value" => 1) --> isBaby, value: 0 => false, 1 => true + 14 => array("type" => 0, "value" => 1) --> IsBaby, value: 0 => false, 1 => true 16 => array("type" => 0, "value" => 0) --> Unknown 17 => array("type" => 6, "value" => array(0, 0, 0)) --> Unknown */ - - public function sheepColor(){ - $pink = 0.1558; - $brown = 2.85; - $lightgray_black_gray = 14.25; - $chance = Utils::randomFloat() * 100; - switch($chance){ - case($chance <= $pink): - $color = 6; - break; - case($chance > $pink and $chance <= ($brown+$pink)): - $color = 12; - break; - case($chance > ($brown+$pink) and $chance <= ($lightgray_black_gray+$brown+$pink)): - $rand = mt_rand(1,3); - if($rand == 1) $color = 15; - elseif($rand == 2) $color = 7; - else $color = 8; - break; - default: - $color = 0; - break; - } - return $color; - } - public function getMetadata(){ $flags = 0; $flags |= $this->fire > 0 ? 1:0; @@ -731,17 +676,11 @@ class Entity extends Position{ 16 => array("type" => 0, "value" => 0), 17 => array("type" => 6, "value" => array(0, 0, 0)), ); - if(!isset($this->data["isBaby"])){ - $this->data["isBaby"] = 0; + if(!isset($this->data["IsBaby"])){ + $this->data["IsBaby"] = 0; } - $d[14]["value"] = $this->data["isBaby"]; - if($this->class === ENTITY_MOB and $this->type === MOB_SHEEP){ - if(!isset($this->data["Sheared"])){ - $this->data["Sheared"] = 0; - $this->data["Color"] = $this->sheepColor(); - } - $d[16]["value"] = (($this->data["Sheared"] == 1 ? 1:0) << 4) | ($this->data["Color"] & 0x0F); - }elseif($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT){ //ladder fix 2.0 + $d[14]["value"] = $this->data["IsBaby"]; + if($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT){ //ladder fix 2.0 $d[16]["value"] = (int) max(0, $this->data["fuse"] - (microtime(true) - $this->spawntime) * 20); }elseif($this->class === ENTITY_PLAYER){ if($this->player->isSleeping !== false){ diff --git a/src/entity/animal/Chicken.php b/src/entity/animal/Chicken.php index 5dc85a4b..d500f03c 100644 --- a/src/entity/animal/Chicken.php +++ b/src/entity/animal/Chicken.php @@ -3,7 +3,6 @@ class Chicken extends Animal{ const TYPE = MOB_CHICKEN; function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ - console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type); parent::__construct($level, $eid, $class, $type, $data); $server = ServerAPI::request(); $server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); @@ -17,4 +16,12 @@ class Chicken extends Animal{ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG,0,1)); $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); } + + public function getDrops(){ + return $this->isBaby() ? array() : + array( + array(FEATHER, 0, mt_rand(0,2)), + array(($this->fire > 0 ? COOKED_CHICKEN : RAW_CHICKEN), 0, 1), + ); + } } \ No newline at end of file diff --git a/src/entity/animal/Cow.php b/src/entity/animal/Cow.php index 2f7914f4..15782589 100644 --- a/src/entity/animal/Cow.php +++ b/src/entity/animal/Cow.php @@ -3,11 +3,20 @@ class Cow extends Animal{ const TYPE = MOB_COW; function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ - console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type); parent::__construct($level, $eid, $class, $type, $data); $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); $this->update(); //$this->setName('Cow'); $this->size = $this->isBaby() ? 0.65 : 1.4; } + + + public function getDrops(){ + return $this->isBaby() ? array() : + array( + array(LEATHER, 0, mt_rand(0,2)), + array(($this->fire > 0 ? STEAK:BEEF), 0, 1), + ); + } + } \ No newline at end of file diff --git a/src/entity/animal/Pig.php b/src/entity/animal/Pig.php index 0b9c8815..5d7c5088 100644 --- a/src/entity/animal/Pig.php +++ b/src/entity/animal/Pig.php @@ -2,11 +2,18 @@ class Pig extends Animal{ const TYPE = MOB_PIG; function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ - console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type); parent::__construct($level, $eid, $class, $type, $data); $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); $this->update(); //$this->setName('Pig'); $this->size = $this->isBaby() ? 0.60 : 1.1875; } + + public function getDrops(){ + return $this->isBaby() ? array() : + array( + array(($this->fire > 0 ? COOKED_PORKCHOP:RAW_PORKCHOP), 0, 1), + ); + } + } \ No newline at end of file diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index cda6cc48..a01b4e15 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -3,11 +3,50 @@ class Sheep extends Animal{ const TYPE = MOB_SHEEP; function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ - console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type); parent::__construct($level, $eid, $class, $type, $data); - $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:8, "generic"); + $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic"); $this->update(); //$this->setName('Sheep'); $this->size = $this->isBaby() ? 0.65 : 1.3; } + + public function getDrops(){ + return $this->isBaby() ? array() : + array( + array(WOOL, $this->data["Color"] & 0x0F, 1), + ); + } + public function getMetadata(){ + $d = parent::getMetadata(); + if(!isset($this->data["Sheared"])){ + $this->data["Sheared"] = 0; + $this->data["Color"] = $this->sheepColor(); + } + $d[16]["value"] = (($this->data["Sheared"] == 1 ? 1:0) << 4) | ($this->data["Color"] & 0x0F); //dark manipulations are happening here... + return $d; + } + public function sheepColor(){ + $pink = 0.1558; + $brown = 2.85; + $lightgray_black_gray = 14.25; + $chance = Utils::randomFloat() * 100; + switch($chance){ + case($chance <= $pink): + $color = 6; + break; + case($chance > $pink and $chance <= ($brown+$pink)): + $color = 12; + break; + case($chance > ($brown+$pink) and $chance <= ($lightgray_black_gray+$brown+$pink)): + $rand = mt_rand(1,3); + if($rand == 1) $color = 15; + elseif($rand == 2) $color = 7; + else $color = 8; + break; + default: + $color = 0; + break; + } + return $color; + } } \ No newline at end of file diff --git a/src/material/item/generic/SpawnEgg.php b/src/material/item/generic/SpawnEgg.php index 6ee32f8f..82c24907 100644 --- a/src/material/item/generic/SpawnEgg.php +++ b/src/material/item/generic/SpawnEgg.php @@ -43,7 +43,7 @@ class SpawnEggItem extends Item{ "x" => $block->x + 0.5, "y" => $block->y, "z" => $block->z + 0.5, - "isBaby" => $ageable ? Utils::chance(5) ? 1 : 0 : 0, + "IsBaby" => $ageable ? Utils::chance(5) ? 1 : 0 : 0, ); $e = ServerAPI::request()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data); ServerAPI::request()->api->entity->spawnToAll($e); diff --git a/src/world/Level.php b/src/world/Level.php index 444d8b78..9df4baf5 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -163,7 +163,7 @@ class Level{ "id" => $entity->type, "Color" => @$entity->data["Color"], "Sheared" => @$entity->data["Sheared"], - "isBaby" => @$entity->data["isBaby"], + "IsBaby" => @$entity->data["IsBaby"], "Health" => $entity->health, "Pos" => array( 0 => $entity->x,