rutgerkok / WorldGeneratorApi

Minecraft Spigot plugin that enables other plugins to customize world generation
MIT License
95 stars 9 forks source link

Strange not edited area #13

Closed romsto closed 4 years ago

romsto commented 4 years ago

Description While editing the BiomeGenerator in the WorldGeneratorInitEvent, the generated world contains few chunks not edited arround the spawn.

X X X X X X X X X X X X S X X X X X X X X X X X X

X represents not edited chunks (I set another biome to spawn but this biome still spawns, also works when you remove all decorations: in these chunks the decorations isn't remove) S represents the Spawn chunk (not edited too)

To Reproduce Steps to reproduce the behavior:

  1. In WorldGeneratorInitEvent
  2. event.getWorldGenerator().getWorldDecorator().withoutAllDefaultDecorations();
  3. Generate a new map

Screenshots

https://prnt.sc/tfwnlj https://prnt.sc/tfwpyt https://prnt.sc/tfwn1g in red the not edited generated chunks, and blue the well generated chunks

MichaelHilus commented 4 years ago

I saw this too with the latest versions of WorldGeneratorAPI and PaperMC.

romsto commented 4 years ago

I haven't tried with Spigot yet. Going to check with the Paper community and maybe PR.

sepiatonal commented 4 years ago

I'm having this issue as well. Did you fix it for yourself?

rutgerkok commented 4 years ago

Having this issue as well. It happens only when a plugin uses WorldGeneratorApi through the WorldGeneratorInitEvent, and no plugin on the server is using WorldGeneratorApi through the getDefaultWorldGenerator method.

afbeelding

If the getDefaultWorldGenerator method is not used, WorldGeneratorApi is activated through Bukkit's WorldInitEvent method. It seems that this method is now called after the first few chunks have been generated. I will need to find some workaround...

rutgerkok commented 4 years ago

Happens on Spigot too... I'll try to see if I can come up with something in the Bukkit API that breaks because the WorldInitEvent is fired too late. If yes, then I can submit a valid bug report to them.

rutgerkok commented 4 years ago

This is going to be very hard to get fixed. Basically, the WorldInitEvent is fired after the first chunks start loading, but before the first chunks finish loading.

This problem does not happen when using Spigot's world generator api. This is because BlockPopulators work on fully loaded chunks. Here's an example that does work correctly:

    @EventHandler
    public void onWorldInit(WorldInitEvent event) {
        event.getWorld().getPopulators().add(new BlockPopulator() {

            @Override
            public void populate(World world, Random random, Chunk chunk) {
                getLogger().info("Generating for chunk " + chunk);
                for (int x = 1; x < 15; x++) {
                    for (int z = 1; z < 15; z++) {
                        chunk.getBlock(x, 100, z).setType(Material.RED_STAINED_GLASS);
                    }
                }
            }
        });
    }

A Spigot bug report exists: SPIGOT-5569, but because it's a rather theoretical issue when only using the Bukkit API, and it will cause other issues when fixed, there isn't really an interest to fix it.

So I need to find another place to call the WorldGeneratorInitEvent from. Suggestions are welcome.

rutgerkok commented 4 years ago

Should be fixed in build 12 at https://ci.codemc.io/job/rutgerkok/job/WorldGeneratorApi/ . WorldGeneratorApi now injects itself into the CraftServer.worlds map, so that it can catch early-on when a new world is loaded.