mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Fixed AxisAlignedBB infinite expansion
This commit is contained in:
parent
9fb46d8fe8
commit
e2986992c7
@ -1065,7 +1065,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return true;
|
||||
}
|
||||
$hasUpdate = $this->entityBaseTick();
|
||||
foreach($this->getLevel()->getNearbyEntities($this->boundingBox->expand(1, 1, 1), $this) as $entity){
|
||||
foreach($this->getLevel()->getNearbyEntities($this->boundingBox->grow(1, 1, 1), $this) as $entity){
|
||||
if($entity instanceof DroppedItem){
|
||||
if($entity->dead !== true and $entity->getPickupDelay() <= 0){
|
||||
$item = $entity->getItem();
|
||||
@ -1314,43 +1314,33 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
/*if($this->forceMovement instanceof Vector3){
|
||||
if($this->forceMovement->distance($newPos) <= 0.7){
|
||||
$this->forceMovement = false;
|
||||
}else{
|
||||
$this->setPosition($this->forceMovement);
|
||||
}
|
||||
}*/
|
||||
/*$speed = $this->entity->getSpeedMeasure();
|
||||
if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){
|
||||
if($this->lastCorrect instanceof Vector3){
|
||||
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
|
||||
}
|
||||
if($this->blocked !== true){
|
||||
$this->server->getLogger()->warning($this->username." moved too quickly!");
|
||||
}
|
||||
}else{*/
|
||||
|
||||
$dy = $newPos->y - $this->y;
|
||||
|
||||
if(($this->onGround and $dy != 0) or (!$this->onGround and $dy <= 0)){
|
||||
if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){
|
||||
$isColliding = true;
|
||||
}else{
|
||||
$isColliding = false;
|
||||
}
|
||||
|
||||
$this->onGround = ($dy <= 0 and $isColliding);
|
||||
}
|
||||
|
||||
$this->updateFallState($dy, $this->onGround);
|
||||
|
||||
$revert = false;
|
||||
|
||||
if($this->chunk === null or !$this->chunk->isGenerated()){
|
||||
$chunk = $this->getLevel()->getChunkAt($newPos->x >> 4, $newPos->z >> 4);
|
||||
if(!($chunk instanceof FullChunk) or !$chunk->isGenerated()){
|
||||
$revert = true;
|
||||
if($newPos->distance($this) > 100){
|
||||
$this->server->getLogger()->warning($this->username." moved too quickly!");
|
||||
$revert = true;
|
||||
}else{
|
||||
$dy = $newPos->y - $this->y;
|
||||
|
||||
if(($this->onGround and $dy != 0) or (!$this->onGround and $dy <= 0)){
|
||||
if(count($this->getLevel()->getCollisionBlocks($this->boundingBox->getOffsetBoundingBox(0, $dy - 0.1, 0))) > 0){
|
||||
$isColliding = true;
|
||||
}else{
|
||||
$isColliding = false;
|
||||
}
|
||||
|
||||
$this->onGround = ($dy <= 0 and $isColliding);
|
||||
}
|
||||
|
||||
$this->updateFallState($dy, $this->onGround);
|
||||
|
||||
|
||||
if($this->chunk === null or !$this->chunk->isGenerated()){
|
||||
$chunk = $this->getLevel()->getChunkAt($newPos->x >> 4, $newPos->z >> 4);
|
||||
if(!($chunk instanceof FullChunk) or !$chunk->isGenerated()){
|
||||
$revert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2011,6 +2011,7 @@ class Server{
|
||||
return;
|
||||
}
|
||||
}
|
||||
echo "Sending usage\n";
|
||||
$plist = "";
|
||||
foreach($this->getPluginManager()->getPlugins() as $p){
|
||||
$d = $p->getDescription();
|
||||
|
@ -158,7 +158,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
$this->justCreated = true;
|
||||
$this->namedtag = $nbt;
|
||||
$this->chunk = $chunk;
|
||||
$this->setLevel($chunk->getProvider()->getLevel()); //Create a hard reference
|
||||
$this->setLevel($chunk->getProvider()->getLevel());
|
||||
$this->server = $chunk->getProvider()->getLevel()->getServer();
|
||||
|
||||
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
@ -1014,8 +1014,6 @@ abstract class Entity extends Position implements Metadatable{
|
||||
$this->chunk->addEntity($this);
|
||||
}
|
||||
|
||||
$this->scheduleUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -666,10 +666,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
for($z = $minZ; $z < $maxZ; ++$z){
|
||||
for($x = $minX; $x < $maxX; ++$x){
|
||||
if($this->isChunkLoaded($x >> 4, $z >> 4)){
|
||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
||||
}
|
||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -707,15 +705,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
//TODO: optimize this loop, check collision cube boundaries
|
||||
for($z = $minZ; $z < $maxZ; ++$z){
|
||||
for($x = $minX; $x < $maxX; ++$x){
|
||||
if($this->isChunkLoaded($x >> 4, $z >> 4)){
|
||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
||||
}
|
||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->getCollidingEntities($bb->expand(0.25, 0.25, 0.25), $entity) as $ent){
|
||||
foreach($this->getCollidingEntities($bb->grow(0.25, 0.25, 0.25), $entity) as $ent){
|
||||
$collides[] = clone $ent->boundingBox;
|
||||
}
|
||||
|
||||
@ -1096,11 +1092,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
for($x = $minX; $x <= $maxX; ++$x){
|
||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||
if($this->isChunkLoaded($x, $z)){
|
||||
foreach($this->getChunkEntities($x, $z) as $ent){
|
||||
if($ent !== $entity and ($entity === null or ($ent->canCollideWith($entity) and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
||||
$nearby[] = $ent;
|
||||
}
|
||||
foreach($this->getChunkEntities($x, $z) as $ent){
|
||||
if($ent !== $entity and ($entity === null or ($ent->canCollideWith($entity) and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
||||
$nearby[] = $ent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1199,7 +1193,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return Entity[]
|
||||
*/
|
||||
public function getChunkEntities($X, $Z){
|
||||
return $this->getChunkAt($X, $Z, true)->getEntities();
|
||||
return ($chunk = $this->getChunkAt($X, $Z)) instanceof FullChunk ? $chunk->getEntities() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1211,7 +1205,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
* @return Tile[]
|
||||
*/
|
||||
public function getChunkTiles($X, $Z){
|
||||
return $this->getChunkAt($X, $Z, true)->getTiles();
|
||||
return ($chunk = $this->getChunkAt($X, $Z)) instanceof FullChunk ? $chunk->getTiles() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user