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
Enter singleplayer
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
Enter
/locate Monument
Code analysis
Code analysis by @unknown can be found in this comment.
Attachments
Comments 8
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".
Can confirm, also occurs with Ocean Ruins and Shipwrecks (tested using the Water World superflat preset).