π¦ About the MattCraft Mod
The MattCraft mod is a custom Fabric mod built for Minecraft 1.21.1 that integrates with the companion web app and BlueMap to provide enhanced server features and tracking.
π― Core Features
πΊοΈ BlueMap Sign Marker Detection
Automatically detects when players place signs in the game world and creates persistent markers on the BlueMap. These markers are stored in the database and survive server restarts.
- Automatically scans for new signs every 5 seconds
- Creates POI markers on BlueMap at sign locations
- Uses the first line of the sign as the marker title
- Markers are stored in the database for persistence
- On server restart, all markers are recreated from database
π Showcase Auto-Generation
When a sign marker is created, the mod automatically generates a showcase entry in the companion app. This links map markers to the showcase system.
- Creates placeholder showcase with sign text as title
- Marked as "auto-generated" in the database
- Players can upload photos and descriptions later
- Linked to season objectives for tracking progress
π HTTP API Integration
The mod communicates with the companion app via HTTP REST API to save marker data and create showcases.
- API Base URL:
http://172.17.0.1:3000/api - POST to
/api/markersto save marker data - POST to
/api/showcases/from-markerto create showcase - GET from
/api/markerson server startup to restore markers
ποΈ Technical Architecture
Minecraft Mod
- Minecraft Version: 1.21.1
- Mod Loader: Fabric
- Language: Java 21
- Build Tool: Gradle 8.10.2
Dependencies
- Fabric API
- BlueMap API (for marker management)
- Java HttpURLConnection (for HTTP requests)
Companion App
- Framework: Next.js 14
- Database: SQLite (better-sqlite3)
- API: REST endpoints
- Authentication: Session-based with device pairing
Deployment
- Server: Docker container
- Companion App: Runs outside Docker on host
- Database: Shared SQLite file at
/opt/docker/mattcraft_dev/companion-app/data/mattcraft.db - Docker Gateway: 172.17.0.1 (for mod β app communication)
π Project Structure
mattcraft_dev/
βββ src/main/java/com/mattcraft/
β βββ SignMarkerManager.java # Main marker detection logic
βββ build.gradle # Gradle build configuration
βββ gradle.properties # Mod metadata
βββ server/ # Minecraft server files
β βββ mods/ # Deployed mod JAR
β βββ config/bluemap/ # BlueMap configuration
βββ companion-app/ # Next.js web app
β βββ app/api/ # REST API endpoints
β βββ app/showcase/ # Showcase page
β βββ app/season/ # Season objectives tracker
β βββ lib/db.ts # Database schema
β βββ data/mattcraft.db # SQLite database
βββ scripts/
βββ build-mod.sh # Build the mod JAR
βββ deploy-mod.sh # Deploy to server
π§ Development Workflow
Building the Mod
# Using Docker for consistent build environment ./scripts/build-mod.sh # Or manually with Gradle ./gradlew build
Deploying to Server
# Build and deploy in one step ./scripts/deploy-mod.sh # Or manually copy the JAR cp build/libs/mattcraft-mod-1.0.0.jar server/mods/
Testing Changes
# Start the companion app cd companion-app npm run dev # Start the Minecraft server docker compose up -d # Watch server logs ./scripts/server-logs.sh
π Debugging
Common Issues
Markers not persisting across restarts
- Check if mod is deployed:
ls -la server/mods/ - Verify API URL is correct: should be
172.17.0.1:3000 - Check companion app logs for API errors
- Verify middleware allows
/api/markersand/api/showcases
HTTP connection failed
- Ensure companion app is running on port 3000
- Test from inside Docker:
docker exec -it mattcraft-server curl http://172.17.0.1:3000/api/markers - Check Docker network gateway:
docker network inspect bridge | grep Gateway
Showcases not appearing
- Check database:
sqlite3 companion-app/data/mattcraft.db "SELECT * FROM showcases;" - Verify
uploaded_bycan be NULL (for auto-generated) - Check
is_auto_generatedcolumn exists - Clear Next.js cache:
rm -rf companion-app/.next
π Database Schema
markers
id- Primary keymarker_id- Unique BlueMap marker IDblock_x, block_y, block_z- Sign coordinatesworld- Minecraft world namesign_text- First line of signshowcase_id- Foreign key to showcasescreated_at- Unix timestamp
showcases
id- Primary keytitle- Showcase title (from sign or user)description- Optional descriptionimage_url- Path to image (placeholder or uploaded)uploaded_by- User ID (nullable for auto-generated)is_auto_generated- 1 if created by mod, 0 if user-createdmarker_id- Link to BlueMap markercoordinates- Optional coordinate stringcreated_at, updated_at- Timestamps
objectives
id- Primary keycategory- Category name (Farms, Utility, etc.)name- Objective namecompleted- 0 or 1showcase_id- Foreign key to showcasesmarker_id- Link to BlueMap markercompleted_by- User who completed itcompleted_at- Completion timestamppoints, description, display_order- Metadata
π Future Enhancements
- Real-time marker updates (WebSocket integration)
- Multiple photos per showcase
- Comments and reactions on showcases
- Marker categories and filtering
- Notification system for new markers
- Achievement system linked to objectives