mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
rewrite of interact system, bugfixes, ai tweaks
This commit is contained in:
parent
f5222be9d2
commit
ac1a1b2449
62 changed files with 649 additions and 491 deletions
|
|
@ -6,13 +6,18 @@ move methods
|
|||
abstract class Animal extends Creature implements Ageable, Breedable{
|
||||
|
||||
public $parent;
|
||||
|
||||
public $inLove; //do NOT add it into metadata, it doesnt send it to player
|
||||
public function isBaby(){
|
||||
if(!isset($this->data["IsBaby"])){
|
||||
$this->data["IsBaby"] = false;
|
||||
}
|
||||
return $this->data["IsBaby"];
|
||||
}
|
||||
|
||||
public function spawnChild(){
|
||||
//TODO
|
||||
//$c->parent = $this->eid;
|
||||
}
|
||||
public function getMetadata(){
|
||||
$d = parent::getMetadata();
|
||||
if(!isset($this->data["IsBaby"])){
|
||||
|
|
@ -21,6 +26,30 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
|||
$d[14]["value"] = $this->isBaby();
|
||||
return $d;
|
||||
}
|
||||
|
||||
public function isInLove(){
|
||||
return $this->inLove > 0;
|
||||
}
|
||||
|
||||
public function interactWith(Entity $e, $action){
|
||||
if($e->isPlayer() && $action === InteractPacket::ACTION_HOLD){
|
||||
$slot = $e->player->getHeldItem();
|
||||
if($this->isFood($slot->getID())){
|
||||
$e->player->removeItem($slot->getID(), $slot->getMetadata(), 1);
|
||||
$this->inLove = 600; //600 ticks, original mehod from mcpe
|
||||
return true;
|
||||
}
|
||||
}
|
||||
parent::interactWith($e, $action);
|
||||
}
|
||||
|
||||
public function counterUpdate(){
|
||||
parent::counterUpdate();
|
||||
if($this->isInLove()){
|
||||
--$this->inLove;
|
||||
}
|
||||
}
|
||||
|
||||
public function environmentUpdate(){
|
||||
if($this->server->api->getProperty("spawn-animals") !== true){
|
||||
$this->close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue