kamilox1234567-collab

I want to create a Minecraft plugin where the biome at coordinates (X: 0, Z: 0) is always forced to be a Plains biome, regardless of the world seed.

Kodari AI
KodariJul 4 at 2:10 pm 1
ForcedPlains
A lightweight Minecraft plugin that forces the biome at block coordinates X:0, Z:0 to always be Plains biome in every world, regardless of world seed or terrain generation. Uses chunk load events to enforce the biome at all y-levels, ensuring the origin point is always Plains terrain. Ideal for server spawns or lore-specific builds that require a fixed biome at the map origin.
kamilox1234567-collab

i put the plugin in plugins folder and then i deleted world folder adn then i started my server and on coordinates X:0 Y:0 there is no plains biom

Kodari AI
KodariJul 4 at 2:17 pm 4

Let me investigate why the biome isn’t stickingThe issue is a race condition — on a fresh world, ChunkLoadEvent fires during chunk generation, before biomes are finalized. The terrain generator overwrites your setBiome() call right after the event returns. The fix: schedule the biome change 1 tick later, after the generation pipeline finishes

Changes made:

  1. Added WorldLoadEvent handler — catches freshly created/loaded worlds and forces the origin biome immediately

  2. Delayed ChunkLoadEvent biome set by 1 tick — Bukkit.getScheduler().scheduleSyncDelayedTask(this, ..., 1L) lets the terrain generation pipeline finish before overwriting, preventing the race condition where the generator clobbers your biome

  3. Ensures chunk (0,0) is loaded in forceOriginToPlains so the biome data is actually applied to an active chunk

Delete the world folder again (or /execute ForcedPlains reload), restart the server, and the origin should now be Plains.

kamilox1234567-collab

The Plains biome is still not appearing at coordinates 0, 0. Should I add something to bukkit.yml? I know that some world generation plugins require you to register them in bukkit.yml so the server knows to use their custom world generator.

Kodari AI
KodariJul 4 at 2:27 pm 4

The issue is a race condition — even delayed tasks don’t guarantee the biome sticks because the server’s terrain generator can overwrite it. The only guaranteed approach is a custom ChunkGenerator that sets the biome during chunk generation itself.

I’ll rewrite the plugin with:

  1. PlainsGenerator — a ChunkGenerator that fills chunk (0,0) entirely with Plains biome during generation

  2. ForcedPlains — registers the generator and also does event-based fallback for chunks generated before the plugin was added

The user must add generator: ForcedPlains to bukkit.yml for each world.

You’re right. The event-based approach is unreliable because the server’s terrain generator runs after our event and overwrites the biome. A custom ChunkGenerator is the only guaranteed solution.

What to add to bukkit.yml:

YAML
worlds:
  world:
    generator: ForcedPlains

Replace world with whatever your world folder name is. This tells Bukkit to use our custom generator for that world.

Now let me rewrite the plugin to provide that generator:

Here’s the plan:

  1. Create PlainsGenerator.java — custom ChunkGenerator that sets Plains biome at origin during chunk generation (runs before terrain finishes, so it sticks)

  2. Rewrite ForcedPlains.java — override getDefaultWorldGenerator() so Bukkit knows our generator exists, plus keep the event fallback

  3. bukkit.yml entry — add generator: ForcedPlains for each world

Now rewrite ForcedPlains to expose this generator:

Now add this to your bukkit.yml (in the root of your server folder, same level as server.properties):

YAML
worlds:
  world:
    generator: ForcedPlains

Replace world with the actual world folder name if yours is different. If you have multiple worlds (world_nether, world_the_end), they get their normal generator — only the overworld uses ForcedPlains.

Steps to apply:

  1. Build the plugin jar, put it in plugins/

  2. Add the generator: ForcedPlains line to bukkit.yml

  3. Delete your world/ folder

  4. Restart the server

When the world generates, PlainsGenerator.generateChunkData() runs during terrain generation — the biome at (0,0) is set to Plains during generation, so no race condition. The event handlers are backup for any chunks that were already loaded before the generator was active.

kamilox1234567-collab

The compilation failed with this error:

code
Compilation failed with 1 error(s):

ERROR in src/main/java/com/forcedplains/PlainsGenerator.java at line 5: cannot find symbol
import org.bukkit.generator.BiomeGrid;
                           ^
  symbol: class BiomeGrid
  location: package org.bukkit.generator


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - BiomeGrid
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/com/forcedplains/PlainsGenerator.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJul 4 at 2:33 pm 4

The error is because generateSurface with WorldInfo and ChunkData uses a newer API that may not be available on your server version. Let me rewrite both files with a simpler approach that works across versions.

The error is because generateSurface with ChunkData needs a 4-arg setBiome(x, y, z, Biome) call, and the compiler may be resolving a different version of the API. Let me rewrite both files cleanly.

The error is BiomeGrid doesn’t exist in your server API version (removed in 1.20). I’ll rewrite the generator to use the modern generateSurface approach with proper 3D ChunkData.setBiome(x, y, z, Biome) calls

The generateSurface method with ChunkData is the modern API (1.17+). Since your server is 1.20+ (that’s why BiomeGrid was missing), this should compile and work.

Remember — you need to add this to your bukkit.yml:

YAML
worlds:
  world:
    generator: ForcedPlains

Replace world with your world folder name. Then delete the world/ folder and restart the server.

kamilox1234567-collab

The compilation failed with this error:

code
Compilation failed with 1 error(s):

ERROR in src/main/java/com/forcedplains/PlainsGenerator.java at line 16: cannot find symbol
                chunkData.setBiome(0, y, 0, Biome.PLAINS);
                         ^
  symbol: method setBiome(int,int,int,Biome)
  location: variable chunkData of type ChunkData


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - setBiome(int,int,int,Biome)
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/forcedplains/PlainsGenerator.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJul 4 at 2:36 pm 1

ChunkData.setBiome(int, int, int, Biome) only exists in Paper 1.20.5+, not in standard Spigot. Let me switch to a completely different approach that works across all versions: a BlockPopulator. A populator runs after terrain generation but before the chunk is finalized — it’s the right API hook for this and doesn’t need any bukkit.yml changes.

Let me rewrite with a BlockPopulator — runs after terrain generation and directly modifies the world’s biome, which avoids the API oddities of ChunkData.

Let me read the main plugin file too, then rewrite both.

The ChunkData.setBiome(x, y, z, Biome) method doesn’t exist in the Spigot version you’re running. The fix: use a BlockPopulator instead — it runs after terrain generation and uses World.setBiome(), which is available in every version.

Now I need to create the PlainsPopulator class:

Now I need to create the PlainsPopulator class that the generator references:

What changed:

  • Removed generateSurface() with ChunkData.setBiome() — that method doesn’t exist on your server version

  • Added getDefaultPopulators() which returns a BlockPopulator — this runs after terrain generation. The populator uses world.setBiome(x, y, z, Biome), a fundamental Bukkit API method that exists in every version

  • Still requires generator: ForcedPlains in bukkit.yml

Add this to bukkit.yml:

YAML
worlds:
  world:
    generator: ForcedPlains

Then delete world/ folder and restart.

kamilox1234567-collab

Just so you know, this is for a Paper server running version 1.21.1.

I'm getting this error in the console:

[16:39:21 INFO]: Preparing level "world" [16:39:21 ERROR]: Could not set generator for default world 'world': Plugin 'ForcedPlains v1.0.0' is not enabled yet (is it load:STARTUP?)

Kodari AI
KodariJul 4 at 2:46 pm 1

That error is a plugin loading order issue — the world is created before the plugin is enabled. The fix is load: STARTUP in plugin.yml.

Since this is Paper 1.21.1, let me also verify the populator code works with that API version.

Two issues:

  1. load: STARTUP needed in plugin.yml so the plugin loads before the world is created

  2. World.setBiome(int, int, int, Biome) is deprecated in Paper 1.21.1 — the correct method is setBiome(int, int, int, Holder<Biome>) which requires RegistryAccess. But since we’re running a populator during chunk generation, the better approach is to use the modern ChunkGenerator.generateSurface with ChunkData.setBiome(int, int, int, Biome) — which does exist in Paper 1.21.1. The earlier error was because your build was compiling against Spigot API, not Paper API.

Let me check what API you’re actually compiling against:

The error is the plugin loading order — the world is created before the plugin is enabled. Fix: load: STARTUP in plugin.yml.

Since you’re on Paper 1.21.1, the ChunkData.setBiome(int, int, int, Biome) method does exist in Paper API. The earlier compile error was because you were compiling against Spigot API. Let me also switch to Paper’s modern World.setBiome(int, int, int, KeyedBiome) via the biome key approach for the populator.

Now I need to update the populator to work properly on Paper 1.21.1. The BlockPopulator approach is solid — I’ll use Chunk.getWorld() to get the world reference (the WorldInfo parameter isn’t a World, but Chunk has one).

The load: STARTUP fix I just applied should resolve that error. That was the issue — the world was being created before the plugin was loaded, so getDefaultWorldGenerator() wasn’t available.

Let me also update the deprecated World.setBiome(int, int, int, Biome) call to the proper Paper 1.21.1 API to ensure it actually applies the biome:

Now update the event fallback in ForcedPlains.java too

What changed:

  1. plugin.yml — added load: STARTUP so the plugin loads before worlds are created, fixing the "Plugin is not enabled yet" error

  2. PlainsPopulator.java — uses Registry.BIOME.get(NamespacedKey.minecraft("plains")) instead of the direct Biome.PLAINS enum, which is the correct Paper 1.21.1 API for World.setBiome()

  3. ForcedPlains.java — same registry fix for the event fallback

You still need this in bukkit.yml:

YAML
worlds:
  world:
    generator: ForcedPlains

Delete world/ folder, restart the server. The load: STARTUP fix should resolve the console error.

kamilox1234567-collab

Now the world is gone, it's just a complete void.

Kodari AI
KodariJul 4 at 2:50 pm 1

The void is because our PlainsGenerator extends ChunkGenerator without providing any terrain — it generates nothing. The fix: drop the custom generator entirely. Instead, have the plugin register the BlockPopulator to worlds directly in onEnable() (no bukkit.yml changes needed).

Plan:

  1. PlainsGenerator.java — delete it (causes void)

  2. ForcedPlains.java — no longer extends ChunkGenerator. Registers the populator via World.getPopulators().add() in onEnable() + WorldInitEvent. Keeps ChunkLoadEvent fallback for existing chunks. No bukkit.yml changes needed.

  3. plugin.yml — remove the load: STARTUP (no longer needed since no custom generator)

  4. Update PlainsPopulator.java to use the proper Paper 1.21.1 setBiome API via chunk.getWorld()

Now update the populator — the populate method’s WorldInfo parameter is also a World object in Paper, but to be safe I’ll use chunk.getWorld():

Now delete the old generator file:

What changed:

  • No custom ChunkGenerator — the normal world generation runs as-is (no void)

  • Registers the BlockPopulator to worlds in onEnable() (already-loaded worlds) and via WorldInitEvent (new worlds)

  • Populator runs after terrain generation and sets chunk (0,0) to Plains biome

  • ChunkLoadEvent fallback fixes chunks that existed before the plugin was added

  • No bukkit.yml changes needed — remove the generator: line if you added it

Build, replace the jar, delete the world/ folder, and restart. You should get normal terrain with Plains at (0,0).

Kodari can make mistakes. Review important code before using.
Files
src
Code
2 125
src/main/java/com/forcedplains/ForcedPlains.java
package com.forcedplains;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class ForcedPlains extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
        getLogger().info("ForcedPlains włączony! Generowanie naturalnego wygładzania biomu Plains w promieniu 100 kratek.");
    }

    @EventHandler
    public void onChunkLoad(ChunkLoadEvent event) {
        // Modyfikujemy tylko nowo generowany teren
        if (!event.isNewChunk()) return;

        int chunkX = event.getChunk().getX();
        int chunkZ = event.getChunk().getZ();
        
        // Sprawdzamy obszar chunków w zasięgu 100 kratek (od -7 do 6)
        if (chunkX >= -7 && chunkX <= 6 && chunkZ >= -7 && chunkZ <= 6) {
            smoothTerraformToPlains(event.getChunk());
        }
    }

    private void smoothTerraformToPlains(Chunk chunk) {
        World world = chunk.getWorld();
        Biome plains = Registry.BIOME.get(NamespacedKey.minecraft("plains"));
        if (plains == null) return;

        int minY = world.getMinHeight();
        int maxY = world.getMaxHeight();
        
        int basePlainsY = 64;   // Docelowa wysokość naszej równiny
        int innerRadius = 80;   // Do tej odległości świat jest idealnie płaski
        int outerRadius = 100;  // Tutaj kończy się strefa wygładzania terenu
        
        int startX = chunk.getX() * 16;
        int startZ = chunk.getZ() * 16;

        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int globalX = startX + x;
                int globalZ = startZ + z;

                // Obliczamy dokładną odległość bloku od punktu 0,0
                double distance = Math.sqrt(globalX * globalX + globalZ * globalZ);

                // Jeśli mieścimy się w całym promieniu 100 kratek
                if (distance <= outerRadius) {
                    
                    // 1. Zmiana biomu (żeby trawa miała ładny kolor w całej strefie)
                    for (int y = minY; y < maxY; y++) {
                        world.setBiome(globalX, y, globalZ, plains);
                    }

                    // 2. Szukamy oryginalnej wysokości terenu wygenerowanej przez Minecrafta
                    int vanillaY = basePlainsY;
                    for (int y = maxY - 1; y >= minY; y--) {
                        Material type = chunk.getBlock(x, y, z).getType();
                        if (type != Material.AIR && type != Material.CAVE_AIR && type != Material.VOID_AIR) {
                            vanillaY = y;
                            break;
                        }
                    }

                    // 3. Obliczamy docelową wysokość (Wygładzanie)
                    int targetY = basePlainsY;
                    
                    if (distance > innerRadius) {
                        // Jeśli jesteśmy w strefie przejściowej (między 80 a 100 kratką),
                        // obliczamy współczynnik płynności 't' (od 0.0 do 1.0)
                        double t = (distance - innerRadius) / (outerRadius - innerRadius);
                        
                        // Łączymy wysokość równiny (64) z wysokością naturalną (vanillaY) za pomocą proporcji
                        targetY = (int) Math.round(basePlainsY * (1.0 - t) + vanillaY * t);
                    }

                    // 4. Fizyczne formowanie bloków według obliczonej wysokości targetY
                    
                    // Czyszczenie wszystkiego nad nowym poziomem gruntu (usuwanie uciętych gór/drzew)
                    for (int y = maxY - 1; y > targetY; y--) {
                        Block block = chunk.getBlock(x, y, z);
                        if (block.getType() != Material.AIR) {
                            block.setType(Material.AIR, false);
                        }
                    }

                    // Tworzenie nowej warstwy powierzchniowej
                    chunk.getBlock(x, targetY, z).setType(Material.GRASS_BLOCK, false);
                    chunk.getBlock(x, targetY - 1, z).setType(Material.DIRT, false);
                    chunk.getBlock(x, targetY - 2, z).setType(Material.DIRT, false);
                    chunk.getBlock(x, targetY - 3, z).setType(Material.DIRT, false);

                    // Wypełnianie ewentualnych pustek pod spodem kamieniem (np. jeśli pod spodem był głęboki ocean)
                    for (int y = targetY - 4; y >= targetY - 15; y--) {
                        Block block = chunk.getBlock(x, y, z);
                        if (block.getType().isAir() || block.isLiquid()) {
                            block.setType(Material.STONE, false);
                        }
                    }
                }
            }
        }
    }
}