This commit is contained in:
ArkQuark 2022-06-16 20:54:10 +03:00
commit 6f99648a72
10 changed files with 113 additions and 78 deletions

View file

@ -16,14 +16,16 @@ Supported version: 0.8.1
• Player hotbar is saved. • Player hotbar is saved.
• Advanced cache option. • Extra options (Only on NostalgiaCore!)
• Server is starting faster. • Server is starting faster (~0.7 sec).
• Vector2 is fixed. • Vector2 is fixed.
• Players can't join as "RCON" or "CONSOLE". • Players can't join as "RCON" or "CONSOLE".
• New many content such NEW entity system and Worked Nether Reactor!
...and etc. ...and etc.
# Download Stable NostalgiaCore # Download Stable NostalgiaCore

View file

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

View file

@ -114,38 +114,7 @@ class Entity extends Position{
break; break;
case ENTITY_MOB: case ENTITY_MOB:
switch($this->type){ switch($this->type){
//Monsters default:
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?
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:1, "generic"); $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:1, "generic");
$this->update(); $this->update();
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type)); //$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
@ -237,34 +206,6 @@ class Entity extends Position{
array(AIR, 0, 0), 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(); return array();
} }
@ -307,21 +248,6 @@ class Entity extends Position{
} }
} }
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)){ 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(); $this->close();
return false; return false;

View file

@ -41,6 +41,11 @@ class EntityRegistry{
self::registerEntity(Chicken::class); self::registerEntity(Chicken::class);
self::registerEntity(Sheep::class); self::registerEntity(Sheep::class);
self::registerEntity(Cow::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*/ /*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)),
);
}
}