fixed nbt(which somehow worked before), enderman ai updates

This commit is contained in:
GameHerobrine 2023-02-21 20:08:50 +03:00
parent 9b5a3959c4
commit 12c9e664f0
6 changed files with 41 additions and 20 deletions

View file

@ -3,6 +3,9 @@
class Enderman extends Monster
{
const TYPE = MOB_ENDERMAN;
public $forceTeleport;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->setSize(0.6, 2.9);
parent::__construct($level, $eid, $class, $type, $data);
@ -11,6 +14,25 @@ class Enderman extends Monster
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 40, "generic");
}
public function harm($dmg, $cause = "generic", $force = false){
parent::harm($dmg, $cause, $force);
if($cause === "water"){
$this->randomTeleport();
}
}
public function randomTeleport(){
$x = $this->x + ($this->random->nextFloat() - 0.5) * 64;
$z = $this->z + ($this->random->nextFloat() - 0.5) * 64;
for($y = 0; $y < 128; ++$y){
$b = $this->level->getBlockWithoutVector($x, $y, $z);
if($b instanceof Block && !$b->isTransparent){ //TODO hitbox check
$this->x = $x;
$this->y = $y+0.5;
$this->z = $z;
}
}
}
}