Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,50 @@ Fantasy fantasy = Fantasy.get(server);
// ...
```

All dimensions created with Fantasy must be set up through a `RuntimeWorldConfig`.
All dimensions created with Fantasy must be set up through a `RuntimeLevelConfig`.
This specifies how the dimension should be created, involving a dimension type, seed, chunk generator, and so on.

For example, we could create a config like such:
```java
RuntimeWorldConfig worldConfig = new RuntimeWorldConfig()
RuntimeLevelConfig levelConfig = new RuntimeLevelConfig()
.setDimensionType(DimensionTypes.OVERWORLD)
.setDifficulty(Difficulty.HARD)
.setGameRule(GameRules.DO_DAYLIGHT_CYCLE, false)
.setGenerator(server.getOverworld().getChunkManager().getChunkGenerator())
.setSeed(1234L);
```

Values such as difficulty, game rules, and weather can all be configured per-world.
World-wide values such as difficulty and game rules can be configured per-level.

#### Creating a temporary dimension
Once we have a runtime world config, creating a temporary dimension is simple:
Once we have a runtime level config, creating a temporary dimension is simple:
```java
RuntimeWorldHandle worldHandle = fantasy.openTemporaryWorld(worldConfig);
RuntimeLevelHandle levelHandle = fantasy.openTemporaryLevel(levelConfig);

// set a block in our created temporary world!
ServerWorld world = worldHandle.asWorld();
world.setBlockState(BlockPos.ORIGIN, Blocks.STONE.getDefaultState());
// set a block in our created temporary level!
ServerLevel level = levelHandle.asLevel();
level.setBlock(BlockPos.ZERO, Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL);

// we don't need the world anymore, delete it!
worldHandle.delete();
// we don't need the level anymore, delete it!
levelHandle.delete();
```
Explicit deletion is not strictly required for temporary worlds: they will be automatically cleaned up when the server exits.
However, it is generally a good idea to delete old worlds if they're not in use anymore.
Explicit deletion is not strictly required for temporary levels: they will be automatically cleaned up when the server exits.
However, it is generally a good idea to delete old levels if they're not in use anymore.

#### Creating a persistent dimension
Persistent dimensions work along very similar lines to temporary dimensions:

```java
RuntimeWorldHandle worldHandle = fantasy.getOrOpenPersistentWorld(new Identifier("foo", "bar"), config);
RuntimeLevelHandle levelHandle = fantasy.getOrOpenPersistentLevel(new Identifier("foo", "bar"), config);

// set a block in our created persistent world!
ServerWorld world = worldHandle.asWorld();
world.setBlockState(BlockPos.ORIGIN, Blocks.STONE.getDefaultState());
// set a block in our created persistent level!
ServerLevel level = levelHandle.asLevel();
level.setBlockState(BlockPos.ORIGIN, Blocks.STONE.getDefaultState());
```

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

Another **very important note** with persistent dimensions is that `getOrOpenPersistentWorld` must be called to re-initialize
the dimension after a game restart! Fantasy will not restore the dimension by itself- it only makes sure that the world data
Another **very important note** with persistent dimensions is that `getOrOpenPersistentLevel` must be called to re-initialize
the dimension after a game restart! Fantasy will not restore the dimension by itself- it only makes sure that the level data
sticks around. This means, if you have a custom persistent dimension, you need to keep track of it and all its needed
data such that it can be reconstructed by calling `getOrOpenPersistentWorld` again with the same identifier.
data such that it can be reconstructed by calling `getOrOpenPersistentLevel` again with the same identifier.
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.13.+'
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'maven-publish'
}

Expand Down Expand Up @@ -41,10 +41,9 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

testmodImplementation sourceSets.main.output
}
Expand All @@ -59,14 +58,14 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 21
it.options.release = 25
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}

jar {
Expand All @@ -76,11 +75,12 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
artifact(tasks.jar.archiveFile) {
builtBy(tasks.jar)
}
artifact(sourcesJar) {
builtBy remapSourcesJar

artifact(tasks.sourcesJar) {
builtBy tasks.sourcesJar
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties

minecraft_version=1.21.11
yarn_mappings=1.21.11+build.1
loader_version=0.18.2
minecraft_version=26.1-pre-2
loader_version=0.18.4
loom_version=1.15-SNAPSHOT

# Mod Properties
mod_version=0.7.0
mod_version=0.8.0
maven_group=xyz.nucleoid
archives_base_name=fantasy

# Dependencies
fabric_version=0.139.4+1.21.11
fabric_api_version=0.143.14+26.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading