diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 512c0e779..28ca062c8 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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; + } } } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 315dce5e4..348f0480d 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2011,6 +2011,7 @@ class Server{ return; } } + echo "Sending usage\n"; $plist = ""; foreach($this->getPluginManager()->getPlugins() as $p){ $d = $p->getDescription(); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 9431fbbd6..dacdedba4 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -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; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index b52e4d64b..6f20f526a 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -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() : []; } /**