Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Box3Blocks is a Minecraft mod that imports 372 decorative blocks from the Box3 platform into Minecraft, supporting terrain file import/export and model items. The repository is a **multi-project monorepo** with 7 independent subprojects targeting different mod loaders and Minecraft versions. There is no root build system — each subproject has its own Gradle wrapper and `build.gradle`.

## Subprojects

| Directory | Loader | MC Version | Java | Key Plugin |
| ------------------ | -------- | ---------- | ---- | -------------------------------- |
| `Fabric-1.20.1/` | Fabric | 1.20.1 | 17 | `fabric-loom-remap` |
| `Fabric-1.21.1/` | Fabric | 1.21.1 | 21 | `fabric-loom-remap` |
| `Fabric-1.21.11/` | Fabric | 1.21.11 | 21 | `fabric-loom-remap` |
| `Fabric-26.1/` | Fabric | 26.1 | 25 | `fabric-loom` |
| `Forge-1.20.1/` | Forge | 1.20.1 | 17 | `net.minecraftforge.gradle` v6.x |
| `NeoForge-1.21.1/` | NeoForge | 1.21.1 | 21 | NeoForge ModDevGradle |
| `NeoForge-26.1/` | NeoForge | 26.1 | 25 | NeoForge ModDevGradle |

## Build Commands

Each subproject is built independently. The Gradle wrapper exists in each subproject directory:

```bash
# Build a single subproject
cd Fabric-26.1 && ./gradlew build

# Clean build artifacts
cd Fabric-26.1 && ./gradlew clean

# Build all in sequence (bash loop)
for d in Fabric-1.20.1 Fabric-1.21.1 Fabric-1.21.11 Fabric-26.1; do
(cd "$d" && ./gradlew build) || break
done
```

**Important:** Forge-1.20.1 requires Java 17 (ForgeGradle 6.x doesn't support Java 21+). All other subprojects use their respective Java versions as noted in the table above.

There are no existing tests (`src/test` directories are empty).

## Shared Resources Architecture

To avoid ~20,000 duplicate asset files across subprojects, shared resources are centralized into three directories. Each subproject's `build.gradle` pulls from the appropriate sources:

- **`shared-resources/`** — used by ALL subprojects: 2,324 block textures (PNG + mcmeta), 372 block models, 372 blockstates, 372 item model definitions, `icon.png`, worldgen data, `block-id.json`, `block-spec.json`
- **`shared-resources-fabric/`** — used by all 4 Fabric subprojects: 372 `models/item/` JSONs + lang files (`en_us.json`, `zh_cn.json`)
- **`shared-resources-forge/`** — used by Forge + both NeoForge subprojects: 372 `models/item/` JSONs + lang files

Resource merging uses `DuplicatesStrategy.EXCLUDE` in Fabric/Forge `processResources` (subproject-local files take precedence over shared), and NeoForge uses `srcDir()` in source sets.

Per-subproject files that remain in `src/main/resources/`:

- `fabric.mod.json` (Fabric variants — metadata + mixin configs)
- `META-INF/mods.toml`, `pack.mcmeta` (Forge/NeoForge)
- `data/box3/worldgen/visible.json` override (Fabric-1.20.1 only)
- `assets/box3/lang/` overrides (Fabric-1.21.11, Fabric-26.1 — newer lang format differs from the older Fabric group)

## Code Architecture

### Two Package Trees

Fabric subprojects use the **`com.box3lab`** package. Forge/NeoForge subprojects use **`com.box3lab.box3`**. The Java source under each is structurally similar but uses loader-specific APIs (Fabric's `Registry` vs Forge/NeoForge's `DeferredRegister`).

### Runtime Block Generation

This mod does **not** define each of the 372 blocks as individual Java classes. Instead, blocks are generated programmatically at registration time:

1. `BlockIndexData` / `BlockIndexUtil` reads `block-id.json` and `block-spec.json` from resources — these define every block's ID, name, category, light level, opacity, etc.
2. `VoxelBlockFactories` / `VoxelBlockPropertiesFactory` creates `Block` instances dynamically from the spec data.
3. `ModBlocks` (Fabric) or `Box3Blocks` (Forge/NeoForge) orchestrates registration into Minecraft's registry system.
4. `CreativeTabRegistrar` groups blocks into 9 creative mode tabs based on category.

Only 6 special blocks have dedicated Java classes: `VoxelBlock`, `GlassVoxelBlock`, `BarrierVoxelBlock`, `BouncePadBlock`, `ConveyorBlock`, `SpiderWebBlock`.

### Key Source Files (in every subproject)

- **Entry point**: `Box3.java` (Fabric, implements `ModInitializer`) or `Box3Blocks.java` (Forge/NeoForge, annotated `@Mod`)
- **Client entry**: `Box3Client.java` (Fabric) or `Box3BlocksClient.java` (Forge/NeoForge)
- **Commands**: `ModCommands.java` — `/box3import`, `/box3export`, `/box3barrier`, `/box3perm`
- **Config**: `ConfigUtil.java` (Fabric) or `Box3Config.java` (Forge/NeoForge) — permission level, barrier visibility
- **Import/Export**: `Box3ImportFiles.java` / `VoxelImport.java` / `VoxelExport.java` — terrain `.gz` file handling
- **Model items**: `PackModelBlockEntity.java` / `PackModelEntityBlock.java` — resource-pack-loaded custom models

### Version Differences Worth Noting

- `VoxelExport` only exists in Fabric-1.21.11, Fabric-26.1, and all Forge/NeoForge variants (not in older Fabric)
- `VoxelFluidRenderHandler` only in Fabric-1.21.11
- NeoForge-26.1 moved client code from `src/main/java` to `src/client/java`
- Fabric-26.1 uses `fabric-loom` (not `fabric-loom-remap`) and Java 25

## Tools

- **`tools/generate_blocks_fabric.py`** — generates Fabric block registration code
- **`tools/generate_blocks_forge.py`** — generates Forge/NeoForge block registration code
- **`tools/strength_blocks.py`** — block property utilities shared by both generators
- **`tools/box3-texture-cut/`** — TypeScript tool for cutting sprite sheets into individual block textures
2 changes: 1 addition & 1 deletion Fabric-1.20.1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "box3",
"version": "${version}",
"name": "Box3Blocks(神岛材质包)",
"description": "Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"description": "Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"authors": ["神岛实验室"],
"contact": {
"homepage": "https://box3lab.com/",
Expand Down
2 changes: 1 addition & 1 deletion Fabric-1.21.1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "box3",
"version": "${version}",
"name": "Box3Blocks(神岛材质包)",
"description": "Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"description": "Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"authors": ["神岛实验室"],
"contact": {
"homepage": "https://box3lab.com/",
Expand Down
2 changes: 1 addition & 1 deletion Fabric-1.21.11/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "box3",
"version": "${version}",
"name": "Box3Blocks(神岛材质包)",
"description": "Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"description": "Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"authors": ["神岛实验室"],
"contact": {
"homepage": "https://box3lab.com/",
Expand Down
12 changes: 4 additions & 8 deletions Fabric-26.1/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "box3",
"version": "${version}",
"name": "Box3Blocks(神岛材质包)",
"description": "Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"description": "Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。",
"authors": ["神岛实验室"],
"contact": {
"homepage": "https://box3lab.com/",
Expand All @@ -13,12 +13,8 @@
"icon": "assets/box3/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"com.box3lab.Box3"
],
"client": [
"com.box3lab.Box3Client"
]
"main": ["com.box3lab.Box3"],
"client": ["com.box3lab.Box3Client"]
},
"mixins": [
"box3.mixins.json",
Expand All @@ -33,4 +29,4 @@
"java": ">=25",
"fabric-api": "*"
}
}
}
2 changes: 1 addition & 1 deletion Forge-1.20.1/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ mod_group_id=com.box3lab.box3
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=Box3Lab
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Box3 Block Mod adds 373 unique decorative blocks to Minecraft, including letters, symbols, color blocks, and glowing blocks, all neatly organized under a Creative Mode tab. It also supports one-click migration of buildings/models from Box3 to Minecraft.
mod_description=Box3 Block Mod adds 372 unique decorative blocks to Minecraft, including letters, symbols, color blocks, and glowing blocks, all neatly organized under a Creative Mode tab. It also supports one-click migration of buildings/models from Box3 to Minecraft.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ authors="神岛实验室"

# The description text for the mod (multi line!) (#mandatory)
description='''
Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。
Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。
'''

# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ authors="神岛实验室"

# The description text for the mod (multi line!) (#mandatory)
description='''
Box3 方块模组为 Minecraft 添加 373 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。
Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。
'''

# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

[简体中文](README.md) | [English](README_en.md)

导入神奇代码岛的373个方块到我的世界,让你在MC中也能使用熟悉的方块进行创作,还支持将神奇代码岛中的建筑/模型结构完整迁移到Minecraft世界中,保持原汁原味的建造风格。
导入神奇代码岛的372个方块到我的世界,让你在MC中也能使用熟悉的方块进行创作,还支持将神奇代码岛中的建筑/模型结构完整迁移到Minecraft世界中,保持原汁原味的建造风格。

## 🌟 主要功能

### 🎨 丰富的方块

- **373种方块**:包括字母、数字、符号、颜色、元素等
- **372种方块**:包括字母、数字、符号、颜色、元素等
- **9个创造标签**:分类整理,方便查找
- Box3:字母 - A-Z字母方块
- Box3:数字 - 0-9数字方块
Expand Down
4 changes: 2 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

[简体中文](README.md) | [English](README_en.md)

Import 373 blocks from the Box3 (Magic Code Island) platform into Minecraft, so you can build with the same familiar blocks inside MC.
Import 372 blocks from the Box3 (Magic Code Island) platform into Minecraft, so you can build with the same familiar blocks inside MC.
You can also migrate structures from Box3 directly into your Minecraft world, preserving the original building style.

## 🌟 Features

### 🎨 Rich Block Library

- **373 blocks**: including letters, numbers, symbols, colors, elements, etc.
- **372 blocks**: including letters, numbers, symbols, colors, elements, etc.
- **9 creative tabs**: organized for easy search and use
- Box3: Letters – A-Z letter blocks
- Box3: Numbers – 0-9 number blocks
Expand Down
1 change: 0 additions & 1 deletion tools/box3-texture-cut/src/blockIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function getSoildBlockTexturePositionById(blockId: number): {
throw new Error(`Error: Block ${blockId} isn't fluid!`);
}
const basePtr = index * 6;
console.log(basePtr);
const faceNameTable = {
0: "left",
1: "right",
Expand Down
Loading