added some new mobs

This commit is contained in:
GameHerobrine 2023-02-21 18:54:20 +03:00
parent 5fdf1f6b75
commit d5d634b6fb
9 changed files with 111 additions and 1 deletions

View file

@ -55,7 +55,7 @@ class EntityAPI{
if(is_int($args[0])) $type = $args[0];
else $type = $mob[strtolower($args[0])];
if($type < 10 || $type > 36){
if($type < 10 || $type > 39){
return "Unknown mob.";
}
$mobName = ucfirst(array_flip($mob)[$type]);

7
src/entity/Neutral.php Normal file
View file

@ -0,0 +1,7 @@
<?php
abstract class Neutral extends Creature
{
}

9
src/entity/Tameable.php Normal file
View file

@ -0,0 +1,9 @@
<?php
interface Tameable
{
public function isTamed();
public function getOwner();
}

View file

@ -0,0 +1,31 @@
<?php
class Wolf extends Animal implements Tameable
{
const TYPE = MOB_WOLF;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.6, 0.8);
parent::__construct($level, $eid, $class, $type, $data);
$this->setSpeed(0.3);
$this->setName("Wolf");
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
}
public function isTamed()
{
return false;
}
public function getOwner()
{
return null;
}
public function isFood($id) //TODO
{
return false;
}
}

View file

@ -0,0 +1,16 @@
<?php
class Enderman extends Monster
{
const TYPE = MOB_ENDERMAN;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.6, 2.9);
parent::__construct($level, $eid, $class, $type, $data);
$this->setName("Enderman");
$this->setSpeed(0.3);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 40, "generic");
}
}

View file

@ -0,0 +1,14 @@
<?php
class SilverFish extends Monster
{
const TYPE = MOB_SILVERFISH;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.3, 0.7);
parent::__construct($level, $eid, $class, $type, $data);
$this->setSpeed(0.3);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
$this->setName("Silverfish");
}
}

View file

@ -0,0 +1,15 @@
<?php
class Slime extends Monster
{
const TYPE = MOB_SLIME;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
parent::__construct($level, $eid, $class, $type, $data);
$this->setName("Slime");
/* Health formula
* SlimeSize = Slime::getSlimeSize(this);
* return SlimeSize * SlimeSize;
*/
}
}

View file

@ -0,0 +1,13 @@
<?php
class Villager extends Neutral //TODO AI
{
const TYPE = MOB_VILLAGER;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.6, 1.8);
$this->setSpeed(0.3);
$this->setName("Villager");
parent::__construct($level, $eid, $class, $type, $data);
}
}

View file

@ -11,11 +11,16 @@ class EntityRegistry{
self::registerEntity(Sheep::class);
self::registerEntity(Cow::class);
self::registerEntity(Mooshroom::class);
self::registerEntity(Villager::class);
self::registerEntity(Wolf::class);
self::registerEntity(Creeper::class);
self::registerEntity(PigZombie::class);
self::registerEntity(Skeleton::class);
self::registerEntity(Spider::class);
self::registerEntity(Zombie::class);
self::registerEntity(SilverFish::class);
//self::registerEntity(Slime::class); TODO some missing property probably
self::registerEntity(Enderman::class);
self::registerEntity(Arrow::class);
self::registerEntity(PrimedTNT::class);
self::registerEntity(Painting::class);