ChunkGenerator#shouldGenerateStructures() doesn't fully work when #shouldGenerateDecorations() is false
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
I expect structures to generate when I return true for shouldGenerateStructures()
Observed/Actual behavior
I noticed when doing some generator stuff, that structures aren't placed into the world when ChunkGenerator#shouldGenerateDecorations() return false.
I did some digging and came to the realization why this happens.
Structures are broken up into 2 parts:
-
StructureStarts = This is an early stage in the generation steps. Minecraft decides which types of structures will go where.
When usingshouldGenerateStructuresreturned as true... this stage decides it will place a structure there. -
StructurePlacements = Later on in the chunk generation steps, in the same stage that decorations (features) are placed, the structure pieces are also placed.
After seeing this in the code I realized ifshouldGenerateDecorationsreturns false (thus preventing features from being placed), the structure piece placements are also skipped.
When this happens, the game will assume a structure is placed in a specific spot, this can be seen using the locate command (see steps below), where it'll find a structure, but nothing actually got placed.
Steps/models to reproduce
Simple code to replicate:
public void testGenerator() {
WorldCreator worldCreator = new WorldCreator("world_test_for_paper");
worldCreator.generator(new ChunkGenerator() {
@Override
public boolean shouldGenerateNoise() {
return true; // Vanilla noise
}
@Override
public boolean shouldGenerateSurface() {
return true; // Vanilla surface
}
@Override
public boolean shouldGenerateStructures() {
return true; // Yes we want structures
}
@Override
public boolean shouldGenerateDecorations() {
return false; // No we dont want your trees
}
@Override
public Location getFixedSpawnLocation(@NotNull World world, @NotNull Random random) {
return new Location(world,1,1,1); // Speed up the process
}
});
World testWorld = worldCreator.createWorld();
}
- start up server
- join server and teleport to new world
- run command
/locate structure minecraft:village_plains - Once the game finds the village, click the TP thing to TP to it.
- Behold, no village.
Plugin and Datapack List
[14:29:19 INFO]: ℹ Server Plugins (1):
[14:29:19 INFO]: Paper Plugins (1):
[14:29:19 INFO]: - CorePlugin #(my plugin for testing)
Paper version
Currently using the 1.21.5 update branch:
[14:24:04 INFO]: This server is running Paper version 1.21.5-DEV-update/1.21.5@ce91a8c (1970-01-01T00:00:00Z) (Implementing API version 1.21.5-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.5-DEV-b6d70a9 (MC: 1.21.5)
I believe this would also happen on previous versions.
I'm pretty sure this happened to me in 1.21.4 and just forgot to report it.
Other
I'm open to doing a PR for this.
Looking thru the code I feel like this could potentially be a simple fix.
I wanted to wait til after 1.21.5 was released, as I'm sure you guys have too much on your plate as it is.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ChunkGenerator#shouldGenerateStructures() and ChunkGenerator#shouldGenerateDecorations(), then trace the generation stages described in the report. Reproduce the issue with the supplied WorldCreator generator, use /locate structure minecraft:village_plains, and verify that structure pieces are placed even when decorations are disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100