Skip to content

Commit

Permalink
Accept other Biome than THE_VOID & other world spawn coordinates.
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrolienF committed Dec 4, 2024
1 parent d351a42 commit 7f5cccf
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ worlds:
```
If your world is not called `world`, replace `world` by your world name. You can set VoidWorldGenerator as generator for more than 1 world.
```yml
worlds:
myCustomWorld1:
generator: VoidWorldGenerator
a2ndCustomWorld:
generator: VoidWorldGenerator
```

You can set the biome to use for empty chunks & the default spawn coordinates in the plugin config in `plugins/VoidWorldGenerator/config.yml`.

## Statistics
[![bStats Graph Data](https://bstats.org/signatures/bukkit/VoidWorldGenerator.svg)](https://bstats.org/plugin/bukkit/VoidWorldGenerator/20171)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group="fr.formiko.voidworldgenerator"
version="1.1.5"
version="1.2.0"
description="Generate empty world."

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.annotation.Nullable;
import org.bstats.bukkit.Metrics;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BiomeProvider;
Expand All @@ -13,13 +14,31 @@
import org.bukkit.generator.WorldInfo;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;

/**
* Generate empty chunks with biome THE_VOID.
* Generate empty chunks with the config biome.
*/
public class VoidWorldGeneratorPlugin extends JavaPlugin {
private static Biome EMPTY_CHUNK_BIOME;
@Override
public void onEnable() { new Metrics(this, 20171); }
public void onEnable() {
new Metrics(this, 20171);
saveDefaultConfig();
try {
EMPTY_CHUNK_BIOME = RegistryAccess.registryAccess().getRegistry(RegistryKey.BIOME)
.get(NamespacedKey.minecraft(getConfig().getString("emptyChunkBiome", "the_void").toLowerCase()));
}catch (Exception e) {
EMPTY_CHUNK_BIOME = null;
}
if(EMPTY_CHUNK_BIOME == null) {
getLogger().warning("Biome not found, using THE_VOID");
EMPTY_CHUNK_BIOME = Biome.THE_VOID;
} else {
getLogger().info("Using biome " + EMPTY_CHUNK_BIOME.getKey().getKey());
}
}

@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { return new VoidChunkGenerator(); }
Expand Down Expand Up @@ -58,15 +77,17 @@ public void generateCaves(@NotNull WorldInfo worldInfo, @NotNull Random random,
public boolean canSpawn(World world, int x, int z) { return true; }

@Override
public Location getFixedSpawnLocation(World world, Random random) { return new Location(world, 0, 100, 0); }
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, getConfig().getInt("spawn.x", 0), getConfig().getInt("spawn.y", 64), getConfig().getInt("spawn.z", 0));
}
}
private class VoidBiomeProvider extends BiomeProvider {

@Override
public @NotNull Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) { return Biome.THE_VOID; }
public @NotNull Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) { return EMPTY_CHUNK_BIOME; }

@Override
public @NotNull List<Biome> getBiomes(@NotNull WorldInfo worldInfo) { return List.of(Biome.THE_VOID); }
public @NotNull List<Biome> getBiomes(@NotNull WorldInfo worldInfo) { return List.of(EMPTY_CHUNK_BIOME); }

}
}
9 changes: 9 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The biome to use for empty chunks. This biome will be used for chunks that have not been generated yet.
# Accepted value can be found there: https://jd.papermc.io/paper/1.21.3/org/bukkit/block/Biome.html
emptyChunkBiome: "THE_VOID"

# Coordinates of the spawn point
spawn:
x: 0
y: 64
z: 0

0 comments on commit 7f5cccf

Please # to comment.