zombies and skeletons will burn now:

This commit is contained in:
GameHerobrine 2022-11-13 02:47:35 +03:00
parent 6dae45045b
commit cf13bd4c43
6 changed files with 54 additions and 27 deletions

View file

@ -24,7 +24,7 @@ class PocketMinecraftServer{
private function load(){
global $dolog;
$this->version = new VersionString();
/*if(defined("DEBUG") and DEBUG >= 0){
@cli_set_process_title("NostalgiaCore ".MAJOR_VERSION);

View file

@ -1285,12 +1285,8 @@ class Entity extends Position
if($harm === true){
$pk = new EntityEventPacket;
$pk->eid = $this->eid;
$pk->event = 2;
//$this->server->api->player->broadcastPacket($this->level->players, $pk);
$this->server->api->dhandle("entity.event", array(
"entity" => $this,
"event" => 2
)); // Ouch! sound
$pk->event = EntityEventPacket::ENTITY_DAMAGE;
$this->server->api->player->broadcastPacket($this->level->players, $pk);
}
if($this->player instanceof Player){
$pk = new SetHealthPacket();

View file

@ -17,6 +17,7 @@ class Chicken extends Animal{
}
public function update(){
parent::update();
if($this->timeUntilEgg-- <= 0){
$this->dropAnEgg();
$this->timeUntilEgg = mt_rand(0,6000) + 6000;

View file

@ -10,6 +10,31 @@ class Skeleton extends Monster{
$this->update();
}
public function updateBurning(){
if($this->fire > 0 or $this->server->api->time->getPhase($this->level->getTime()) != "day"){
return false;
}
for($y = $this->y; $y < 129; $y++){
$block = $this->level->getBlockWithoutVector($this->x, $y, $this->z);
if($block->isSolid){
return false;
}
}
if($block->getID() === AIR){
$this->fire = 160; //Value from 0.8.1
$this->updateMetadata();
return true;
}else{
return false;
}
}
public function update(){
$this->updateBurning();
parent::update();
}
public function getDrops(){
return [
[ARROW, 0, mt_rand(0,2)],

View file

@ -8,28 +8,31 @@ class Zombie extends Monster{
$this->setSize(0.6, 1.85);
$this->setSpeed(0.23);
$this->update();
//$this->server->schedule(20, [$this, "burnable"], null, true); //todo
}
public function burnable(){
if($this->fire > 0 or $this->server->api->time->getPhase($this->level->getTime()) == "day"){
return;
}
$y = $this->y;
for(; $y < 129; $y++){
$block = $this->level->getBlock(new Vector3($this->x, $y, $this->z));
if($block->isSolid){ //?
return false;
}
}
$block = $this->level->getBlock(new Vector3($this->x, $y, $this->z))->getID();
if($block === AIR){
$this->fire = 200;
$this->updateMetadata();
return true;
}else{
return false;
}
public function updateBurning(){
if($this->fire > 0 or $this->server->api->time->getPhase($this->level->getTime()) != "day"){
return false;
}
for($y = $this->y; $y < 129; $y++){
$block = $this->level->getBlockWithoutVector($this->x, $y, $this->z);
if($block->isSolid){
return false;
}
}
if($block->getID() === AIR){
$this->fire = 160; //Value from 0.8.1
$this->updateMetadata();
return true;
}else{
return false;
}
}
public function update(){
$this->updateBurning();
parent::update();
}
public function getDrops(){

View file

@ -4,6 +4,8 @@ class EntityEventPacket extends RakNetDataPacket{
public $eid;
public $event;
const ENTITY_DAMAGE = 2;
public function pid(){
return ProtocolInfo::ENTITY_EVENT_PACKET;
}