How can I create new world (sponge 8.0)?

How can I create new world (sponge 8.0) ?

I want to create list of worlds:

  • spawn: (void world/empty world)
  • home: (general world)

I want the code to create void world and general world.
Please help me.

Take a look at world template for creating worlds

https://jd.spongepowered.org/spongeapi/8.0.0/org/spongepowered/api/world/server/WorldTemplate.html

Its easier to create the 3 main types of worlds (overworld, nether, end), but you can make a flat world with the only layer being air (creating a void world).

1 Like

Thank for you care!

how can I create the flat world with the only layer being air ?

Could you please send me an example code ?

Yeah sure. I thought i had one on my github but must have forgot to push. Ill send it when im on my pc

1 Like

Thank you so much!

            WorldTemplate templateWorld = WorldTemplate
                    .builder()
                    .key(MinigameWorldManager.MINIGAME_WORLD)
                    .serializationBehavior(SerializationBehavior.NONE)
                    .displayName(Component.text("Minigames"))
                    .performsSpawnLogic(false)
                    .generator(ChunkGenerator.flat(FlatGeneratorConfig
                                                           .builder()
                                                           .addLayer(LayerConfig.of(0, BlockTypes.AIR
                                                                   .get()
                                                                   .defaultState()))
                                                           .structureConfig(StructureGenerationConfig.none())
                                                           .biome(Biomes.PLAINS)
                                                           .build()))
                    .build();
1 Like

Thank for you care! I’ll test it for now!

How can I create a world with random seed ? I’ve created 2 worlds. They are the same seed value.

On the WorldFactory#builder there is a method of generationConfig which accepts a WorldGenerationConfig.

The builder for WorldGenerationConfig allows you to supply your own world seed where you can supply a random long.

The code would be something like

var random = new Random();
var worldGenConfig = WorldGenerationConfig
  .Mutable
  .builder()
  .seed(random.nextLong())
  .build();
var world = WorldTemplate
  .builder()
  .generationConfig(worldGenConfig)
  .//your other world methods
  .build()


1 Like

Thank for you care!

1 Like