mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-24 13:39:44 +00:00
classes for all animals, moved construcors
This commit is contained in:
parent
efa2e11497
commit
327e74e7aa
8 changed files with 59 additions and 43 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
interface Ageable{
|
interface Ageable{
|
||||||
|
public function isBaby();
|
||||||
}
|
}
|
||||||
|
|
@ -4,5 +4,7 @@ TODO:
|
||||||
move methods
|
move methods
|
||||||
*/
|
*/
|
||||||
class Animal extends Creature implements Ageable{
|
class Animal extends Creature implements Ageable{
|
||||||
|
public function isBaby(){
|
||||||
|
return $this->data["isBaby"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,38 +114,6 @@ class Entity extends Position{
|
||||||
break;
|
break;
|
||||||
case ENTITY_MOB:
|
case ENTITY_MOB:
|
||||||
switch($this->type){
|
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
|
//Monsters
|
||||||
case MOB_CREEPER:
|
case MOB_CREEPER:
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
|
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:20, "generic");
|
||||||
|
|
@ -219,10 +187,7 @@ class Entity extends Position{
|
||||||
$this->close();
|
$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(){
|
public function updateFuse(){
|
||||||
if($this->closed === true){
|
if($this->closed === true){
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ class EntityRegistry{
|
||||||
public static function registerEntities(){
|
public static function registerEntities(){
|
||||||
self::$entityList = new EntityList;
|
self::$entityList = new EntityList;
|
||||||
self::registerEntity(Pig::class);
|
self::registerEntity(Pig::class);
|
||||||
|
self::registerEntity(Chicken::class);
|
||||||
|
self::registerEntity(Sheep::class);
|
||||||
|
self::registerEntity(Cow::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Register an Entity*/
|
/*Register an Entity*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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"));
|
||||||
|
$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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
TODO:
|
|
||||||
move methods
|
|
||||||
*/
|
|
||||||
class Pig extends Animal{
|
class Pig extends Animal{
|
||||||
const TYPE = 12;
|
const TYPE = MOB_PIG;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||||
console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type);
|
console("A constructor which indicates it works! ".":".$eid.":".$class.":".$type);
|
||||||
parent::__construct($level, $eid, $class, $type, $data);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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->update();
|
||||||
|
//$this->setName('Sheep');
|
||||||
|
$this->size = $this->isBaby() ? 0.65 : 1.3;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue