mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
Big update about mobs
Removes some array() and some another minor changes.
Cow now drop 0-3 meat.
Pigs can be saddled, and if pig saddled it will drop them.
Creeper can be blown up with flint and steel ("power" => 3).
You can ride on pig (some buggy).
Now Saddle maxStackSize = 1.
Using shears and flint&steel on sheep and creeper they will break.
Saddled will save with closing the server.
This commit is contained in:
parent
2a52e6c69c
commit
f5222be9d2
17 changed files with 221 additions and 180 deletions
|
|
@ -1,19 +1,41 @@
|
|||
<?php
|
||||
class Creeper extends Monster{
|
||||
const TYPE = MOB_CREEPER;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:16, "generic");
|
||||
$this->setName('Creeper');
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 16, "generic");
|
||||
$this->setName("Creeper");
|
||||
$this->setSize(0.6, 1.7);
|
||||
$this->update();
|
||||
|
||||
if($this->data["Saddled"] === 1){
|
||||
$this->server->schedule(30, [$this, "updateFuse"], []); //unknown ticks
|
||||
}
|
||||
}
|
||||
|
||||
public function getMetadata(){
|
||||
$d = parent::getMetadata();
|
||||
if(!isset($this->data["Saddled"])){
|
||||
$this->data["Saddled"] = 0;
|
||||
}
|
||||
$d[16]["value"] = ((int)$this->data["Saddled"]);
|
||||
return $d;
|
||||
}
|
||||
|
||||
public function updateFuse(){
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
if($this->type === MOB_CREEPER){
|
||||
$this->updateMetadata();
|
||||
$this->close();
|
||||
$explosion = new Explosion($this, 3);
|
||||
$explosion->explode();
|
||||
}
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
return array(
|
||||
array(GUNPOWDER, 0, mt_rand(0,2)),
|
||||
);
|
||||
return $this->data["Saddled"] === 1 ? parent::getDrops() : [
|
||||
[GUNPOWDER, 0, mt_rand(0,2)]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
class PigZombie extends Monster{
|
||||
const TYPE = MOB_PIGMAN;
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
||||
$this->setSize(0.3, 1.95);
|
||||
$this->setName('Pigman');
|
||||
$this->setName("Pigman");
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
return array(
|
||||
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
|
||||
array(GOLD_INGOT, 0, mt_rand(0,1)),
|
||||
);
|
||||
return [
|
||||
[COOKED_PORKCHOP, 0, mt_rand(0,2)],
|
||||
[GOLD_INGOT, 0, mt_rand(0,1)]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,18 @@
|
|||
<?php
|
||||
class Skeleton extends Monster{
|
||||
const TYPE = MOB_SKELETON;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
|
||||
$this->setName('Skeleton');
|
||||
$this->setName("Skeleton");
|
||||
$this->setSize(0.6, 1.99);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
return array(
|
||||
array(ARROW, 0, mt_rand(0,2)),
|
||||
array(BONE, 0, mt_rand(0,2)),
|
||||
);
|
||||
return [
|
||||
[ARROW, 0, mt_rand(0,2)],
|
||||
[BONE, 0, mt_rand(0,2)]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
<?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"] : 8, "generic");
|
||||
$this->setName('Spider');
|
||||
$this->setName("Spider");
|
||||
$this->setSize(1.4, 0.9);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
return array(
|
||||
array(STRING, 0, mt_rand(0,2)),
|
||||
);
|
||||
return [
|
||||
[STRING, 0, mt_rand(0,2)]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
<?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"] : 12, "generic");
|
||||
$this->setName('Zombie');
|
||||
$this->setName("Zombie");
|
||||
$this->setSize(0.6, 1.85);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
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)),
|
||||
);
|
||||
return [
|
||||
[CARROT, 0, Utils::chance(0.83) ? 1 : 0],
|
||||
[POTATO, 0, Utils::chance(0.83) ? 1 : 0],
|
||||
[FEATHER, 0, mt_rand(0,2)]
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue