Biome arguments
In Minecraft 1.16, they added the ability to refer to in-game biomes. The CommandAPI implements this using the BiomeArgument
. As expected, this returns Bukkit's Biome
enum when used.
Example - Setting the biome of a chunk
Say you want to set the biome of the current chunk that a player is in. We can do this using the World.setBiome(x, y, z, biome)
method for a given world. We will use this command syntax to set the biome of our current chunk:
/setbiome <biome>
And we can set the biome of the current chunk as expected:
new CommandAPICommand("setbiome")
.withArguments(new BiomeArgument("biome"))
.executesPlayer((player, args) -> {
Biome biome = (Biome) args[0];
Chunk chunk = player.getLocation().getChunk();
player.getWorld().setBiome(chunk.getX(), player.getLocation().getBlockY(), chunk.getZ(), biome);
})
.register();