Hello World - Your First Add-on
A basic example to get you started with Minecraft Bedrock scripting.
What This Does
This is a minimal add-on that logs when the world initializes and greets players when they join. It demonstrates the core pattern: import modules, set up event listeners, react to events.
The pattern you'll use everywhere:
- Import what you need (
world,system) - Subscribe to events
- React to those events
Setup
- Create a behavior pack folder
- Add a manifest.json file
- Create your main script
Basic Script
import { world, system } from "@minecraft/server";
// Run once when world loads
system.run(() => {
console.log("Add-on loaded!"); // Shows in server console
});
// Listen for player joins
world.afterEvents.playerJoin.subscribe((event) => {
const player = event.player;
player.sendMessage("§6Welcome to the realm!"); // Shows to player
});
Understanding imports: world is how you access server-wide events. system is for scheduling code to run at specific times.
manifest.json
{
"format_version": 2,
"header": {
"description": "My First Add-on",
"name": "Hello World",
"uuid": "12345678-1234-5678-1234-567812345678",
"version": [1, 0, 0],
"min_engine_version": [1, 14, 0]
},
"modules": [
{
"description": "Scripts",
"type": "script",
"uuid": "87654321-4321-8765-4321-876543218765",
"entry": "scripts/main.js",
"version": [1, 0, 0]
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.14.0"
}
]
}
What's Happening
- Import: Load Minecraft APIs
- system.run(): Run code once
- afterEvents.playerJoin: Subscribe to player join event
- player.sendMessage(): Send message to player
Next Steps
- Add more event listeners
- Create commands
- Store player data
- Add items and blocks
Testing
- Move your behavior pack to Minecraft
- Create a world with your pack enabled
- Open world logs to see console output (use !help to test)
This is the foundation for everything else you'll build!