@@ -666,10 +666,8 @@ public function getCollisionBlocks(AxisAlignedBB $bb){
666666
667667 for ($ z = $ minZ ; $ z < $ maxZ ; ++$ z ){
668668 for ($ x = $ minX ; $ x < $ maxX ; ++$ x ){
669- if ($ this ->isChunkLoaded ($ x >> 4 , $ z >> 4 )){
670- for ($ y = $ minY - 1 ; $ y < $ maxY ; ++$ y ){
671- $ this ->getBlock (new Vector3 ($ x , $ y , $ z ))->collidesWithBB ($ bb , $ collides );
672- }
669+ for ($ y = $ minY - 1 ; $ y < $ maxY ; ++$ y ){
670+ $ this ->getBlock (new Vector3 ($ x , $ y , $ z ))->collidesWithBB ($ bb , $ collides );
673671 }
674672 }
675673 }
@@ -707,15 +705,13 @@ public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb){
707705 //TODO: optimize this loop, check collision cube boundaries
708706 for ($ z = $ minZ ; $ z < $ maxZ ; ++$ z ){
709707 for ($ x = $ minX ; $ x < $ maxX ; ++$ x ){
710- if ($ this ->isChunkLoaded ($ x >> 4 , $ z >> 4 )){
711- for ($ y = $ minY - 1 ; $ y < $ maxY ; ++$ y ){
712- $ this ->getBlock (new Vector3 ($ x , $ y , $ z ))->collidesWithBB ($ bb , $ collides );
713- }
708+ for ($ y = $ minY - 1 ; $ y < $ maxY ; ++$ y ){
709+ $ this ->getBlock (new Vector3 ($ x , $ y , $ z ))->collidesWithBB ($ bb , $ collides );
714710 }
715711 }
716712 }
717713
718- foreach ($ this ->getCollidingEntities ($ bb ->expand (0.25 , 0.25 , 0.25 ), $ entity ) as $ ent ){
714+ foreach ($ this ->getCollidingEntities ($ bb ->grow (0.25 , 0.25 , 0.25 ), $ entity ) as $ ent ){
719715 $ collides [] = clone $ ent ->boundingBox ;
720716 }
721717
@@ -1096,11 +1092,9 @@ public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null){
10961092
10971093 for ($ x = $ minX ; $ x <= $ maxX ; ++$ x ){
10981094 for ($ z = $ minZ ; $ z <= $ maxZ ; ++$ z ){
1099- if ($ this ->isChunkLoaded ($ x , $ z )){
1100- foreach ($ this ->getChunkEntities ($ x , $ z ) as $ ent ){
1101- if ($ ent !== $ entity and ($ entity === null or ($ ent ->canCollideWith ($ entity ) and $ entity ->canCollideWith ($ ent ))) and $ ent ->boundingBox ->intersectsWith ($ bb )){
1102- $ nearby [] = $ ent ;
1103- }
1095+ foreach ($ this ->getChunkEntities ($ x , $ z ) as $ ent ){
1096+ if ($ ent !== $ entity and ($ entity === null or ($ ent ->canCollideWith ($ entity ) and $ entity ->canCollideWith ($ ent ))) and $ ent ->boundingBox ->intersectsWith ($ bb )){
1097+ $ nearby [] = $ ent ;
11041098 }
11051099 }
11061100 }
@@ -1199,7 +1193,7 @@ public function getTile(Vector3 $pos){
11991193 * @return Entity[]
12001194 */
12011195 public function getChunkEntities ($ X , $ Z ){
1202- return $ this ->getChunkAt ($ X , $ Z, true ) ->getEntities ();
1196+ return ( $ chunk = $ this ->getChunkAt ($ X , $ Z)) instanceof FullChunk ? $ chunk ->getEntities () : [] ;
12031197 }
12041198
12051199 /**
@@ -1211,7 +1205,7 @@ public function getChunkEntities($X, $Z){
12111205 * @return Tile[]
12121206 */
12131207 public function getChunkTiles ($ X , $ Z ){
1214- return $ this ->getChunkAt ($ X , $ Z, true ) ->getTiles ();
1208+ return ( $ chunk = $ this ->getChunkAt ($ X , $ Z)) instanceof FullChunk ? $ chunk ->getTiles () : [] ;
12151209 }
12161210
12171211 /**
0 commit comments