Interface TestWorldBuilder


@NonExtendable public interface TestWorldBuilder
A builder used for creating singleplayer worlds and dedicated servers.

Worlds from this builder default to being flat worlds with settings and game rules designed for consistency of tests, see the package documentation for details. To disable this, use setUseConsistentSettings(boolean). If you need to re-enable a particular setting, you can override it using adjustSettings(java.util.function.Consumer<net.minecraft.client.gui.screen.world.WorldCreator>).

  • Method Details

    • setUseConsistentSettings

      TestWorldBuilder setUseConsistentSettings(boolean useConsistentSettings)
      Sets whether to use consistent world settings. Consistent settings are designed for consistency of tests. See the package documentation for details on what the consistent settings are.

      If disabled, the world builder will default to creating worlds with the default world preset in survival mode, as if clicking straight through the create world screen without changing any settings.

      Parameters:
      useConsistentSettings - Whether to use consistent settings
      Returns:
      This world builder instance
    • adjustSettings

      TestWorldBuilder adjustSettings(Consumer<WorldCreator> settingsAdjuster)
      Adjusts the world settings from the default. Can be used to adjust anything that can be changed in the create world screen, including generation settings and game rules.
      Parameters:
      settingsAdjuster - The function to adjust the world settings
      Returns:
      This world builder instance
    • create

      Creates and joins a singleplayer world with the configured world settings.
      Returns:
      The singleplayer context of the world that was joined
    • createServer

      default TestDedicatedServerContext createServer()
      Creates and starts a dedicated server with the configured world settings.
      Returns:
      The dedicated server context of the server that was created
    • createServer

      TestDedicatedServerContext createServer(Properties serverProperties)
      Creates and starts a dedicated server with the configured world settings and some custom server properties.
      Parameters:
      serverProperties - The custom server properties to be written to the server.properties file.
      Returns:
      The dedicated server context of the server that was created.