File tree 1 file changed +15
-6
lines changed
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -902,14 +902,23 @@ class ABMHandler
902
902
if (!i->required_neighbors .empty ())
903
903
{
904
904
v3s16 p1;
905
- for (p1.X = p .X -1 ; p1.X <= p .X +1 ; p1.X ++)
906
- for (p1.Y = p .Y -1 ; p1.Y <= p .Y +1 ; p1.Y ++)
907
- for (p1.Z = p .Z -1 ; p1.Z <= p .Z +1 ; p1.Z ++)
905
+ for (p1.X = p0 .X -1 ; p1.X <= p0 .X +1 ; p1.X ++)
906
+ for (p1.Y = p0 .Y -1 ; p1.Y <= p0 .Y +1 ; p1.Y ++)
907
+ for (p1.Z = p0 .Z -1 ; p1.Z <= p0 .Z +1 ; p1.Z ++)
908
908
{
909
- if (p1 == p )
909
+ if (p1 == p0 )
910
910
continue ;
911
- MapNode n = map->getNodeNoEx (p1);
912
- content_t c = n.getContent ();
911
+ content_t c;
912
+ if (block->isValidPosition (p1)) {
913
+ // if the neighbor is found on the same map block
914
+ // get it straight from there
915
+ const MapNode &n = block->getNodeUnsafe (p1);
916
+ c = n.getContent ();
917
+ } else {
918
+ // otherwise consult the map
919
+ MapNode n = map->getNodeNoEx (p1 + block->getPosRelative ());
920
+ c = n.getContent ();
921
+ }
913
922
std::set<content_t >::const_iterator k;
914
923
k = i->required_neighbors .find (c);
915
924
if (k != i->required_neighbors .end ()){
You can’t perform that action at this time.
0 commit comments