mojira.dev
MC-252680

Feature placement crash with very long shipwrecks: java.lang.RuntimeException: We are asking a region for a chunk out of bound

Did some googling on this one, saw that people way back in 1.14.1 had the same issue. Game crashes when a player enters certain chunks, so far just 48 18. Running a multiplayer server with just the 4 of us right now.

One crash report is from vanilla, one from Forge and one from Fabric. I tried numerous types to see if it would help the crash but had no luck. Long story short, the crash occurs in unmodified minecraft and modified minecraft.

Attachments

Comments 3

Does this issue still occur when add those data packs are disabled? (This report should remain valid anyways, as the game shouldn't crash)

Please attached used datapacks.

Code analysis
Yarn 1.19.1

In Minecraft, there are two kinds of worlds. The real world which holds all chunks, and the generation-stage chunk region holding certain amount of chunks. This exception is thrown by a chunk region that was {{getChunk}}ed a chunk it does not manage.

This is caused by a shipwreck: ShipwreckGenerator.Piece#generate method is on the crash log.

public void generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox chunkBox, ChunkPos chunkPos, BlockPos pivot) {
      int i = world.getTopY();
      int j = 0;
      Vec3i lv = this.template.getSize(); // the dimension of the shipwreck structure, can be overridden by data packs
      Heightmap.Type lv2 = this.grounded ? Heightmap.Type.WORLD_SURFACE_WG : Heightmap.Type.OCEAN_FLOOR_WG;
      int k = lv.getX() * lv.getZ();
      if (k == 0) {
        j = world.getTopY(lv2, this.pos.getX(), this.pos.getZ());
      } else {
        BlockPos lv3 = this.pos.add(lv.getX() - 1, 0, lv.getZ() - 1); // this.pos is the start of the chunk (see ShipwreckStructure)
        for (BlockPos lv4 : BlockPos.iterate(this.pos, lv3)) {
          int l = world.getTopY(lv2, lv4.getX(), lv4.getZ()); // Chunk query
          j += l;
          i = Math.min(i, l);
        } 
        j /= k;
      }
   /* omitted */
}

As seen above, if a shipwreck's structure NBT file was modified by data packs, the position can overflow the chunk. This causes getTopY to be called on potentially out-of-region chunk, which this crash shows. The fix would be to clamp the width and height of the structure for heightmap querying.

Zoatroid

(Unassigned)

Plausible

Platform

Normal

Crash, Data Packs

1.19, 1.19.1

Retrieved