Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-136886

Finding Nearby Features loads every generated chunk in radius

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • None
    • Minecraft 1.13.1, 1.15.2, 20w45a, 20w46a, 20w48a
    • None
    • Community Consensus
    • (Unassigned)

      [Developer Report]

      The code that finds the nearest feature in a radius around a position, used by locate, dolphins and treasure maps, is using the wrong method to look up chunks, resulting in every chunk that has been generated to be loaded by the command, crashing servers.

      The code never did this pre 1.13, so clearly this was a bug.

       

      I traced it down that the wrong getChunk method was used, which forwards to the correct one with the load boolean always set to true

       

      Switching it like so still finds structures correctly:

       

       

      private StructureStart a(GeneratorAccess generatoraccess, ChunkGenerator<? extends GeneratorSettings> chunkgenerator, SeededRandom seededrandom, long i) {
              if (!chunkgenerator.getWorldChunkManager().a(this)) {
                  return StructureGenerator.a;
              } else {
                  Long2ObjectMap long2objectmap = chunkgenerator.getStructureStartCache(this);
                  StructureStart structurestart = (StructureStart) long2objectmap.get(i);
      
                  if (structurestart != null) {
                      return structurestart;
                  } else {
                      ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i);
                      IChunkAccess ichunkaccess = generatoraccess.getChunkProvider().getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, false, false); // Paper - don't load chunks
      
                      if (ichunkaccess != null) {
                          structurestart = ichunkaccess.a(this.a());
                          if (structurestart != null) {
                              long2objectmap.put(i, structurestart);
                              return structurestart;
                          }
                      }
      
                      if (this.a(chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z)) {
                          StructureStart structurestart1 = this.a(generatoraccess, chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z);
      
                          structurestart = structurestart1.b() ? structurestart1 : StructureGenerator.a;
                      } else {
                          structurestart = StructureGenerator.a;
                      }
      
                      if (structurestart.b()) {
                          generatoraccess.getChunkProvider().a(chunkcoordintpair.x, chunkcoordintpair.z, true).a(this.a(), structurestart);
                      }
      
                      long2objectmap.put(i, structurestart);
                      return structurestart;
                  }
              }
          }
      

       

            Unassigned Unassigned
            aikar Aikar
            Votes:
            12 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: