pathfinder was changed, 102 bug fixed

This commit is contained in:
GameHerobrine 2022-10-19 18:40:19 +03:00
parent 2ea5fcd034
commit 7b66cd0250
10 changed files with 424 additions and 160 deletions

View file

@ -141,6 +141,11 @@ class Entity extends Position{
}
}
public function setVelocity($vX, $vY, $vZ){
$this->motionX = $vX;
$this->motionY = $vY;
$this->motionZ = $vZ;
}
/**
* @param mixed $e Entity instance or EID
@ -492,7 +497,7 @@ class Entity extends Position{
}
if($support === false){
$this->speedY -= $this->class === ENTITY_FALLING ? 0.08 : 1.6;
$this->speedY -= $this->class === ENTITY_FALLING ? 0.08 : 0.04; //TODO: replace with $gravity
$update = true;
}else{
//$this->speedX = 0;

View file

@ -3,6 +3,7 @@ class Pig extends Animal{
const TYPE = MOB_PIG;
public $pathFinder, $path, $server;
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
$this->pathFinder = new AStar($this); //make it before everything else as entity class constructor sends update
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic");
$this->server = ServerAPI::request();
@ -19,4 +20,12 @@ class Pig extends Animal{
array(($this->fire > 0 ? COOKED_PORKCHOP:RAW_PORKCHOP), 0, mt_rand(0,2)),
);
}
public function update(){
//$start = new MinecraftNode(round($this->x), round($this->y), round($this->z));
//$stop = $start->add(5,0,5);
//$path = $this->pathFinder->findPath($start, $stop); //allows diagonals, path should be ~5 blocks
//var_dump($path);
parent::update();
}
}