Skip to content

Project Structure

el211 edited this page Sep 9, 2026 · 1 revision

Project Structure

GoCraft/
├── bedrock/
│   ├── listener.go         # RakNet listener, login, Bedrock play loop
│   └── world/              # Canonical block-hash and sub-chunk encoder
├── config/
│   └── config.go           # YAML loading, defaults, and validation
├── core/
│   ├── entity/             # Canonical Entity type and thread-safe registry
│   ├── game/game.go        # Edition-neutral player registry + shared entity IDs
│   ├── permission/         # Group/user permission model and manager
│   ├── player/             # Canonical Player model (position, inventory, game mode)
│   ├── spatial/            # Position and rotation types
│   └── world/
│       ├── block.go        # Block{Namespace, Name, Properties}
│       ├── chunk.go        # Sections, chunks, block entities
│       ├── generator.go    # Seeded Overworld/Nether/End terrain generator
│       ├── storage.go      # Storage interface (disk / memory)
│       ├── world.go        # Concurrent world cache with dirty-chunk tracking
│       └── arch_test.go    # Fails build if core/ imports java/
├── customitems/
│   ├── pack.go             # Item definition structs
│   ├── registry.go         # Persistent CMD / Bedrock runtime ID assignments
│   ├── manager.go          # Pack loader — scans packs/, assigns IDs
│   ├── javapack.go         # Java resource pack ZIP generator
│   ├── javaserver.go       # Embedded HTTP server for Java pack delivery
│   ├── bedrockpack.go      # Bedrock .mcaddon generator (RP + BP)
│   └── bedrockitems.go     # StartGame ItemEntry list builder
├── java/
│   ├── auth/               # Login crypto, UUIDs, Mojang sessions
│   ├── handler/            # Login/play handlers, commands, recipes, crafting
│   ├── network/            # TCP listener and client connections
│   ├── protocol/           # Framing, packets, VarInts, wire types
│   ├── registry/           # Provider interface + VanillaProvider
│   └── world/
│       ├── anvil/          # Anvil region-file I/O, NBT, atomic saves
│       ├── blocks.go       # StateID() accessor
│       ├── items.go        # ItemID/ItemName + block-placement helpers
│       ├── chunk.go        # Java chunk encoder (PalettedContainer, heightmaps)
│       └── sender.go       # Chunk burst sender
├── internal/
│   ├── gamedata/           # go:embed declarations for JSON data files
│   │   └── java/1.21.4/    # blocks.json, registries.json, recipes.json
│   └── protocoldata/       # MustCB/MustSB packet ID resolver
│       └── java/1.21.4/    # Packet ID JSON files per protocol state
├── runtime/                # Native Go plugin runtime (JVM/Go link, supervisor)
├── server/
│   ├── server.go           # Core + adapter orchestration
│   ├── chatformat.go       # Chat format loader (configuration/chatformat.yml)
│   ├── glyphs.go           # Glyph map loader (configuration/glyphs.yml)
│   └── resourcepack.go     # Bedrock pack loader (.mcpack / .mcaddon)
├── docs/                   # Documentation pages
├── logs/                   # Milestone development records
├── main.go                 # Executable entry point
└── server.yml              # Runtime configuration

Layering rules

  • core/ is the foundation. It never imports java/ or bedrock/. Edition-specific IDs (Java state IDs, Bedrock runtime IDs) are never stored in core/ types — they are resolved only at the adapter boundary.
  • java/ and bedrock/ are peers. Neither imports the other. Each reads canonical state and produces its own native wire format.
  • server/ is the composition root that wires config + core + adapters into the binary.

The core/world/arch_test.go test fails the build if core/ imports an adapter, keeping the boundary honest. See Architecture and Contributing.

Custom items pipeline

packs/mypacks/items.yml
       │
customitems.Load()
       ├── assigns CMD integers (Java)      → packs/.registry.yml (persistent)
       ├── assigns runtime IDs (Bedrock)    → packs/.registry.yml (persistent)
       ├── BuildJavaPack() → ZIP in memory  → HTTP server on :8080
       ├── BuildBedrockPack() → mcaddon     → bedrock/listener pack list
       └── BedrockItemEntries()             → StartGame.Items (appended to vanilla registry)

Clone this wiki locally