Prerequisites
- Java 21 or higher installed
- A project with Minestom dependency configured (see Installation)
- Basic understanding of Java programming
Creating Your First Server
Let’s build a simple server that creates a flat world and spawns players in creative mode.Create the Main Class
Create a new Java class with a
main method. This will be the entry point for your server.Main.java
Auth.Offline() disables online mode authentication. For production servers, consider using Auth.Online() or integrating with a proxy like Velocity.Create a World Instance
Minestom uses “instances” instead of traditional worlds. Instances are lightweight containers for blocks and entities that can be easily created, copied, and managed.Add the following code before starting the server:
Main.java
Handle Player Connections
Now we need to handle player login and spawning. We’ll use Minestom’s event system to listen for player configuration and spawn events.
Main.java
Run Your Server
Compile and run your application. You should see output indicating the server has started:Connect to your server using the Minecraft client at
Terminal
localhost:25565.Make sure you’re using a Minecraft client version that matches your Minestom version (1.21.x based on the data version 1.21.11-rv2).
Complete Example
Here’s the complete working example based on the Minestom demo:Main.java
What’s Next?
Congratulations! You’ve created your first Minestom server. Here are some next steps:Core Concepts
Understand instances, blocks, entities, and the event system
Commands
Add custom commands using Brigadier
Block Handlers
Implement custom block interactions like chests and doors
Event System
Learn how to listen and respond to server events
