mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
fixed nbt(which somehow worked before), enderman ai updates
This commit is contained in:
parent
9b5a3959c4
commit
12c9e664f0
6 changed files with 41 additions and 20 deletions
|
|
@ -431,7 +431,7 @@ class Entity extends Position
|
|||
$this->fire = 0;
|
||||
$this->updateMetadata();
|
||||
}
|
||||
if ($this->air <= 0 && ! $waterDone) {
|
||||
if (($this->air <= 0 && ! $waterDone) || $this->type === MOB_ENDERMAN) { //TODO check is correct
|
||||
$this->harm(2, "water");
|
||||
$hasUpdate = true;
|
||||
$waterDone = true;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue