mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
micro entity optimizations, fixed getEyeHeight, rewrote inWall, static hitboxes
This commit is contained in:
parent
0469550ca2
commit
2927fe1094
9 changed files with 54 additions and 94 deletions
|
|
@ -76,7 +76,7 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){
|
||||
if($this->level->entityList[$entid] instanceof Entity){
|
||||
if($bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){
|
||||
$this->applyCollision($this->level->entityList[$entid]);
|
||||
$this->level->entityList[$entid]->applyCollision($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,27 +84,6 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
}
|
||||
|
||||
public function applyCollision(Entity $collided){
|
||||
if(!($this->isPlayer() && $collided->isPlayer()) && $this->eid != $collided->eid){
|
||||
$diffX = $collided->x - $this->x;
|
||||
$diffZ = $collided->z - $this->z;
|
||||
$maxDiff = max(abs($diffX), abs($diffZ));
|
||||
if($maxDiff > 0.01){
|
||||
$sqrtMax = sqrt($maxDiff);
|
||||
$diffX /= $sqrtMax;
|
||||
$diffZ /= $sqrtMax;
|
||||
|
||||
$col = (($v = 1 / $sqrtMax) > 1 ? 1 : $v);
|
||||
$diffX *= $col;
|
||||
$diffZ *= $col;
|
||||
$diffX *= 0.05;
|
||||
$diffZ *= 0.05;
|
||||
$this->addVelocity(-$diffX, 0, -$diffZ);
|
||||
$collided->addVelocity($diffX, 0, $diffZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function update($now){
|
||||
if(self::$despawnMobs && ++$this->ticksExisted > self::$despawnTimer){
|
||||
$this->close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue