@@ -44,15 +44,14 @@ Values such as difficulty, game rules, and weather can all be configured per-wor
4444#### Creating a temporary dimension
4545Once we have a runtime world config, creating a temporary dimension is simple:
4646``` java
47- CompletableFuture<RuntimeWorldHandle > future = fantasy. openTemporaryWorld(worldConfig);
48- future. thenAccept(worldHandle - > {
49- // when the temporary world is created, set a block
50- ServerWorld world = worldHandle. asWorld();
51- world. setBlockState(BlockPos . ORIGIN , Blocks . STONE. getDefaultState());
52-
53- // we don't need the world anymore, delete it!
54- worldHandle. delete();
55- });
47+ RuntimeWorldHandle worldHandle = fantasy. openTemporaryWorld(worldConfig);
48+
49+ // set a block in our created temporary world!
50+ ServerWorld world = worldHandle. asWorld();
51+ world. setBlockState(BlockPos . ORIGIN , Blocks . STONE. getDefaultState());
52+
53+ // we don't need the world anymore, delete it!
54+ worldHandle. delete();
5655```
5756Explicit deletion is not strictly required for temporary worlds: they will be automatically cleaned up when the server exits.
5857However, it is generally a good idea to delete old worlds if they're not in use anymore.
@@ -61,12 +60,11 @@ However, it is generally a good idea to delete old worlds if they're not in use
6160Persistent dimensions work along very similar lines to temporary dimensions:
6261
6362``` java
64- CompletableFuture<RuntimeWorldHandle > future = fantasy. getOrOpenPersistentWorld(new Identifier (" foo" , " bar" ), config);
65- future. thenAccept(worldHandle - > {
66- // when the persistent world is created, set a block
67- ServerWorld world = worldHandle. asWorld();
68- world. setBlockState(BlockPos . ORIGIN , Blocks . STONE. getDefaultState());
69- });
63+ RuntimeWorldHandle worldHandle = fantasy. getOrOpenPersistentWorld(new Identifier (" foo" , " bar" ), config);
64+
65+ // set a block in our created persistent world!
66+ ServerWorld world = worldHandle. asWorld();
67+ world. setBlockState(BlockPos . ORIGIN , Blocks . STONE. getDefaultState());
7068```
7169
7270The main difference involves the addition of an ` Identifier ` parameter which much be specified to name your dimension uniquely.
0 commit comments