mojira.dev
MC-138717

/locate command does not locate certain structures in Superflat

The bug

The locate command always returns "Could not find that structure nearby" even when the structure is right below you.

Affected structures

  • Ocean monuments

  • Ocean ruins

  • Shipwrecks

  • Igloos

  • Desert pyramids

  • Jungle temples

  • Witch huts

How to reproduce

  1. Enter singleplayer

  2. Create superflat world with preset:

    minecraft:bedrock,38*minecraft:stone,5*minecraft:dirt,5*minecraft:sand,110*minecraft:water;minecraft:deep_ocean;oceanmonument,decoration,stronghold,mineshaft,dungeon
  3. Enter /locate Monument

Code analysis

Code analysis by @unknown can be found in this comment.

Attachments

Comments 8

Can confirm, also occurs with Ocean Ruins and Shipwrecks (tested using the Water World superflat preset).

It also affect desert pyramid

Confirmed in 20w14a with the water world preset, tested shipwrecks, ocean ruins, monuments, all three of which generates in the water world superflat preset.
Or with this generator config (water world superflat preset) in "server.properties"'s "generator-options" field:

{"structures":{"biome_1":{},"oceanmonument":{}},"layers":[{"block":"minecraft:bedrock","height":1},{"block":"minecraft:stone","height":5},{"block":"minecraft:dirt","height":5},{"block":"minecraft:sand","height":5},{"block":"minecraft:water","height":90}],"biome":"minecraft:deep_ocean"}

After another peek, I found the cause of the problem and has a solution for it.

This is the current code for locating structure in the superflat chunk generator (fabricmc yarn mappings):

public BlockPos locateStructure(ServerWorld serverWorld, String id, BlockPos center, int radius, boolean skipExistingChunks) {
   return !((FlatChunkGeneratorConfig)this.config).getStructures().keySet().contains(id.toLowerCase(Locale.ROOT)) ? null : super.locateStructure(serverWorld, id, center, radius, skipExistingChunks);
}

The problem is that some structure config keys, such as "oceanmonument" and "biome_1" as shown in the last comment's generator settings for server.properties, are not a direct mapping to structure names.

A suggested revision is as below:

public BlockPos locateStructure(ServerWorld serverWorld, String id, BlockPos center, int radius, boolean skipExistingChunks) {
   return !this.biome.hasStructureFeature(Feature.STRUCTURES.get(id.toLowerCase(Locale.ROOT))) ? null : super.locateStructure(serverWorld, id, center, radius, skipExistingChunks);
}

This way, we are querying the biome of the superflat world whether such a feature exists (the biome already has all the processed structure information), which is more reliable.

I have applied this patch as a mod, and it apparently works well (see the screenshot of it working), while other unintended features that may have been specified by "biome_1", such as "Swamp_Hut", still correctly reports "Could not find that structure nearby".

Confirmed in 20w15a.

Confirmed in 20w16a.

Can confirm in 21w05b.

Daniel Tavares

(Unassigned)

Confirmed

Normal

Commands, Structures

/locate, monument, ocean_ruin, shipwreck

Minecraft 1.13.2, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, ..., Minecraft 19w14b, 1.15.2, 20w14a, 20w15a, 20w16a

22w06a

Retrieved