mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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;
|
return true;
|
||||||
}
|
}
|
||||||
$hasUpdate = $this->entityBaseTick();
|
$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 instanceof DroppedItem){
|
||||||
if($entity->dead !== true and $entity->getPickupDelay() <= 0){
|
if($entity->dead !== true and $entity->getPickupDelay() <= 0){
|
||||||
$item = $entity->getItem();
|
$item = $entity->getItem();
|
||||||
@ -1314,23 +1314,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
$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{*/
|
|
||||||
|
|
||||||
|
$revert = false;
|
||||||
|
|
||||||
|
if($newPos->distance($this) > 100){
|
||||||
|
$this->server->getLogger()->warning($this->username." moved too quickly!");
|
||||||
|
$revert = true;
|
||||||
|
}else{
|
||||||
$dy = $newPos->y - $this->y;
|
$dy = $newPos->y - $this->y;
|
||||||
|
|
||||||
if(($this->onGround and $dy != 0) or (!$this->onGround and $dy <= 0)){
|
if(($this->onGround and $dy != 0) or (!$this->onGround and $dy <= 0)){
|
||||||
@ -1345,7 +1335,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->updateFallState($dy, $this->onGround);
|
$this->updateFallState($dy, $this->onGround);
|
||||||
|
|
||||||
$revert = false;
|
|
||||||
|
|
||||||
if($this->chunk === null or !$this->chunk->isGenerated()){
|
if($this->chunk === null or !$this->chunk->isGenerated()){
|
||||||
$chunk = $this->getLevel()->getChunkAt($newPos->x >> 4, $newPos->z >> 4);
|
$chunk = $this->getLevel()->getChunkAt($newPos->x >> 4, $newPos->z >> 4);
|
||||||
@ -1353,6 +1342,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
$revert = true;
|
$revert = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($revert or !$this->setPositionAndRotation($newPos, $packet->yaw, $packet->pitch)){
|
if($revert or !$this->setPositionAndRotation($newPos, $packet->yaw, $packet->pitch)){
|
||||||
$pk = new MovePlayerPacket();
|
$pk = new MovePlayerPacket();
|
||||||
|
@ -2011,6 +2011,7 @@ class Server{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo "Sending usage\n";
|
||||||
$plist = "";
|
$plist = "";
|
||||||
foreach($this->getPluginManager()->getPlugins() as $p){
|
foreach($this->getPluginManager()->getPlugins() as $p){
|
||||||
$d = $p->getDescription();
|
$d = $p->getDescription();
|
||||||
|
@ -158,7 +158,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
$this->justCreated = true;
|
$this->justCreated = true;
|
||||||
$this->namedtag = $nbt;
|
$this->namedtag = $nbt;
|
||||||
$this->chunk = $chunk;
|
$this->chunk = $chunk;
|
||||||
$this->setLevel($chunk->getProvider()->getLevel()); //Create a hard reference
|
$this->setLevel($chunk->getProvider()->getLevel());
|
||||||
$this->server = $chunk->getProvider()->getLevel()->getServer();
|
$this->server = $chunk->getProvider()->getLevel()->getServer();
|
||||||
|
|
||||||
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
$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->chunk->addEntity($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->scheduleUpdate();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,13 +666,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
for($z = $minZ; $z < $maxZ; ++$z){
|
for($z = $minZ; $z < $maxZ; ++$z){
|
||||||
for($x = $minX; $x < $maxX; ++$x){
|
for($x = $minX; $x < $maxX; ++$x){
|
||||||
if($this->isChunkLoaded($x >> 4, $z >> 4)){
|
|
||||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $collides;
|
return $collides;
|
||||||
}
|
}
|
||||||
@ -707,15 +705,13 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
//TODO: optimize this loop, check collision cube boundaries
|
//TODO: optimize this loop, check collision cube boundaries
|
||||||
for($z = $minZ; $z < $maxZ; ++$z){
|
for($z = $minZ; $z < $maxZ; ++$z){
|
||||||
for($x = $minX; $x < $maxX; ++$x){
|
for($x = $minX; $x < $maxX; ++$x){
|
||||||
if($this->isChunkLoaded($x >> 4, $z >> 4)){
|
|
||||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||||
$this->getBlock(new Vector3($x, $y, $z))->collidesWithBB($bb, $collides);
|
$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;
|
$collides[] = clone $ent->boundingBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1096,7 +1092,6 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
for($x = $minX; $x <= $maxX; ++$x){
|
for($x = $minX; $x <= $maxX; ++$x){
|
||||||
for($z = $minZ; $z <= $maxZ; ++$z){
|
for($z = $minZ; $z <= $maxZ; ++$z){
|
||||||
if($this->isChunkLoaded($x, $z)){
|
|
||||||
foreach($this->getChunkEntities($x, $z) as $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)){
|
if($ent !== $entity and ($entity === null or ($ent->canCollideWith($entity) and $entity->canCollideWith($ent))) and $ent->boundingBox->intersectsWith($bb)){
|
||||||
$nearby[] = $ent;
|
$nearby[] = $ent;
|
||||||
@ -1104,7 +1099,6 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $nearby;
|
return $nearby;
|
||||||
}
|
}
|
||||||
@ -1199,7 +1193,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
*/
|
*/
|
||||||
public function getChunkEntities($X, $Z){
|
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[]
|
* @return Tile[]
|
||||||
*/
|
*/
|
||||||
public function getChunkTiles($X, $Z){
|
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