Skip to content

Commit 8b7643f

Browse files
author
Gegy
committed
update README to reflect API changes
1 parent e39b8a2 commit 8b7643f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ Values such as difficulty, game rules, and weather can all be configured per-wor
4444
#### Creating a temporary dimension
4545
Once 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
```
5756
Explicit deletion is not strictly required for temporary worlds: they will be automatically cleaned up when the server exits.
5857
However, 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
6160
Persistent 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

7270
The main difference involves the addition of an `Identifier` parameter which much be specified to name your dimension uniquely.

0 commit comments

Comments
 (0)