monsters are separated now

This commit is contained in:
GameHerobrine 2022-06-16 20:53:40 +03:00
parent 27be94ad1b
commit dbc199f34b
10 changed files with 112 additions and 79 deletions

View file

@ -272,7 +272,6 @@ class EntityAPI{
$eid = $this->eCnt++;
$efl = EntityRegistry::$entityList->getEntityFromType($type);
if($efl instanceof PropertyEntity){
console(json_encode($data));
$class = $efl->getEntityName();
$this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data);
}else{

View file

@ -114,38 +114,7 @@ class Entity extends Position{
break;
case ENTITY_MOB:
switch($this->type){
//Monsters
case MOB_CREEPER:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Creeper');
$this->size = 1.6; //not original
break;
case MOB_PIGMAN:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Pigman');
$this->size = 1.8; //not original
break;
case MOB_SKELETON:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Skeleton');
$this->size = 1.9;
break;
case MOB_SPIDER:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Spider');
$this->size = 0.6; //not original
break;
case MOB_ZOMBIE:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Zombie');
$this->size = 1.95;
break;
default: //no break uwu?
default:
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:1, "generic");
$this->update();
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
@ -237,34 +206,6 @@ class Entity extends Position{
array(AIR, 0, 0),
);
}
switch($this->type){
//Monsters
case MOB_ZOMBIE:
return array(
array(CARROT, 0, Utils::chance(0.83) ? 1 : 0),
array(POTATO, 0, Utils::chance(0.83) ? 1 : 0),
array(FEATHER, 0, mt_rand(0,2)),
);
case MOB_SPIDER:
return array(
array(STRING, 0, mt_rand(0,2)),
);
case MOB_PIGMAN:
return array(
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
array(GOLD_INGOT, 0, mt_rand(0,1)),
);
case MOB_CREEPER:
return array(
array(GUNPOWDER, 0, mt_rand(0,2)),
);
case MOB_SKELETON:
return array(
array(ARROW, 0, mt_rand(0,2)),
array(BONE, 0, mt_rand(0,2)),
);
}
}
return array();
}
@ -306,21 +247,6 @@ class Entity extends Position{
return false;
}
}
if($this->class === ENTITY_MOB){
switch($this->type){
case MOB_ZOMBIE:
case MOB_CREEPER:
case MOB_PIGMAN:
case MOB_SKELETON:
case MOB_SPIDER:
if($this->server->api->getProperty("spawn-mobs") !== true){
$this->close();
return false;
}
break;
}
}
if($this->class !== ENTITY_PLAYER and ($this->x <= 0 or $this->z <= 0 or $this->x >= 256 or $this->z >= 256 or $this->y >= 128 or $this->y <= 0)){
$this->close();

View file

@ -41,6 +41,11 @@ class EntityRegistry{
self::registerEntity(Chicken::class);
self::registerEntity(Sheep::class);
self::registerEntity(Cow::class);
self::registerEntity(Creeper::class);
self::registerEntity(PigZombie::class);
self::registerEntity(Skeleton::class);
self::registerEntity(Spider::class);
self::registerEntity(Zombie::class);
}
/*Register an Entity*/

View file

@ -0,0 +1,10 @@
<?php
class Monster extends Creature{
public function environmentUpdate(){
parent::environmentUpdate();
if($this->server->api->getProperty("spawn-mobs") !== true){
$this->close();
return false;
}
}
}

View file

@ -0,0 +1,18 @@
<?php
class Creeper extends Monster{
const TYPE = MOB_CREEPER;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Creeper');
$this->size = 1.6; //not original
}
public function getDrops(){
return array(
array(GUNPOWDER, 0, mt_rand(0,2)),
);
}
}

View file

@ -0,0 +1,18 @@
<?php
class PigZombie extends Monster{
const TYPE = MOB_PIGMAN;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Pigman');
$this->size = 1.8; //not original
}
public function getDrops(){
return array(
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
array(GOLD_INGOT, 0, mt_rand(0,1)),
);
}
}

View file

@ -0,0 +1,19 @@
<?php
class Skeleton extends Monster{
const TYPE = MOB_SKELETON;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Skeleton');
$this->size = 1.9;
}
public function getDrops(){
return array(
array(ARROW, 0, mt_rand(0,2)),
array(BONE, 0, mt_rand(0,2)),
);
}
}

View file

@ -0,0 +1,18 @@
<?php
class Spider extends Monster{
const TYPE = MOB_SPIDER;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
$this->update();
//$this->setName('Spider');
$this->size = 0.6; //not original
}
public function getDrops(){
return array(
array(STRING, 0, mt_rand(0,2)),
);
}
}

View file

@ -0,0 +1,20 @@
<?php
class Zombie extends Monster{
const TYPE = MOB_ZOMBIE;
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 20, "generic");
$this->update();
//$this->setName('Zombie');
$this->size = 1.95;
}
public function getDrops(){
return array(
array(CARROT, 0, Utils::chance(0.83) ? 1 : 0),
array(POTATO, 0, Utils::chance(0.83) ? 1 : 0),
array(FEATHER, 0, mt_rand(0,2)),
);
}
}

View file

@ -92,9 +92,9 @@ class RailBlock extends FlowableBlock{
}
foreach($deltaY as $y){
$v3 = new Vector3(
$rail.getFloorX() + $blocks[1][0],
$rail.getFloorY() + $y,
$rail.getFloorZ() + $blocks[1][1]
$rail->getFloorX() + $blocks[1][0],
$rail->getFloorY() + $y,
$rail->getFloorZ() + $blocks[1][1]
);
$idToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getID();
$metaToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getMetadata();