mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +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,22 +1,34 @@
|
|||
<?php
|
||||
class Pig extends Animal{
|
||||
class Pig extends Animal implements Rideable{
|
||||
const TYPE = MOB_PIG;
|
||||
public $server;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
public 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->server = ServerAPI::request();
|
||||
$this->setSize($this->isBaby() ? 0.45 : 0.9, $this->isBaby() ? 0.45 : 0.9);
|
||||
$this->setName('Pig');
|
||||
$this->setName("Pig");
|
||||
$this->update();
|
||||
}
|
||||
|
||||
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 isFood($id){
|
||||
return $id === POTATO || $id === CARROT || $id === BEETROOT;
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
return $this->isBaby() ? parent::getDrops() :
|
||||
array(
|
||||
array(($this->fire > 0 ? COOKED_PORKCHOP:RAW_PORKCHOP), 0, mt_rand(0,2)),
|
||||
);
|
||||
return $this->isBaby() ? parent::getDrops() : ($this->data["Saddled"] ? [
|
||||
[($this->fire > 0 ? COOKED_PORKCHOP : RAW_PORKCHOP), 0, mt_rand(0,2)],
|
||||
[SADDLE, 0, 1]
|
||||
] : [
|
||||
[($this->fire > 0 ? COOKED_PORKCHOP : RAW_PORKCHOP), 0, mt_rand(0,2)]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue