mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
slimes are added + some of their features. last mob prob?
This commit is contained in:
parent
e6effaa6d9
commit
0f6784c4f3
2 changed files with 45 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
class Slime extends Monster
|
||||
{
|
||||
const TYPE = MOB_SLIME;
|
||||
protected $size;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setName("Slime");
|
||||
|
|
@ -10,6 +11,49 @@ class Slime extends Monster
|
|||
* SlimeSize = Slime::getSlimeSize(this);
|
||||
* return SlimeSize * SlimeSize;
|
||||
*/
|
||||
$this->setSlimeSize(nullsafe($data["Size"], (1 << mt_rand(0, 2))));
|
||||
}
|
||||
|
||||
public function getSlimeSize(){
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function makeDead($cause){
|
||||
$cnt = 2 + mt_rand(0, 2);
|
||||
$s = $this->size;
|
||||
if($s > 1){
|
||||
for($i = 0; $i < $cnt; ++$i){
|
||||
$xOff = (($cnt % 2) - 0.5) * $s / 4;
|
||||
$zOff = (($cnt / 2) - 0.5) * $s / 4;
|
||||
$e = $this->server->api->entity->add($this->level, $this->class, $this->type, [
|
||||
"x" => $this->x+$xOff,
|
||||
"y"=> $this->y + 1,
|
||||
"z" => $this->z+$zOff,
|
||||
"Size" => (int) ($s / 2)
|
||||
]);
|
||||
$this->server->api->entity->spawnToAll($e);
|
||||
}
|
||||
}
|
||||
parent::makeDead($cause);
|
||||
}
|
||||
|
||||
public function setSlimeSize($i){
|
||||
$this->size = $i;
|
||||
$this->setSize(0.6*$i, 0.6*$i);
|
||||
$this->setHealth($i * $i);
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
$sd = parent::createSaveData();
|
||||
$sd["Size"] = $this->size;
|
||||
return $sd;
|
||||
}
|
||||
|
||||
public function getMetadata()
|
||||
{
|
||||
$ret = parent::getMetadata();
|
||||
$ret[16]["value"] = $this->size;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class EntityRegistry{
|
|||
self::registerEntity(Spider::class);
|
||||
self::registerEntity(Zombie::class);
|
||||
self::registerEntity(SilverFish::class);
|
||||
//self::registerEntity(Slime::class); TODO some missing property probably
|
||||
self::registerEntity(Slime::class);
|
||||
self::registerEntity(Enderman::class);
|
||||
self::registerEntity(Arrow::class);
|
||||
self::registerEntity(PrimedTNT::class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue