-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.kt.ft
31 lines (25 loc) · 1.08 KB
/
Main.kt.ft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ${MAIN_CLASS.packageName}
import net.minestom.server.MinecraftServer
import net.minestom.server.instance.block.Block
import net.minestom.server.coordinate.Pos
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent
fun main() {
// Initialization
val minecraftServer = MinecraftServer.init()
// Create the instance
val instanceManager = MinecraftServer.getInstanceManager()
val instanceContainer = instanceManager.createInstanceContainer()
// Set the ChunkGenerator
instanceContainer.setGenerator { unit ->
unit.modifier().fillHeight(0, 40, Block.GRASS_BLOCK)
}
// Add an event callback to specify the spawning instance (and the spawn position)
val globalEventHandler = MinecraftServer.getGlobalEventHandler()
globalEventHandler.addListener(AsyncPlayerConfigurationEvent::class.java) { event ->
val player = event.getPlayer()
event.spawningInstance = instanceContainer
player.respawnPoint = Pos(0.0, 42.0, 0.0)
}
// Start the server on port 25565
minecraftServer.start("0.0.0.0", 25565)
}