mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
entities have autojump now
This commit is contained in:
parent
9f5304bdad
commit
1aef739065
3 changed files with 20 additions and 4 deletions
|
|
@ -160,9 +160,9 @@ class Player{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->server->api->entity->getAll($this->level) as $e){
|
foreach($this->level->entities as $e){
|
||||||
if($e !== $this->entity){
|
if($e !== $this->entity){
|
||||||
if($e->player instanceof Player){
|
if($e->isPlayer()){
|
||||||
$pk = new MoveEntityPacket_PosRot;
|
$pk = new MoveEntityPacket_PosRot;
|
||||||
$pk->eid = $this->entity->eid;
|
$pk->eid = $this->entity->eid;
|
||||||
$pk->x = -256;
|
$pk->x = -256;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class Entity extends Position
|
||||||
public $radius;
|
public $radius;
|
||||||
public $inAction = false;
|
public $inAction = false;
|
||||||
public $hasKnockback;
|
public $hasKnockback;
|
||||||
|
public $hasJumped;
|
||||||
public $onGround, $inWater;
|
public $onGround, $inWater;
|
||||||
|
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ class MobController
|
||||||
* @var Entity
|
* @var Entity
|
||||||
*/
|
*/
|
||||||
public $entity;
|
public $entity;
|
||||||
|
|
||||||
public function __construct($e){
|
public function __construct($e){
|
||||||
$this->entity = $e;
|
$this->entity = $e;
|
||||||
}
|
}
|
||||||
|
|
@ -19,6 +18,23 @@ class MobController
|
||||||
$ox = ($x > 0 ? 1 : ($x < 0 ? -1 : 0));
|
$ox = ($x > 0 ? 1 : ($x < 0 ? -1 : 0));
|
||||||
$oy = ($y > 0 ? 1 : ($y < 0 ? -1 : 0));
|
$oy = ($y > 0 ? 1 : ($y < 0 ? -1 : 0));
|
||||||
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
|
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
|
||||||
|
$xf = $this->entity->x + ($this->entity->getSpeedModifer() * $ox * $this->entity->getSpeed());
|
||||||
|
$zf = $this->entity->z + ($this->entity->getSpeedModifer() * $oz * $this->entity->getSpeed());
|
||||||
|
$bs = [ //TODO simplify(somehow)
|
||||||
|
$this->entity->level->getBlockWithoutVector(ceil($xf), $this->entity->y, ceil($zf)),
|
||||||
|
$this->entity->level->getBlockWithoutVector(ceil($xf), $this->entity->y, $zf),
|
||||||
|
$this->entity->level->getBlockWithoutVector($xf, $this->entity->y, ceil($zf)),
|
||||||
|
$this->entity->level->getBlockWithoutVector($xf, $this->entity->y, $zf)
|
||||||
|
];
|
||||||
|
foreach($bs as $b){
|
||||||
|
if($b->isSolid){
|
||||||
|
if(!$this->entity->level->getBlock($b->getSide(1))->isSolid){
|
||||||
|
$oy = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
||||||
$this->faceEntity($this->entity->add($ox, $oy, $oz));
|
$this->faceEntity($this->entity->add($ox, $oy, $oz));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue