-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not load client class in server context
- Loading branch information
1 parent
506bdb4
commit 38e7c68
Showing
6 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Common/src/main/kotlin/possible_triangle/skygrid/world/ServerProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package possible_triangle.skygrid.world | ||
|
||
import net.minecraft.core.RegistryAccess | ||
import net.minecraft.server.dedicated.DedicatedServerProperties | ||
import net.minecraft.world.level.levelgen.WorldGenSettings | ||
import possible_triangle.skygrid.SkygridMod | ||
import kotlin.random.Random | ||
|
||
object ServerProvider { | ||
|
||
fun fromServerProperties(registries: RegistryAccess, properties: DedicatedServerProperties.WorldGenProperties): WorldGenSettings? { | ||
val levelType = properties.levelType | ||
if (levelType != SkygridMod.MOD_ID) return null | ||
|
||
val seed = properties.levelSeed.takeIf { it.isNotEmpty() }?.let { | ||
try { | ||
it.toLong() | ||
} catch (ex: NumberFormatException) { | ||
it.hashCode().toLong() | ||
} | ||
}.takeIf { it != 0L } ?: Random.nextLong() | ||
|
||
return SkygridChunkGenerator.createSettings(registries, seed, false) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters