diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2db888ce..3eb36893 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,6 +111,32 @@ jobs: name: Fabric-26.1-artifact path: Fabric-26.1/build/libs/ + build-fabric-26-2: + runs-on: ubuntu-24.04 + steps: + - name: checkout repository + uses: actions/checkout@v4 + - name: validate gradle wrapper + uses: gradle/actions/wrapper-validation@v4 + - name: setup jdk + uses: actions/setup-java@v4 + with: + java-version: "25" + distribution: "microsoft" + - name: make gradle wrapper executable + working-directory: ./Fabric-26.2 + run: chmod +x ./gradlew + + - name: build Fabric 26.2 + working-directory: ./Fabric-26.2 + run: ./gradlew build + + - name: upload artifacts Fabric 26.2 + uses: actions/upload-artifact@v4 + with: + name: Fabric-26.2-artifact + path: Fabric-26.2/build/libs/ + build-neoforge-1-21-1: runs-on: ubuntu-24.04 steps: diff --git a/AGENTS.md b/AGENTS.md index 27fd94d3..4d90ea44 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ This file provides guidance to Codex (Codex.ai/code) when working with code in t Box3Blocks is a Minecraft mod that imports 372 decorative blocks from the Box3 platform into Minecraft, supporting terrain file import/export and model items. It also includes **Box3JS**, a server-side TypeScript/JavaScript scripting engine (Rhino) for creating custom gameplay, mini-games, and world interactions. -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`. +The repository is a **multi-project monorepo** with 8 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 @@ -16,11 +16,12 @@ The repository is a **multi-project monorepo** with 7 independent subprojects ta | `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` | +| `Fabric-26.2/` | Fabric | 26.2 | 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 | **Box3JS lives here** — NeoForge ModDevGradle | | `NeoForge-26.1/` | NeoForge | 26.1 | 25 | NeoForge ModDevGradle | -Only NeoForge-1.21.1 has the Box3JS scripting engine. The other 6 subprojects are purely the Box3Blocks decorative block mod. +Only NeoForge-1.21.1 has the Box3JS scripting engine. The other 7 subprojects are purely the Box3Blocks decorative block mod. ## Build Commands @@ -36,7 +37,7 @@ cd run/config/box3/script/colorzone npm install && npm run build # esbuild → Babel → Rhino target ``` -**Important:** Forge-1.20.1 requires Java 17. All other subprojects use Java 21+. NeoForge-26.1 uses Java 25. +**Important:** Forge-1.20.1 requires Java 17. Fabric-1.21.1 and Fabric-1.21.11 use Java 21. Fabric-26.1, Fabric-26.2, and NeoForge-26.1 use Java 25. There are no existing tests (`src/test` directories are empty). @@ -45,7 +46,7 @@ There are no existing tests (`src/test` directories are empty). Shared resources are centralized to avoid ~20,000 duplicate asset files: - **`shared-resources/`** — used by ALL subprojects: block textures, models, blockstates, item models, worldgen data, `block-id.json`, `block-spec.json` -- **`shared-resources-fabric/`** — used by all 4 Fabric subprojects: `models/item/` JSONs + lang files +- **`shared-resources-fabric/`** — used by all 5 Fabric subprojects: `models/item/` JSONs + lang files - **`shared-resources-forge/`** — used by Forge + both NeoForge subprojects: `models/item/` JSONs + lang files ## Block Mod Architecture @@ -125,10 +126,11 @@ Consumable/Cooldown/Enchantable/JukeboxPlayable components are NOT available in ## Version Differences -- `VoxelExport` only in Fabric-1.21.11, Fabric-26.1, and Forge/NeoForge variants +- `VoxelExport` only in Fabric-1.21.11, Fabric-26.1, Fabric-26.2, and Forge/NeoForge variants - `VoxelFluidRenderHandler` only in Fabric-1.21.11 - NeoForge-26.1 moved client code to `src/client/java` -- Fabric-26.1 uses `fabric-loom` (not `fabric-loom-remap`) and Java 25 +- Fabric-26.1 and Fabric-26.2 use `fabric-loom` (not `fabric-loom-remap`) and Java 25 +- Fabric-26.2 uses `EntityTypes.ITEM_DISPLAY` (not `EntityType.ITEM_DISPLAY`) and `Vec3.atCenterOf()` (not `BlockPos.getCenter()`) ## Tools diff --git a/Box3JS-NeoForge-1.21.1/README_NEW.md b/Box3JS-NeoForge-1.21.1/README_NEW.md new file mode 100644 index 00000000..5ce6b5f8 --- /dev/null +++ b/Box3JS-NeoForge-1.21.1/README_NEW.md @@ -0,0 +1,79 @@ +# Box3JS — Minecraft Scripting Engine + +> **Beta** — APIs may change during early development. Feedback is welcome. + +**No Java, just TypeScript.** Build Minecraft minigames, RPG systems, and world mechanics with scripts that hot-reload in seconds. + +Built on Mozilla Rhino, Box3JS brings the Box3 coding style to Minecraft servers. Write TypeScript, run it instantly — no JDK, no Gradle, no server restarts. + +## Features + +- **TypeScript-first** — Full type declarations (`.d.ts`) with bilingual JSDoc, auto-complete in any editor +- **Box3-compatible API** — World, Entity, Player, Voxels, Storage, Database, HTTP, remoteChannel +- **110+ Minecraft extensions** — Scoreboards, BossBars, teams, world border, particles, fireworks, potions, custom blocks/items/sounds registration, and more +- **Client-side scripting** — Custom HUD, keyboard input, audio playback, client-side SQLite & HTTP +- **Project isolation** — Run multiple script projects independently, each with its own scope and callbacks +- **Sandbox mode** — Test safely; roll back all script-made changes on stop +- **Standalone compilation** — `/box3script compile` packages your script into a distributable JAR + +## Quick Start + +``` +/box3script create mygame +``` + +``` +npm install && npm run build +``` + +``` +/box3script sandbox mygame +/box3script start mygame +``` + +Full guide: [https://docs.box3lab.com/box3js-mc](https://docs.box3lab.com/box3js-mc) + +## License + +Apache License 2.0 + +--- + +# Box3JS(神岛代码)— Minecraft 脚本引擎 + +> **Beta** — 早期测试阶段,API 可能变动,欢迎反馈。 + +**不写 Java,只用 TypeScript。** 在 Minecraft 里用脚本开发小游戏、RPG 玩法、世界机制,热重载秒级生效。 + +Box3JS 基于 Mozilla Rhino 引擎,延续了神奇代码岛的 API 风格。无需 JDK、无需 Gradle、无需重启服务器,写 TypeScript 即写即跑。 + +## 特性 + +- **TypeScript 优先** — 完整类型声明(`.d.ts`),双语 JSDoc,任意编辑器均有自动补全 +- **Box3 兼容 API** — World / Entity / Player / Voxels / Storage / Database / HTTP / remoteChannel +- **110+ MC 扩展** — 记分板、Bossbar、队伍、世界边界、粒子、烟花、药水、自定义方块/物品/音效注册等 +- **客户端脚本** — 自定义 HUD、键盘输入、音效播放、客户端 SQLite & HTTP +- **项目隔离** — 多脚本项目独立运行,各自拥有独立作用域和回调 +- **沙盒模式** — 放心测试,停止后回滚一切脚本改动 +- **独立编译** — `/box3script compile` 一键打包为可分发 JAR + +## 快速开始 + +``` +/box3script create mygame +``` + +``` +npm install && npm run build +``` + +``` +/box3script sandbox mygame +/box3script start mygame +``` + +完整教程:[https://docs.box3lab.com/box3js-mc](https://docs.box3lab.com/box3js-mc) + +## 许可证 + +Apache License 2.0 diff --git a/Box3JS-NeoForge-1.21.1/docs/en/index.md b/Box3JS-NeoForge-1.21.1/docs/en/index.md index 0dd46e73..018e255e 100644 --- a/Box3JS-NeoForge-1.21.1/docs/en/index.md +++ b/Box3JS-NeoForge-1.21.1/docs/en/index.md @@ -3,76 +3,61 @@ layout: home hero: name: "Box3JS" - text: "JS/TS Scripting Engine for Minecraft" - tagline: Build custom gameplay, mini-games, and UIs — no JDK, no Java compilation required. + text: "TypeScript Scripting Engine for Minecraft" + tagline: No Java. No Gradle. No restarts. Write TypeScript, hot-reload in seconds. actions: - theme: brand text: Get Started link: /en/guide/getting-started + - theme: alt + text: Why Box3JS? + link: /en/guide/about-box3js features: + - icon: ⚡ + title: TypeScript, Zero Java + details: Full DTS types with bilingual JSDoc for every API. esbuild + Babel pipeline compiles modern TS to ES5 automatically. No JDK, no Gradle, no IDE setup. + - icon: 🔄 + title: Hot Reload in Seconds + details: Edit → save → see changes instantly. No server restarts. Built-in file watcher auto-reloads on every save. - icon: 🎮 + title: Box3-Compatible API + details: Same clean API style as Box3 (Shenqi Code Island). World, Entity, Player, Voxels, Storage, Database, HTTP, remoteChannel — all as global objects. + - icon: 🧩 + title: 110+ Minecraft Extensions + details: Scoreboards, BossBars, teams, world border, particles, fireworks, lightning, potions, custom blocks/items/sounds, and more. + - icon: 🖥️ title: Server & Client Scripting - details: Server-side world manipulation, entities, recipes. Client-side keyboard input, screen UI, sounds, SQLite storage, and HTTP requests. + details: Server handles game logic and world manipulation. Client handles keyboard input, HUD, audio, custom GUIs. Bidirectional events via remoteChannel. + - icon: 🛡️ + title: Sandbox Protection + details: Enable sandbox to auto-track all script changes. Disable to fully roll back. Test fearlessly — your map is always safe. - icon: 📦 - title: TypeScript First - details: Full DTS type definitions for all 17 global objects. Built-in esbuild + Babel pipeline transpiles modern TS to Rhino-compatible ES5. - - icon: 🔄 - title: Hot Reload - details: Edit scripts and see changes instantly without restarting the server. File watcher auto-reloads on save. - - icon: 🌐 - title: Bidirectional Communication - details: remoteChannel enables server↔client event messaging. Server broadcasts to all players; clients reply independently. + title: Standalone JAR Distribution + details: /box3script compile packages your scripts into a standalone mod. Drop it into mods/ — no Box3JS dependency required. - icon: 🗄️ - title: Dual-Side Storage & Database - details: JSON file persistence and SQLite on both server and client. Pagination, atomic updates, counters, and tagged-template queries. - - icon: 🧩 - title: Custom Blocks & Items - details: Block textures, item models, equipment, sounds, and creative tabs — all registered from JSON configs (standalone/JAR mode). - - icon: 📚 - title: Comprehensive Docs - details: 50+ pages across API reference, progressive tutorials, cookbook recipes, architecture deep-dive, and FAQ — in Chinese and English. - - icon: 🚀 - title: Standalone JAR Mode - details: Compile your script project into a self-contained JAR mod. No runtime dependency on Box3JS — just drop it in your mods folder. + title: Built-in Persistence + details: JSON file storage and SQLite database on both server and client. Leaderboards, player saves, economies — all built-in. --- ## Quick Start ```bash -# In-game: create a new project -/box3script create mygame +/box3script create mygame # scaffold a TypeScript project +``` -# Build and watch +```bash cd config/box3/script/mygame -npm install -npm run build -- --watch - -# TypeScript type checking -npm run check +npm install && npm run build # install deps + build ``` -```ts -// src/server/app.ts — your first script -world.onChat((entity, message) => { - if (message === "!hello") { - entity.player.directMessage(`Hello, ${entity.player.name}!`); - return false; - } - return true; -}); +```bash +/box3script sandbox mygame # enable sandbox (recommended) +/box3script start mygame # start the script ``` -[Read full docs →](/en/guide/getting-started) - -## Version Info +Open `src/server/app.ts`, write your game logic, save, then `/box3script reload mygame`. Enable `/box3script watch` and it auto-reloads on every save. -| Component | Version | -|-----------|---------| -| Minecraft | 1.21.1 | -| Mod Loader | NeoForge | -| Java | 21 | -| JS Engine | Mozilla Rhino 1.9.1 (ES5) | -| TypeScript | via Babel → ES5 | +[Full documentation →](/en/guide/getting-started) diff --git a/Box3JS-NeoForge-1.21.1/docs/index.md b/Box3JS-NeoForge-1.21.1/docs/index.md index 01e61bbc..41e8dcb8 100644 --- a/Box3JS-NeoForge-1.21.1/docs/index.md +++ b/Box3JS-NeoForge-1.21.1/docs/index.md @@ -3,76 +3,61 @@ layout: home hero: name: "Box3JS" - text: "Minecraft JS/TS 脚本引擎" - tagline: 神奇代码岛同款编程体验,用 JS/TS 在 Minecraft 里创造小游戏 + text: "Minecraft TypeScript 脚本引擎" + tagline: 不写 Java,不用 Gradle,不用重启。写 TypeScript,热重载秒级生效。 actions: - theme: brand text: 快速开始 link: /guide/getting-started + - theme: alt + text: 为什么选择 Box3JS? + link: /guide/about-box3js features: + - icon: ⚡ + title: TypeScript,零 Java + details: 所有 API 均提供完整 DTS 类型定义 + 双语 JSDoc。esbuild + Babel 构建管线自动转译现代 TS 到 ES5。无需 JDK、Gradle、IDE 配置。 + - icon: 🔄 + title: 秒级热重载 + details: 修改 → 保存 → 即时生效,不需要重启服务端。内置文件监听,保存即自动重载。 - icon: 🎮 + title: Box3 兼容 API + details: 延续神奇代码岛的简洁 API 风格。World、Entity、Player、Voxels、Storage、Database、HTTP、remoteChannel——全部全局注入,无需 import。 + - icon: 🧩 + title: 110+ MC 扩展 + details: 记分板、Bossbar、队伍、世界边界、粒子、烟花、闪电、药水、自定义方块/物品/音效注册……覆盖常见玩法需求。 + - icon: 🖥️ title: 服务端 & 客户端双端脚本 - details: 服务端:世界操作、实体、合成配方。客户端:键盘输入、屏幕 UI、音效、SQLite 存储、HTTP 请求。 + details: 服务端处理游戏逻辑和世界操作,客户端处理键盘、HUD、音效、自定义 GUI。通过 remoteChannel 双向实时通信。 + - icon: 🛡️ + title: 沙盒保护 + details: 开启沙盒自动追踪脚本所有改动,关闭沙盒完整回滚。放心测试,不破坏地图。 - icon: 📦 - title: TypeScript 优先 - details: 17 个全局对象全部提供 DTS 类型定义。内置 esbuild + Babel 构建管线,将现代 TS 转译为 Rhino 兼容的 ES5。 - - icon: 🔄 - title: 热重载 - details: 修改脚本即时生效,无需重启服务端。文件监听器在保存时自动重载。 - - icon: 🌐 - title: 双向通信 - details: remoteChannel 实现服务端↔客户端事件消息传递。服务端广播至所有玩家,客户端独立回复。 + title: 独立 JAR 分发 + details: /box3script compile 一键编译为独立模组,放入 mods/ 即可运行,无需 Box3JS 依赖。 - icon: 🗄️ - title: 双端存储 & 数据库 - details: 服务端和客户端均支持 JSON 文件持久化与 SQLite。分页查询、原子更新、计数器、标签模板查询。 - - icon: 🧩 - title: 自定义方块 & 物品 - details: 方块纹理、物品模型、装备、音效、创造标签页——全部通过 JSON 配置注册(独立/JAR 模式)。 - - icon: 📚 - title: 完善文档 - details: 50+ 页面,涵盖 API 参考、渐进式教程、常用配方、架构深入解析和常见问题——支持中英双语。 - - icon: 🚀 - title: 独立 JAR 模式 - details: 将脚本项目编译为独立 JAR 模组,无需依赖 Box3JS 运行时——放入 mods 文件夹即可使用。 + title: 内置持久化 + details: 服务端和客户端均支持 JSON 文件存储和 SQLite 数据库。排行榜、玩家存档、经济系统——全部内置。 --- ## 快速开始 ```bash -# 游戏内:创建新项目 -/box3script create mygame +/box3script create mygame # 创建 TypeScript 项目 +``` -# 构建并监听 +```bash cd config/box3/script/mygame -npm install -npm run build -- --watch - -# TypeScript 类型检查 -npm run check +npm install && npm run build # 安装依赖 + 构建 ``` -```ts -// src/server/app.ts — 你的第一个脚本 -world.onChat((entity, message) => { - if (message === "!hello") { - entity.player.directMessage(`你好,${entity.player.name}!`); - return false; - } - return true; -}); +```bash +/box3script sandbox mygame # 开启沙盒(推荐) +/box3script start mygame # 启动脚本 ``` -[查看完整文档 →](/guide/getting-started) - -## 版本信息 +打开 `src/server/app.ts` 写游戏逻辑,保存后 `/box3script reload mygame`。开启 `/box3script watch` 后保存即自动重载。 -| 组件 | 版本 | -|------|------| -| Minecraft | 1.21.1 | -| 模组加载器 | NeoForge | -| Java | 21 | -| JS 引擎 | Mozilla Rhino 1.9.1 (ES5) | -| TypeScript | 通过 Babel → ES5 | +[完整文档 →](/guide/getting-started) diff --git a/CLAUDE.md b/CLAUDE.md index da729076..510d0c2b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co Box3Blocks is a Minecraft mod that imports 372 decorative blocks from the Box3 platform into Minecraft, supporting terrain file import/export and model items. It also includes **Box3JS**, a dual-side (server + client) TypeScript/JavaScript scripting engine (Rhino) for creating custom gameplay, mini-games, GUIs, and world interactions. -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`. +The repository is a **multi-project monorepo** with 8 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 @@ -16,11 +16,12 @@ The repository is a **multi-project monorepo** with 7 independent subprojects ta | `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` | +| `Fabric-26.2/` | Fabric | 26.2 | 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 | **Box3JS lives here** — NeoForge ModDevGradle | | `NeoForge-26.1/` | NeoForge | 26.1 | 25 | NeoForge ModDevGradle | -Only NeoForge-1.21.1 has the Box3JS scripting engine. The other 6 subprojects are purely the Box3Blocks decorative block mod. +Only NeoForge-1.21.1 has the Box3JS scripting engine. The other 7 subprojects are purely the Box3Blocks decorative block mod. ## Build Commands @@ -39,7 +40,7 @@ cd run/config/box3/script/mygame && npm run build cd NeoForge-1.21.1 && node tools/verify-box3js-project.mjs ``` -**Important:** Forge-1.20.1 requires Java 17. All other subprojects use Java 21+. NeoForge-26.1 uses Java 25. +**Important:** Forge-1.20.1 requires Java 17. Fabric-1.21.1 and Fabric-1.21.11 use Java 21. Fabric-26.1, Fabric-26.2, and NeoForge-26.1 use Java 25. There are no existing tests (`src/test` directories are empty). @@ -48,7 +49,7 @@ There are no existing tests (`src/test` directories are empty). Shared resources are centralized to avoid ~20,000 duplicate asset files: - **`shared-resources/`** — used by ALL subprojects: block textures, models, blockstates, item models, worldgen data, `block-id.json`, `block-spec.json` -- **`shared-resources-fabric/`** — used by all 4 Fabric subprojects: `models/item/` JSONs + lang files +- **`shared-resources-fabric/`** — used by all 5 Fabric subprojects: `models/item/` JSONs + lang files - **`shared-resources-forge/`** — used by Forge + both NeoForge subprojects: `models/item/` JSONs + lang files ## Block Mod Architecture @@ -201,10 +202,11 @@ export default [ ## Version Differences -- `VoxelExport` only in Fabric-1.21.11, Fabric-26.1, and Forge/NeoForge variants +- `VoxelExport` only in Fabric-1.21.11, Fabric-26.1, Fabric-26.2, and Forge/NeoForge variants - `VoxelFluidRenderHandler` only in Fabric-1.21.11 - NeoForge-26.1 moved client code to `src/client/java` -- Fabric-26.1 uses `fabric-loom` (not `fabric-loom-remap`) and Java 25 +- Fabric-26.1 and Fabric-26.2 use `fabric-loom` (not `fabric-loom-remap`) and Java 25 +- Fabric-26.2 uses `EntityTypes.ITEM_DISPLAY` (not `EntityType.ITEM_DISPLAY`) and `Vec3.atCenterOf()` (not `BlockPos.getCenter()`) ## Tools diff --git a/Fabric-26.2/.gitattributes b/Fabric-26.2/.gitattributes new file mode 100644 index 00000000..097f9f98 --- /dev/null +++ b/Fabric-26.2/.gitattributes @@ -0,0 +1,9 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# Linux start script should use lf +/gradlew text eol=lf + +# These are Windows script files and should use crlf +*.bat text eol=crlf + diff --git a/Fabric-26.2/.github/workflows/build.yml b/Fabric-26.2/.github/workflows/build.yml new file mode 100644 index 00000000..524fb1bd --- /dev/null +++ b/Fabric-26.2/.github/workflows/build.yml @@ -0,0 +1,30 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: checkout repository + uses: actions/checkout@v6 + - name: validate gradle wrapper + uses: gradle/actions/wrapper-validation@v6 + - name: setup jdk + uses: actions/setup-java@v5 + with: + java-version: '25' + distribution: 'microsoft' + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + uses: actions/upload-artifact@v7 + with: + name: Artifacts + path: build/libs/ diff --git a/Fabric-26.2/.gitignore b/Fabric-26.2/.gitignore new file mode 100644 index 00000000..c476faf2 --- /dev/null +++ b/Fabric-26.2/.gitignore @@ -0,0 +1,40 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/Fabric-26.2/build.gradle b/Fabric-26.2/build.gradle new file mode 100644 index 00000000..9eb3321e --- /dev/null +++ b/Fabric-26.2/build.gradle @@ -0,0 +1,91 @@ +plugins { + id 'net.fabricmc.fabric-loom' version "${loom_version}" + id 'maven-publish' +} + +version = project.mod_version +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + +loom { + splitEnvironmentSourceSets() + + mods { + "box3" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } + +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + + implementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + +} + +processResources { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": inputs.properties.version + } + from(file("../shared-resources")) + from(file("../shared-resources-fabric")) +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 25 +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 +} + +jar { + inputs.property "archivesName", project.base.archivesName + + +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} diff --git a/Fabric-26.2/gradle.properties b/Fabric-26.2/gradle.properties new file mode 100644 index 00000000..fdc31cdb --- /dev/null +++ b/Fabric-26.2/gradle.properties @@ -0,0 +1,20 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349 +org.gradle.configuration-cache=false + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=26.2 +loader_version=0.19.3 +loom_version=1.17-SNAPSHOT + +# Mod Properties +mod_version=1.4.3-mc26.2 +maven_group=com.box3lab +archives_base_name=box3 + +# Dependencies +fabric_api_version=0.153.0+26.2 diff --git a/Fabric-26.2/gradle/wrapper/gradle-wrapper.jar b/Fabric-26.2/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..b1b8ef56 Binary files /dev/null and b/Fabric-26.2/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Fabric-26.2/gradle/wrapper/gradle-wrapper.properties b/Fabric-26.2/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..df6a6ad7 --- /dev/null +++ b/Fabric-26.2/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,9 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Fabric-26.2/gradlew b/Fabric-26.2/gradlew new file mode 100755 index 00000000..b9bb139f --- /dev/null +++ b/Fabric-26.2/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Fabric-26.2/gradlew.bat b/Fabric-26.2/gradlew.bat new file mode 100644 index 00000000..24c62d56 --- /dev/null +++ b/Fabric-26.2/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/Fabric-26.2/settings.gradle b/Fabric-26.2/settings.gradle new file mode 100644 index 00000000..622ce07c --- /dev/null +++ b/Fabric-26.2/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} + +// Should match your modid +rootProject.name = 'box3' diff --git a/Fabric-26.2/src/client/java/com/box3lab/Box3Client.java b/Fabric-26.2/src/client/java/com/box3lab/Box3Client.java new file mode 100644 index 00000000..649d7d52 --- /dev/null +++ b/Fabric-26.2/src/client/java/com/box3lab/Box3Client.java @@ -0,0 +1,9 @@ +package com.box3lab; + +import net.fabricmc.api.ClientModInitializer; + +public class Box3Client implements ClientModInitializer { + @Override + public void onInitializeClient() { + } +} \ No newline at end of file diff --git a/Fabric-26.2/src/client/resources/box3.client.mixins.json b/Fabric-26.2/src/client/resources/box3.client.mixins.json new file mode 100644 index 00000000..74c22c56 --- /dev/null +++ b/Fabric-26.2/src/client/resources/box3.client.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "com.box3lab.client.mixin", + "compatibilityLevel": "JAVA_25", + "client": [], + "injectors": { + "defaultRequire": 1 + }, + "overwrites": { + "requireAnnotations": true + } +} \ No newline at end of file diff --git a/Fabric-26.2/src/main/java/com/box3lab/Box3.java b/Fabric-26.2/src/main/java/com/box3lab/Box3.java new file mode 100644 index 00000000..e3962bd5 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/Box3.java @@ -0,0 +1,31 @@ +package com.box3lab; + +import com.box3lab.command.ModCommands; +import com.box3lab.register.ModBlocks; +import com.box3lab.register.ModItems; + +import net.fabricmc.api.ModInitializer; + +// import org.slf4j.Logger; +// import org.slf4j.LoggerFactory; + +public class Box3 implements ModInitializer { + public static final String MOD_ID = "box3"; + + // This logger is used to write text to the console and the log file. + // It is considered best practice to use your mod id as the logger's name. + // That way, it's clear which mod wrote info, warnings, and errors. + // public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + @Override + public void onInitialize() { + // This code runs as soon as Minecraft is in a mod-load-ready state. + // However, some things (like resources) may still be uninitialized. + // Proceed with mild caution. + ModBlocks.initialize(); + ModItems.initialize(); + ModCommands.register(); + + // LOGGER.info("Hello Fabric world!"); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/BarrierVoxelBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/BarrierVoxelBlock.java new file mode 100644 index 00000000..90e1a7f7 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/BarrierVoxelBlock.java @@ -0,0 +1,60 @@ +package com.box3lab.block; + +import com.box3lab.util.ConfigUtil; +import com.google.gson.JsonObject; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; + +import static com.box3lab.util.ConfigUtil.CONFIG_DIR_NAME; + +public class BarrierVoxelBlock extends VoxelBlock { + + private static volatile boolean visible = false; + + static { + loadConfig(); + } + + public BarrierVoxelBlock(BlockBehaviour.Properties properties) { + super(properties); + } + + @Override + public float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) { + return visible ? 0F : 1.0F; + } + + public static boolean isVisible() { + return visible; + } + + public static void setVisible(boolean value) { + visible = value; + saveConfig(); + } + + private static void loadConfig() { + JsonObject obj = ConfigUtil.readConfig(CONFIG_DIR_NAME); + if (obj == null) { + return; + } + if (obj.has("barrierVisible")) { + visible = obj.get("barrierVisible").getAsBoolean(); + } + } + + @Override + public RenderShape getRenderShape(BlockState state) { + return visible ? RenderShape.MODEL : RenderShape.INVISIBLE; + } + + private static void saveConfig() { + JsonObject obj = new JsonObject(); + obj.addProperty("barrierVisible", visible); + ConfigUtil.writeConfig(CONFIG_DIR_NAME, obj); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/BouncePadBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/BouncePadBlock.java new file mode 100644 index 00000000..69119653 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/BouncePadBlock.java @@ -0,0 +1,44 @@ +package com.box3lab.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; + +public class BouncePadBlock extends VoxelBlock { + + public BouncePadBlock(BlockBehaviour.Properties properties) { + super(properties); + } + + @Override + public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { + super.stepOn(level, pos, state, entity); + + if (entity.getY() < pos.getY() + 0.5D) { + return; + } + + Vec3 vel = entity.getDeltaMovement(); + + double bounce = 0.7D + level.getRandom().nextDouble() * 0.3D; + + if (vel.y < bounce) { + vel = new Vec3(vel.x, bounce, vel.z); + } + + entity.setDeltaMovement(vel); + } + + @Override + public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) { + + if (entity.isSuppressingBounce()) { + super.fallOn(level, state, pos, entity, fallDistance); + } else { + entity.resetFallDistance(); + } + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/ConveyorBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/ConveyorBlock.java new file mode 100644 index 00000000..43a5855f --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/ConveyorBlock.java @@ -0,0 +1,36 @@ +package com.box3lab.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; + +public class ConveyorBlock extends VoxelBlock { + + public ConveyorBlock(BlockBehaviour.Properties properties) { + super(properties); + } + + @Override + public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { + super.stepOn(level, pos, state, entity); + + Direction facing = state.getValue(HORIZONTAL_FACING); + double speed = 0.06D; + + Vec3 vel = entity.getDeltaMovement(); + switch (facing) { + case NORTH -> vel = new Vec3(vel.x, vel.y, vel.z - speed); + case SOUTH -> vel = new Vec3(vel.x, vel.y, vel.z + speed); + case WEST -> vel = new Vec3(vel.x - speed, vel.y, vel.z); + case EAST -> vel = new Vec3(vel.x + speed, vel.y, vel.z); + default -> { } + } + + entity.setDeltaMovement(vel); + + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/GlassVoxelBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/GlassVoxelBlock.java new file mode 100644 index 00000000..9c03be1d --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/GlassVoxelBlock.java @@ -0,0 +1,20 @@ +package com.box3lab.block; + +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; + +public class GlassVoxelBlock extends VoxelBlock { + + public GlassVoxelBlock(BlockBehaviour.Properties properties) { + super(properties); + } + + @Override + public boolean skipRendering(BlockState state, BlockState adjacentState, Direction side) { + if (adjacentState.getBlock() == state.getBlock()) { + return true; + } + return super.skipRendering(state, adjacentState, side); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/SpiderWebBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/SpiderWebBlock.java new file mode 100644 index 00000000..1b1e1d75 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/SpiderWebBlock.java @@ -0,0 +1,35 @@ +package com.box3lab.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; + +public class SpiderWebBlock extends VoxelBlock { + + public SpiderWebBlock(BlockBehaviour.Properties properties) { + super(properties); + } + + @Override + public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { + super.stepOn(level, pos, state, entity); + + if (entity instanceof LivingEntity) { + LivingEntity living = (LivingEntity) entity; + + + boolean isSprinting = living.isSprinting(); + + if (isSprinting) { + Vec3 movement = living.getDeltaMovement(); + living.setDeltaMovement(movement.multiply(0.15, 1.0, 0.15)); + } else { + living.setDeltaMovement(Vec3.ZERO); + } + } + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/VoxelBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/VoxelBlock.java new file mode 100644 index 00000000..66c1886f --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/VoxelBlock.java @@ -0,0 +1,49 @@ +package com.box3lab.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.EnumProperty; + +public class VoxelBlock extends Block { + public static final EnumProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; + + public VoxelBlock(BlockBehaviour.Properties properties) { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH)); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(HORIZONTAL_FACING); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite()); + } + + @Override + public BlockState rotate(BlockState state, Rotation rotation) { + return state.setValue(HORIZONTAL_FACING, rotation.rotate(state.getValue(HORIZONTAL_FACING))); + } + + @Override + public BlockState mirror(BlockState state, Mirror mirror) { + return state.rotate(mirror.getRotation(state.getValue(HORIZONTAL_FACING))); + } + + @Override + public boolean isCollisionShapeFullBlock(BlockState state, BlockGetter level, BlockPos pos) { + return super.isCollisionShapeFullBlock(state, level, pos); + } + +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelBlockEntity.java b/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelBlockEntity.java new file mode 100644 index 00000000..4ab3efa7 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelBlockEntity.java @@ -0,0 +1,276 @@ +package com.box3lab.block.entity; + +import java.util.Locale; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import com.box3lab.register.modelbe.PackModelBlockEntityRegistrar; + +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.Component; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.permissions.PermissionSet; +import net.minecraft.world.entity.Display; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityTypes; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.ValueInput; +import net.minecraft.world.level.storage.ValueOutput; +import net.minecraft.world.phys.AABB; + +public class PackModelBlockEntity extends BlockEntity { + private static final long RESPAWN_INTERVAL_TICKS = 20L; + private static final String DISPLAY_TAG_PREFIX = "box3_pack_model:"; + + private static final float SCALE_STEP = 0.1F; + private static final float SCALE_MIN = 0.1F; + private static final float SCALE_MAX = 4.0F; + private static final float OFFSET_STEP = 0.05F; + private static final float ROTATION_STEP = 15.0F; + private static final Map CONFIG_CLIPBOARD = new ConcurrentHashMap<>(); + + private float scale = 1.0F; + private float offsetX = 0.0F; + private float offsetY = 0.0F; + private float offsetZ = 0.0F; + private float rotationOffset = 0.0F; + private int modeIndex = 0; + + public PackModelBlockEntity(BlockPos pos, BlockState state) { + super(PackModelBlockEntityRegistrar.typeFor(state.getBlock()), pos, state); + } + + @Override + protected void loadAdditional(ValueInput input) { + super.loadAdditional(input); + this.scale = clamp(input.getFloatOr("scale", 1.0F), SCALE_MIN, SCALE_MAX); + this.offsetX = input.getFloatOr("offset_x", 0.0F); + this.offsetY = input.getFloatOr("offset_y", 0.0F); + this.offsetZ = input.getFloatOr("offset_z", 0.0F); + this.rotationOffset = input.getFloatOr("rotation_offset", 0.0F); + this.modeIndex = Math.floorMod(input.getIntOr("config_mode", 0), Mode.values().length); + } + + @Override + protected void saveAdditional(ValueOutput output) { + super.saveAdditional(output); + output.putFloat("scale", this.scale); + output.putFloat("offset_x", this.offsetX); + output.putFloat("offset_y", this.offsetY); + output.putFloat("offset_z", this.offsetZ); + output.putFloat("rotation_offset", this.rotationOffset); + output.putInt("config_mode", this.modeIndex); + } + + @Override + public void setRemoved() { + removeDisplaysAt(this.level, this.getBlockPos()); + super.setRemoved(); + } + + public static void serverTick(Level level, BlockPos pos, BlockState state, PackModelBlockEntity blockEntity) { + if (!(level instanceof ServerLevel serverLevel)) { + return; + } + + String tag = displayTag(pos); + var displays = findDisplays(serverLevel, pos, tag); + + if (displays.isEmpty()) { + if (serverLevel.getGameTime() % RESPAWN_INTERVAL_TICKS != 0) { + return; + } + spawnDisplay(serverLevel, pos, state, blockEntity, tag); + return; + } + + for (Display.ItemDisplay display : displays) { + blockEntity.applyPose(serverLevel, pos, state, display); + } + } + + public void cycleMode(net.minecraft.world.entity.player.Player player) { + this.modeIndex = (this.modeIndex + 1) % Mode.values().length; + this.setChanged(); + player.sendSystemMessage(Component.translatable( + "message.box3.model.config.mode", + Component.translatable(currentMode().translationKey()))); + } + + public void adjustCurrentMode(ServerLevel level, BlockPos pos, BlockState state, int direction, + net.minecraft.world.entity.player.Player player) { + Mode mode = currentMode(); + switch (mode) { + case SCALE -> this.scale = clamp(this.scale + SCALE_STEP * direction, SCALE_MIN, SCALE_MAX); + case OFFSET_X -> this.offsetX += OFFSET_STEP * direction; + case OFFSET_Y -> this.offsetY += OFFSET_STEP * direction; + case OFFSET_Z -> this.offsetZ += OFFSET_STEP * direction; + case ROTATION -> this.rotationOffset = normalizeDegrees(this.rotationOffset + ROTATION_STEP * direction); + } + + this.setChanged(); + player.sendSystemMessage(statusComponent()); + applyToDisplays(level, pos, state); + } + + public void copyConfig(net.minecraft.world.entity.player.Player player) { + CONFIG_CLIPBOARD.put(player.getUUID(), + new ConfigSnapshot(this.scale, this.offsetX, this.offsetY, this.offsetZ, this.rotationOffset)); + player.sendSystemMessage(Component.translatable("message.box3.model.config.copy.success")); + } + + public void pasteConfig(ServerLevel level, BlockPos pos, BlockState state, + net.minecraft.world.entity.player.Player player) { + ConfigSnapshot snapshot = CONFIG_CLIPBOARD.get(player.getUUID()); + if (snapshot == null) { + player.sendSystemMessage(Component.translatable("message.box3.model.config.copy.empty")); + return; + } + + this.scale = clamp(snapshot.scale, SCALE_MIN, SCALE_MAX); + this.offsetX = snapshot.offsetX; + this.offsetY = snapshot.offsetY; + this.offsetZ = snapshot.offsetZ; + this.rotationOffset = normalizeDegrees(snapshot.rotationOffset); + this.setChanged(); + + applyToDisplays(level, pos, state); + player.sendSystemMessage(Component.translatable("message.box3.model.config.copy.pasted")); + player.sendSystemMessage(statusComponent()); + } + + public static void removeDisplaysAt(Level level, BlockPos pos) { + if (!(level instanceof ServerLevel serverLevel)) { + return; + } + + String tag = displayTag(pos); + for (Display.ItemDisplay display : findDisplays(serverLevel, pos, tag)) { + display.discard(); + display.setCustomName(null); + } + } + + private static void spawnDisplay(ServerLevel level, BlockPos pos, BlockState state, PackModelBlockEntity be, + String tag) { + Display.ItemDisplay display = EntityTypes.ITEM_DISPLAY.create(level, EntitySpawnReason.SPAWN_ITEM_USE); + if (display == null) { + return; + } + + display.setNoGravity(true); + display.setInvulnerable(true); + display.getSlot(0).set(new ItemStack(state.getBlock())); + display.setCustomName(Component.literal(tag)); + display.setCustomNameVisible(false); + + be.applyPose(level, pos, state, display); + level.addFreshEntity(display); + } + + private void applyPose(ServerLevel level, BlockPos pos, BlockState state, Display.ItemDisplay display) { + double x = pos.getX() + 0.5D; + double y = pos.getY() + this.offsetY; + double z = pos.getZ() + 0.5D; + display.setPos(x, y, z); + + float baseYaw = 0.0F; + if (state.hasProperty(PackModelEntityBlock.HORIZONTAL_FACING)) { + Direction facing = state.getValue(PackModelEntityBlock.HORIZONTAL_FACING); + baseYaw = facing.toYRot(); + } + display.setYRot(normalizeDegrees(baseYaw + this.rotationOffset)); + + applyDisplayTransformation(level, display); + } + + private void applyDisplayTransformation(ServerLevel level, Display.ItemDisplay display) { + MinecraftServer server = level.getServer(); + CommandSourceStack source = server.createCommandSourceStack().withSuppressedOutput() + .withPermission(PermissionSet.ALL_PERMISSIONS); + + String cmd = String.format( + Locale.ROOT, + "data merge entity %s {item_display:\"fixed\",transformation:{translation:[%sf,%sf,%sf],left_rotation:[0f,0f,0f,1f],scale:[%sf,%sf,%sf],right_rotation:[0f,0f,0f,1f]}}", + display.getStringUUID(), + fmt(this.offsetX), fmt(0.0F), fmt(this.offsetZ), + fmt(this.scale), fmt(this.scale), fmt(this.scale)); + server.getCommands().performPrefixedCommand(source, cmd); + } + + private static String fmt(float value) { + return String.format(Locale.ROOT, "%.3f", value); + } + + private static java.util.List findDisplays(ServerLevel level, BlockPos pos, String tag) { + return level.getEntitiesOfClass( + Display.ItemDisplay.class, + new AABB(pos).inflate(0.25D), + display -> { + Component name = display.getCustomName(); + return name != null && tag.equals(name.getString()); + }); + } + + private void applyToDisplays(ServerLevel level, BlockPos pos, BlockState state) { + for (Display.ItemDisplay display : findDisplays(level, pos, displayTag(pos))) { + applyPose(level, pos, state, display); + } + } + + private Mode currentMode() { + return Mode.values()[this.modeIndex]; + } + + private Component statusComponent() { + return Component.translatable( + "message.box3.model.config.status", + Component.translatable(currentMode().translationKey()), + String.format(Locale.ROOT, "%.2f", this.scale), + String.format(Locale.ROOT, "%.2f", this.offsetX), + String.format(Locale.ROOT, "%.2f", this.offsetY), + String.format(Locale.ROOT, "%.2f", this.offsetZ), + String.format(Locale.ROOT, "%.1f", this.rotationOffset)); + } + + private static float clamp(float value, float min, float max) { + return Math.max(min, Math.min(max, value)); + } + + private static float normalizeDegrees(float value) { + float v = value % 360.0F; + return v < 0.0F ? v + 360.0F : v; + } + + private static String displayTag(BlockPos pos) { + return DISPLAY_TAG_PREFIX + pos.asLong(); + } + + private enum Mode { + SCALE("scale"), + OFFSET_X("offset_x"), + OFFSET_Y("offset_y"), + OFFSET_Z("offset_z"), + ROTATION("rotation"); + + private final String keyPart; + + Mode(String keyPart) { + this.keyPart = keyPart; + } + + public String translationKey() { + return "message.box3.model.config.mode." + this.keyPart; + } + } + + private record ConfigSnapshot(float scale, float offsetX, float offsetY, float offsetZ, float rotationOffset) { + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelEntityBlock.java b/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelEntityBlock.java new file mode 100644 index 00000000..bd449cad --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/block/entity/PackModelEntityBlock.java @@ -0,0 +1,156 @@ +package com.box3lab.block.entity; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.phys.BlockHitResult; +import org.jspecify.annotations.Nullable; + +public class PackModelEntityBlock extends Block implements EntityBlock { + public static final EnumProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; + + public PackModelEntityBlock(BlockBehaviour.Properties properties) { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(HORIZONTAL_FACING, Direction.NORTH)); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new PackModelBlockEntity(pos, state); + } + + @Override + protected RenderShape getRenderShape(BlockState state) { + return RenderShape.INVISIBLE; + } + + @Override + protected void spawnDestroyParticles(Level level, Player player, BlockPos pos, BlockState state) { + // This block is rendered by ItemDisplay instead of block model, + // so vanilla block-break particles would resolve to missing textures. + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(HORIZONTAL_FACING); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite()); + } + + @Override + public BlockState rotate(BlockState state, Rotation rotation) { + return state.setValue(HORIZONTAL_FACING, rotation.rotate(state.getValue(HORIZONTAL_FACING))); + } + + @Override + public BlockState mirror(BlockState state, Mirror mirror) { + return state.rotate(mirror.getRotation(state.getValue(HORIZONTAL_FACING))); + } + + @Override + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, + BlockHitResult hitResult) { + if (level.isClientSide()) { + return InteractionResult.SUCCESS; + } + + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof PackModelBlockEntity modelBe) { + modelBe.cycleMode(player); + return InteractionResult.SUCCESS; + } + return InteractionResult.PASS; + } + + @Override + protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, + InteractionHand hand, BlockHitResult hitResult) { + if (stack.is(Items.PAPER)) { + if (level.isClientSide()) { + return InteractionResult.SUCCESS; + } + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof PackModelBlockEntity modelBe) { + modelBe.copyConfig(player); + return InteractionResult.SUCCESS; + } + return InteractionResult.PASS; + } + + if (stack.is(Items.BOOK)) { + if (level.isClientSide()) { + return InteractionResult.SUCCESS; + } + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof PackModelBlockEntity modelBe && level instanceof net.minecraft.server.level.ServerLevel serverLevel) { + modelBe.pasteConfig(serverLevel, pos, state, player); + return InteractionResult.SUCCESS; + } + return InteractionResult.PASS; + } + + int direction; + if (stack.is(Items.STICK)) { + direction = 1; + } else if (stack.is(Items.BLAZE_ROD)) { + direction = -1; + } else { + return InteractionResult.TRY_WITH_EMPTY_HAND; + } + + if (level.isClientSide()) { + return InteractionResult.SUCCESS; + } + + BlockEntity blockEntity = level.getBlockEntity(pos); + if (blockEntity instanceof PackModelBlockEntity modelBe && level instanceof net.minecraft.server.level.ServerLevel serverLevel) { + modelBe.adjustCurrentMode(serverLevel, pos, state, direction, player); + return InteractionResult.SUCCESS; + } + + return InteractionResult.PASS; + } + + @Nullable + @Override + @SuppressWarnings("unchecked") + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { + if (level.isClientSide()) { + return null; + } + + BlockEntityType expectedType = com.box3lab.register.modelbe.PackModelBlockEntityRegistrar.typeFor(state.getBlock()); + if (blockEntityType != expectedType) { + return null; + } + + return (lvl, pos, blockState, be) -> PackModelBlockEntity.serverTick( + lvl, + pos, + blockState, + (PackModelBlockEntity) be); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/command/ModCommands.java b/Fabric-26.2/src/main/java/com/box3lab/command/ModCommands.java new file mode 100644 index 00000000..d41febaf --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/command/ModCommands.java @@ -0,0 +1,388 @@ +package com.box3lab.command; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.box3lab.block.BarrierVoxelBlock; +import com.box3lab.register.VoxelExport; +import com.box3lab.register.VoxelImport; +import com.box3lab.util.Box3ImportFiles; +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.suggestion.SuggestionProvider; + +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.minecraft.commands.CommandSourceStack; +import static net.minecraft.commands.Commands.argument; +import static net.minecraft.commands.Commands.literal; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.Identifier; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.phys.Vec3; + +public final class ModCommands { + private ModCommands() { + } + + private static final String DEFAULT_EXPORT_MARKER_BLOCK = "minecraft:redstone_block"; + private static final int MAX_MARKER_SCAN_RADIUS = 1024; + private static final int MARKER_Y_TOLERANCE = 512; + + private static final SuggestionProvider BOX3_FILE_SUGGESTIONS = (context, builder) -> { + try { + List files = Box3ImportFiles.listJsonFiles(); + for (String file : files) { + String name = file; + if (name.endsWith(".gz")) { + name = name.substring(0, name.length() - 3); + } + builder.suggest(name); + } + } catch (IOException ignored) { + + } + return builder.buildFuture(); + }; + + public static void register() { + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { + dispatcher.register( + literal("box3import") + .executes(context -> listBox3ImportFiles(context.getSource())) + .then(argument("fileName", StringArgumentType.word()) + .suggests(BOX3_FILE_SUGGESTIONS) + // /box3import + .executes(context -> executeBox3Import( + context.getSource(), + StringArgumentType.getString( + context, + "fileName"), + 0, + false, + false)) + // /box3import + .then(argument("offsetY", + IntegerArgumentType.integer()) + .executes(context -> executeBox3Import( + context.getSource(), + StringArgumentType + .getString( + context, + "fileName"), + IntegerArgumentType + .getInteger( + context, + "offsetY"), + false, + false)) + // /box3import + // + .then(argument("ignoreBarrier", + BoolArgumentType.bool()) + .executes(context -> executeBox3Import( + context.getSource(), + StringArgumentType + .getString( + context, + "fileName"), + IntegerArgumentType + .getInteger( + context, + "offsetY"), + BoolArgumentType.getBool( + context, + "ignoreBarrier"), + false)) + // /box3import + // + // + // + // + .then(argument("ignoreWater", + BoolArgumentType.bool()) + .executes(context -> executeBox3Import( + context.getSource(), + StringArgumentType + .getString( + context, + "fileName"), + IntegerArgumentType + .getInteger( + context, + "offsetY"), + BoolArgumentType.getBool( + context, + "ignoreBarrier"), + BoolArgumentType.getBool( + context, + "ignoreWater")))))))); + + dispatcher.register( + literal("box3barrier") + .executes(context -> showBarrierStatus(context.getSource())) + .then(argument("value", BoolArgumentType.bool()) + .executes(context -> setBarrierVisible( + context.getSource(), + BoolArgumentType.getBool( + context, + "value"))) + .then(literal("toggle") + .executes(context -> toggleBarrierVisible( + context.getSource()))))); + + dispatcher.register( + literal("box3export") + .executes(context -> showBox3ExportUsage(context.getSource())) + .then(argument("fileName", StringArgumentType.word()) + .executes(context -> executeBox3ExportByMarkers( + context.getSource(), + StringArgumentType.getString( + context, + "fileName"))))); + }); + } + + private static int listBox3ImportFiles(CommandSourceStack source) { + var dir = Box3ImportFiles.getImportDir(); + + try { + List files = Box3ImportFiles.listJsonFiles(); + + if (files.isEmpty()) { + source.sendSuccess( + () -> Component.translatable( + "command.box3.box3import.list.empty", + dir.toString()), + false); + } else { + String joined = String.join(", ", files); + source.sendSuccess( + () -> Component.translatable( + "command.box3.box3import.list.success", + dir.toString(), joined), + false); + } + } catch (IOException e) { + source.sendFailure( + Component.translatable( + "command.box3.box3import.list.error", + dir.toString(), e.getMessage())); + } + + return 1; + } + + private static int showBox3ExportUsage(CommandSourceStack source) { + source.sendFailure(Component.translatable("command.box3.box3export.usage")); + return 0; + } + + private static String resolveMapName(String fileName) { + if (fileName != null && fileName.startsWith("Box3-")) { + String suffix = fileName.substring("Box3-".length()); + if (!suffix.isEmpty()) { + return "https://box3lab.com/mc/build/" + suffix + ".gz"; + } + } + return fileName; + } + + private static int executeBox3Import(CommandSourceStack source, String fileName, + int offsetY, boolean ignoreBarrier, boolean useVanillaWater) { + ServerLevel level = source.getServer().overworld(); + try { + ServerPlayer player = source.getPlayer(); + String mapName = resolveMapName(fileName); + var basePos = player != null ? player.position() : Vec3.atCenterOf(new BlockPos(0, 0, 0)); + var offsetPos = basePos.add(0, offsetY, 0); + + VoxelImport.apply(null, level, mapName, + offsetPos, + player, + ignoreBarrier, + useVanillaWater); + + source.sendSuccess( + () -> Component.translatable("command.box3.box3import.success", + mapName), + false); + } catch (Exception e) { + source.sendFailure( + Component.translatable("command.box3.box3import.failure", e.getMessage())); + } + return 1; + } + + private static int showBarrierStatus(CommandSourceStack source) { + boolean visible = BarrierVoxelBlock.isVisible(); + source.sendSuccess( + () -> Component.translatable("command.box3.box3barrier.status", + String.valueOf(visible)), + false); + return 1; + } + + private static int setBarrierVisible(CommandSourceStack source, boolean value) { + BarrierVoxelBlock.setVisible(value); + source.sendSuccess( + () -> Component.translatable("command.box3.box3barrier.set", String.valueOf(value)), + false); + return 1; + } + + private static int toggleBarrierVisible(CommandSourceStack source) { + boolean current = BarrierVoxelBlock.isVisible(); + boolean next = !current; + BarrierVoxelBlock.setVisible(next); + source.sendSuccess( + () -> Component.translatable("command.box3.box3barrier.toggled", + String.valueOf(next)), + false); + return 1; + } + + private static int executeBox3Export(CommandSourceStack source, String fileName, + int x1, int y1, int z1, int x2, int y2, int z2) { + ServerLevel level = source.getLevel(); + BlockPos from = new BlockPos(x1, y1, z1); + BlockPos to = new BlockPos(x2, y2, z2); + + try { + VoxelExport.ExportResult result = VoxelExport.exportRegion(level, from, to, fileName); + source.sendSuccess( + () -> Component.translatable( + "command.box3.box3export.success", + result.output().toString(), + result.scannedBlocks(), + result.exportedBlocks()), + false); + } catch (Exception e) { + source.sendFailure( + Component.translatable("command.box3.box3export.failure", e.getMessage())); + } + return 1; + } + + private static int executeBox3ExportByMarkers(CommandSourceStack source, String fileName) { + ServerPlayer player = source.getPlayer(); + if (player == null) { + source.sendFailure(Component.translatable("command.box3.box3export.player_only")); + return 0; + } + + Block markerBlock = resolveMarkerBlock(DEFAULT_EXPORT_MARKER_BLOCK); + if (markerBlock == null) { + source.sendFailure(Component.translatable("command.box3.box3export.marker_invalid", + DEFAULT_EXPORT_MARKER_BLOCK)); + return 0; + } + + List positions = findMarkerPositions(source.getLevel(), player.blockPosition(), markerBlock, + MAX_MARKER_SCAN_RADIUS, MARKER_Y_TOLERANCE, 2); + if (positions.size() < 2) { + source.sendFailure(Component.translatable( + "command.box3.box3export.marker_count_invalid", + MAX_MARKER_SCAN_RADIUS, + positions.size(), + BuiltInRegistries.BLOCK.getKey(markerBlock).toString())); + return 0; + } + + BlockPos p1 = positions.get(0); + BlockPos p2 = positions.get(1); + return executeBox3Export(source, fileName, p1.getX(), p1.getY(), p1.getZ(), p2.getX(), p2.getY(), + p2.getZ()); + } + + private static Block resolveMarkerBlock(String blockId) { + Identifier id = Identifier.tryParse(blockId); + if (id == null) { + return null; + } + if (!BuiltInRegistries.BLOCK.containsKey(id)) { + return null; + } + return BuiltInRegistries.BLOCK.get(id).map(holder -> holder.value()).orElse(null); + } + + private static List findMarkerPositions(ServerLevel level, BlockPos center, Block markerBlock, + int maxRadius, int yTolerance, int maxResults) { + List positions = new ArrayList<>(); + BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos(); + int cx = center.getX(); + int cy = center.getY(); + int cz = center.getZ(); + + for (int radius = 0; radius <= maxRadius; radius++) { + int minX = cx - radius; + int maxX = cx + radius; + int minZ = cz - radius; + int maxZ = cz + radius; + + if (radius == 0) { + if (scanMarkerColumn(level, markerBlock, cy, yTolerance, cx, cz, cursor, positions, + maxResults)) { + return positions; + } + continue; + } + + for (int x = minX; x <= maxX; x++) { + if (scanMarkerColumn(level, markerBlock, cy, yTolerance, x, minZ, cursor, positions, + maxResults)) { + return positions; + } + if (scanMarkerColumn(level, markerBlock, cy, yTolerance, x, maxZ, cursor, positions, + maxResults)) { + return positions; + } + } + + for (int z = minZ + 1; z <= maxZ - 1; z++) { + if (scanMarkerColumn(level, markerBlock, cy, yTolerance, minX, z, cursor, positions, + maxResults)) { + return positions; + } + if (scanMarkerColumn(level, markerBlock, cy, yTolerance, maxX, z, cursor, positions, + maxResults)) { + return positions; + } + } + } + return positions; + } + + private static boolean scanMarkerColumn(ServerLevel level, Block markerBlock, int centerY, int yTolerance, int x, int z, + BlockPos.MutableBlockPos cursor, List positions, int maxResults) { + for (int dy = 0; dy <= yTolerance; dy++) { + int y1 = centerY + dy; + cursor.set(x, y1, z); + if (level.hasChunkAt(cursor) && level.getBlockState(cursor).getBlock() == markerBlock) { + positions.add(cursor.immutable()); + if (positions.size() >= maxResults) { + return true; + } + } + + if (dy == 0) { + continue; + } + + int y2 = centerY - dy; + cursor.set(x, y2, z); + if (level.hasChunkAt(cursor) && level.getBlockState(cursor).getBlock() == markerBlock) { + positions.add(cursor.immutable()); + if (positions.size() >= maxResults) { + return true; + } + } + } + return false; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/ModBlocks.java b/Fabric-26.2/src/main/java/com/box3lab/register/ModBlocks.java new file mode 100644 index 00000000..2853bc1b --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/ModBlocks.java @@ -0,0 +1,69 @@ +package com.box3lab.register; + +import java.util.HashMap; +import java.util.Map; + +import com.box3lab.Box3; +import com.box3lab.register.core.BlockRegistrar; +import com.box3lab.register.creative.CreativeTabRegistrar; +import com.box3lab.register.modelbe.PackModelBlockEntityRegistrar; +import com.box3lab.register.sound.CategorySoundTypes; +import com.box3lab.register.voxel.VoxelBlockFactories; +import com.box3lab.register.voxel.VoxelBlockPropertiesFactory; +import com.box3lab.register.voxel.VoxelLightLevelMapper; +import com.box3lab.util.BlockIndexData; +import com.box3lab.util.BlockIndexUtil; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; + +public class ModBlocks { + public static final Map BLOCKS = new HashMap<>(); + + public static void initialize() { + + BlockIndexData data = BlockIndexData.get(); + + for (int i = 0; i < data.ids.length; i++) { + int id = data.ids[i]; + if (id == 0) { + continue; + } + if (BlockIndexUtil.isFluid(id)) { + continue; + } + + String voxelName = data.names[i]; + String texturePart = voxelName.toLowerCase(java.util.Locale.ROOT); + + String category = data.categoryByName.getOrDefault(texturePart, ""); + SoundType soundType = CategorySoundTypes.soundTypeForCategory(category); + + int emissive = BlockIndexUtil.blockEmissiveLight(id); + final int lightLevel = VoxelLightLevelMapper.lightLevelFromEmissivePacked(emissive); + + boolean solid = BlockIndexUtil.isSolid(id); + boolean transparent = !solid; + + int index = data.indexById.get(id); + float hardness = data.blockHardness[index]; + float resistance = data.blockResistance[index]; + float friction = data.blockFriction[index]; + + var props = VoxelBlockPropertiesFactory.create(solid, soundType, lightLevel, hardness, resistance, + friction); + + Block block = BlockRegistrar.register( + Box3.MOD_ID, + texturePart, + VoxelBlockFactories.factoryFor(texturePart, transparent), + props, + true); + BLOCKS.put(texturePart, block); + } + + CreativeTabRegistrar.registerCreativeTabs(Box3.MOD_ID, BLOCKS, data); + PackModelBlockEntityRegistrar.registerAll(); + } + +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/ModItems.java b/Fabric-26.2/src/main/java/com/box3lab/register/ModItems.java new file mode 100644 index 00000000..f8f2634c --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/ModItems.java @@ -0,0 +1,11 @@ +package com.box3lab.register; + +public final class ModItems { + + private ModItems() { + } + + public static void initialize() { + // Reserved for future item registrations. + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/VoxelExport.java b/Fabric-26.2/src/main/java/com/box3lab/register/VoxelExport.java new file mode 100644 index 00000000..68735942 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/VoxelExport.java @@ -0,0 +1,148 @@ +package com.box3lab.register; + +import static com.box3lab.Box3.MOD_ID; + +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPOutputStream; + +import com.box3lab.util.BlockIdResolver; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public final class VoxelExport { + + private VoxelExport() { + } + + public static ExportResult exportRegion(ServerLevel level, BlockPos from, BlockPos to, String fileName) throws IOException { + BlockPos min = new BlockPos( + Math.min(from.getX(), to.getX()), + Math.min(from.getY(), to.getY()), + Math.min(from.getZ(), to.getZ())); + BlockPos max = new BlockPos( + Math.max(from.getX(), to.getX()), + Math.max(from.getY(), to.getY()), + Math.max(from.getZ(), to.getZ())); + + int sizeX = max.getX() - min.getX() + 1; + int sizeY = max.getY() - min.getY() + 1; + int sizeZ = max.getZ() - min.getZ() + 1; + + List indices = new ArrayList<>(); + List data = new ArrayList<>(); + List rot = new ArrayList<>(); + + for (int z = 0; z < sizeZ; z++) { + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + BlockPos pos = min.offset(x, y, z); + BlockState state = level.getBlockState(pos); + int id = BlockIdResolver.getIdByBlock(state.getBlock()); + if (id == 0) { + continue; + } + + int idx = x + y * sizeX + z * sizeX * sizeY; + indices.add(idx); + data.add(id); + rot.add(toRotationIndex(state)); + } + } + } + + JsonObject root = new JsonObject(); + root.add("shape", intArray(sizeX, sizeY, sizeZ)); + root.add("dir", intArray(1, 1, 1)); + root.add("indices", toJsonArray(indices)); + root.add("data", toJsonArray(data)); + root.add("rot", toJsonArray(rot)); + + Path output = resolveOutput(fileName); + Files.createDirectories(output.getParent()); + writeGzipJson(output, root.toString()); + + return new ExportResult(output, sizeX * sizeY * sizeZ, indices.size()); + } + + private static int toRotationIndex(BlockState state) { + Direction dir = null; + if (state.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) { + dir = state.getValue(BlockStateProperties.HORIZONTAL_FACING); + } else if (state.hasProperty(BlockStateProperties.FACING)) { + Direction facing = state.getValue(BlockStateProperties.FACING); + if (facing.getAxis().isHorizontal()) { + dir = facing; + } + } + + if (dir == null) { + return 0; + } + + Rotation rotation = switch (dir) { + case EAST -> Rotation.CLOCKWISE_90; + case SOUTH -> Rotation.CLOCKWISE_180; + case WEST -> Rotation.COUNTERCLOCKWISE_90; + default -> Rotation.NONE; + }; + + return switch (rotation) { + case CLOCKWISE_90 -> 1; + case CLOCKWISE_180 -> 2; + case COUNTERCLOCKWISE_90 -> 3; + default -> 0; + }; + } + + private static JsonArray intArray(int a, int b, int c) { + JsonArray array = new JsonArray(); + array.add(a); + array.add(b); + array.add(c); + return array; + } + + private static JsonArray toJsonArray(List values) { + JsonArray array = new JsonArray(); + for (Integer value : values) { + array.add(value); + } + return array; + } + + private static Path resolveOutput(String fileName) { + String cleaned = (fileName == null || fileName.isBlank()) ? "export" : fileName.trim(); + if (!cleaned.endsWith(".gz")) { + cleaned = cleaned + ".gz"; + } + return FabricLoader.getInstance() + .getConfigDir() + .resolve(MOD_ID) + .resolve(cleaned); + } + + private static void writeGzipJson(Path outputPath, String json) throws IOException { + try (OutputStream fos = Files.newOutputStream(outputPath); + GZIPOutputStream gos = new GZIPOutputStream(fos)) { + gos.write(json.getBytes(StandardCharsets.UTF_8)); + gos.finish(); + } + } + + public record ExportResult(Path output, int scannedBlocks, int exportedBlocks) { + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/VoxelImport.java b/Fabric-26.2/src/main/java/com/box3lab/register/VoxelImport.java new file mode 100644 index 00000000..a95ce28e --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/VoxelImport.java @@ -0,0 +1,178 @@ +package com.box3lab.register; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.zip.GZIPInputStream; + +import static com.box3lab.Box3.MOD_ID; +import com.box3lab.util.BlockIdResolver; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.phys.Vec3; + +public final class VoxelImport { + + public static void apply(Object voxels, Object world, String mapName, Vec3 customOrigin, + ServerPlayer player, boolean ignoreBarrier, boolean ignoreWater) throws Exception { + JsonObject cfg = loadConfig(mapName); + if (cfg == null) { + throw new Exception(Component + .translatable("command.box3.box3import.config_invalid") + .getString()); + } + + int[] shape = toIntArray(cfg.getAsJsonArray("shape")); + int[] dir = toIntArray(cfg.getAsJsonArray("dir")); + int[] indices = toIntArray(cfg.getAsJsonArray("indices")); + int[] data = toIntArray(cfg.getAsJsonArray("data")); + int[] rot = toIntArray(cfg.getAsJsonArray("rot")); + + int total = Math.min(indices.length, data.length); + int lastProgress = -1; + + int[] origin = new int[] { + (int) Math.floor(customOrigin.x), + (int) Math.floor(customOrigin.y), + (int) Math.floor(customOrigin.z) + }; + + for (int i = 0; i < indices.length && i < data.length; i++) { + int idx = indices[i]; + int id = data[i]; + + if (ignoreBarrier && BlockIdResolver.isBarrierId(id)) { + continue; + } + + int x = idx % shape[0]; + int y = (idx / shape[0]) % shape[1]; + int z = idx / (shape[0] * shape[1]); + int r = rot.length > i ? rot[i] : 0; + int wx = origin[0] + dir[0] * x; + int wy = origin[1] + dir[1] * y; + int wz = origin[2] + dir[2] * z; + + if (world instanceof ServerLevel level) { + BlockPos pos = new BlockPos(wx, wy, wz); + Block block = BlockIdResolver.getBlockById(id, ignoreWater); + Rotation rotation = switch (r & 3) { + case 1 -> Rotation.CLOCKWISE_90; + case 2 -> Rotation.CLOCKWISE_180; + case 3 -> Rotation.COUNTERCLOCKWISE_90; + default -> Rotation.NONE; + }; + + level.setBlock(pos, block.defaultBlockState().rotate(rotation), 3); + + if (player != null) { + int progress = (i + 1) * 100 / total; + if (progress / 10 > lastProgress / 10) { + lastProgress = progress; + player.sendSystemMessage(Component.translatable( + "command.box3.box3import.progress", mapName, progress)); + } + } + } + } + } + + private static JsonObject loadConfig(String mapName) { + if (mapName.startsWith("http://") || mapName.startsWith("https://")) { + try { + String json = readGzipJsonFromUrl(mapName); + return JsonParser.parseString(json).getAsJsonObject(); + } catch (IOException | JsonParseException e) { + System.err.println(Component + .translatable("command.box3.box3import.config_read_failed", mapName) + .getString()); + return null; + } + } + + // 否则仍然从本地 config 目录读取 + Path configPath = FabricLoader.getInstance() + .getConfigDir() + .resolve(MOD_ID) + .resolve(mapName.endsWith(".gz") ? mapName : mapName + ".gz"); + + if (!Files.exists(configPath)) { + System.err.println(Component + .translatable("command.box3.box3import.config_missing", configPath.toString()) + .getString()); + return null; + } + + try { + String json = readGzipJson(configPath.toString()); + return JsonParser.parseString(json).getAsJsonObject(); + } catch (IOException | JsonParseException e) { + System.err.println(Component + .translatable("command.box3.box3import.config_read_failed", configPath.toString()) + .getString()); + return null; + } + } + + private static String readGzipJson(String path) throws IOException { + try (FileInputStream fis = new FileInputStream(path); + GZIPInputStream gis = new GZIPInputStream(fis); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + + byte[] buffer = new byte[8192]; + int n; + while ((n = gis.read(buffer)) > 0) { + baos.write(buffer, 0, n); + } + return baos.toString(StandardCharsets.UTF_8); + } + } + + private static String readGzipJsonFromUrl(String urlString) throws IOException { + URI uri = URI.create(urlString); + URL url = uri.toURL(); + URLConnection connection = url.openConnection(); + connection.setConnectTimeout(10_000); + connection.setReadTimeout(30_000); + + try (InputStream is = connection.getInputStream(); + GZIPInputStream gis = new GZIPInputStream(is); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + + byte[] buffer = new byte[8192]; + int n; + while ((n = gis.read(buffer)) > 0) { + baos.write(buffer, 0, n); + } + return baos.toString(StandardCharsets.UTF_8); + } + } + + private static int[] toIntArray(JsonArray array) { + if (array == null) { + return new int[0]; + } + int[] result = new int[array.size()]; + for (int i = 0; i < array.size(); i++) { + result[i] = array.get(i).getAsInt(); + } + return result; + } +} \ No newline at end of file diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/core/BlockRegistrar.java b/Fabric-26.2/src/main/java/com/box3lab/register/core/BlockRegistrar.java new file mode 100644 index 00000000..a8659619 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/core/BlockRegistrar.java @@ -0,0 +1,31 @@ +package com.box3lab.register.core; + +import java.util.function.Function; + +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +public final class BlockRegistrar { + private BlockRegistrar() { + } + + public static Block register(String modId, String name, Function blockFactory, BlockBehaviour.Properties settings, boolean shouldRegisterItem) { + ResourceKey blockKey = ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(modId, name)); + Block block = blockFactory.apply(settings.setId(blockKey)); + + if (shouldRegisterItem) { + ResourceKey itemKey = ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(modId, name)); + BlockItem blockItem = new BlockItem(block, new Item.Properties().setId(itemKey).useBlockDescriptionPrefix()); + Registry.register(BuiltInRegistries.ITEM, itemKey, blockItem); + } + + return Registry.register(BuiltInRegistries.BLOCK, blockKey, block); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabExtras.java b/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabExtras.java new file mode 100644 index 00000000..a8f97da5 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabExtras.java @@ -0,0 +1,26 @@ +package com.box3lab.register.creative; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.world.level.ItemLike; + +public final class CreativeTabExtras { + private static final Map> EXTRAS = new HashMap<>(); + + private CreativeTabExtras() { + } + + public static void add(String categoryPath, ItemLike item) { + if (categoryPath == null || categoryPath.isBlank() || item == null) { + return; + } + EXTRAS.computeIfAbsent(categoryPath, k -> new ArrayList<>()).add(item); + } + + public static Map> extras() { + return EXTRAS; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabRegistrar.java b/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabRegistrar.java new file mode 100644 index 00000000..89c02c56 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/creative/CreativeTabRegistrar.java @@ -0,0 +1,132 @@ +package com.box3lab.register.creative; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import com.box3lab.util.BlockIndexData; + +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.ItemLike; + +public final class CreativeTabRegistrar { + public static final String DEFAULT_MODEL_TAB = "models"; + + private CreativeTabRegistrar() { + } + + private static String sanitizeCategoryPath(String category) { + if (category == null || category.isBlank()) { + return ""; + } + String lower = category.toLowerCase(Locale.ROOT); + return lower.replaceAll("[^a-z0-9_\\-]+", "_"); + } + + private static ItemStack defaultIcon(Map blocks) { + Block iconBlock = blocks.get("stone"); + if (iconBlock == null && !blocks.isEmpty()) { + iconBlock = blocks.values().iterator().next(); + } + return iconBlock == null ? new ItemStack(Items.STONE) : new ItemStack(iconBlock); + } + + public static void registerCreativeTabs(String modId, Map blocks, BlockIndexData data) { + Map> categoryToRegistryNames = new HashMap<>(); + for (String rn : blocks.keySet()) { + String voxelName = rn; + String category = data.categoryByName.getOrDefault(voxelName, ""); + String categoryPath = sanitizeCategoryPath(category); + if (categoryPath != null && !categoryPath.isBlank()) { + categoryToRegistryNames.computeIfAbsent(categoryPath, k -> new ArrayList<>()).add(rn); + } + } + + List categories = new ArrayList<>(categoryToRegistryNames.keySet()); + categories.sort(Comparator.naturalOrder()); + + int tabColumn = 0; + for (String categoryPath : categories) { + List registryNames = categoryToRegistryNames.get(categoryPath); + if (registryNames == null || registryNames.isEmpty()) { + continue; + } + registryNames.sort(Comparator.naturalOrder()); + + Block categoryIconBlock = blocks.get(registryNames.get(0)); + + ResourceKey key = ResourceKey.create( + BuiltInRegistries.CREATIVE_MODE_TAB.key(), + Identifier.fromNamespaceAndPath(modId, "creative_tab_" + categoryPath)); + CreativeModeTab tab = CreativeModeTab.builder(CreativeModeTab.Row.TOP, tabColumn++) + .icon(() -> categoryIconBlock == null ? defaultIcon(blocks) : new ItemStack(categoryIconBlock)) + .title(Component.translatable("itemGroup." + modId + "." + categoryPath)) + .displayItems((params, output) -> { + for (String rn : registryNames) { + Block b = blocks.get(rn); + if (b != null) { + output.accept(b.asItem()); + } + } + + List extras = CreativeTabExtras.extras().get(categoryPath); + if (extras != null) { + for (ItemLike extra : extras) { + if (extra != null) { + output.accept(extra); + } + } + } + }) + .build(); + + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, key, tab); + } + } + + public static void registerModelTab(String modId) { + String categoryPath = sanitizeCategoryPath(DEFAULT_MODEL_TAB); + if (categoryPath.isBlank()) { + return; + } + if (BuiltInRegistries.CREATIVE_MODE_TAB + .containsKey(Identifier.fromNamespaceAndPath(modId, "creative_tab_" + categoryPath))) { + return; + } + + List extras = CreativeTabExtras.extras().get(categoryPath); + if (extras == null || extras.isEmpty()) { + return; + } + + ItemLike iconItem = extras.get(0); + ResourceKey key = ResourceKey.create( + BuiltInRegistries.CREATIVE_MODE_TAB.key(), + Identifier.fromNamespaceAndPath(modId, "creative_tab_" + categoryPath)); + + CreativeModeTab tab = CreativeModeTab.builder(CreativeModeTab.Row.BOTTOM, 0) + .icon(() -> new ItemStack(iconItem)) + .title(Component.translatable("itemGroup." + modId + "." + categoryPath)) + .displayItems((params, output) -> { + for (ItemLike extra : extras) { + if (extra != null) { + output.accept(extra); + } + } + }) + .build(); + + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, key, tab); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/modelbe/PackModelBlockEntityRegistrar.java b/Fabric-26.2/src/main/java/com/box3lab/register/modelbe/PackModelBlockEntityRegistrar.java new file mode 100644 index 00000000..04e3625b --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/modelbe/PackModelBlockEntityRegistrar.java @@ -0,0 +1,212 @@ +package com.box3lab.register.modelbe; + +import static com.box3lab.Box3.MOD_ID; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import com.box3lab.block.entity.PackModelEntityBlock; +import com.box3lab.register.creative.CreativeTabExtras; +import com.box3lab.register.creative.CreativeTabRegistrar; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.material.MapColor; + +public final class PackModelBlockEntityRegistrar { + private static final String ASSET_PREFIX = "assets/" + MOD_ID + "/"; + + private static final Map> TYPES_BY_BLOCK = new LinkedHashMap<>(); + + private PackModelBlockEntityRegistrar() { + } + + public static void registerAll() { + Set modelNames = discoverPairedModelNames(); + if (modelNames.isEmpty()) { + return; + } + + for (String name : modelNames) { + Identifier id = Identifier.tryBuild(MOD_ID, name); + if (id == null) { + continue; + } + + ResourceKey blockKey = ResourceKey.create(Registries.BLOCK, id); + if (BuiltInRegistries.BLOCK.containsKey(blockKey)) { + continue; + } + + Block block = new PackModelEntityBlock( + BlockBehaviour.Properties.of() + .setId(blockKey) + .mapColor(MapColor.STONE) + .strength(1.5F, 6.0F) + .noOcclusion() + .isViewBlocking((state, level, pos) -> false) + .isSuffocating((state, level, pos) -> false) + .isRedstoneConductor((state, level, pos) -> false)); + Registry.register(BuiltInRegistries.BLOCK, blockKey, block); + + ResourceKey itemKey = ResourceKey.create( + Registries.ITEM, + Identifier.fromNamespaceAndPath(MOD_ID, name)); + if (!BuiltInRegistries.ITEM.containsKey(itemKey)) { + Item item = new BlockItem(block, new Item.Properties().setId(itemKey).useItemDescriptionPrefix()); + Registry.register(BuiltInRegistries.ITEM, itemKey, item); + CreativeTabExtras.add(CreativeTabRegistrar.DEFAULT_MODEL_TAB, item); + } + + ResourceKey> blockEntityKey = ResourceKey.create(Registries.BLOCK_ENTITY_TYPE, id); + if (BuiltInRegistries.BLOCK_ENTITY_TYPE.containsKey(blockEntityKey)) { + continue; + } + + BlockEntityType type = FabricBlockEntityTypeBuilder + .create(com.box3lab.block.entity.PackModelBlockEntity::new, block) + .build(); + + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, blockEntityKey, type); + TYPES_BY_BLOCK.put(block, type); + } + + CreativeTabRegistrar.registerModelTab(MOD_ID); + } + + public static BlockEntityType typeFor(Block block) { + BlockEntityType type = TYPES_BY_BLOCK.get(block); + if (type == null) { + throw new IllegalStateException("No block entity type bound for block: " + block); + } + return type; + } + + private static Set discoverPairedModelNames() { + Set result = new LinkedHashSet<>(); + Path packsRoot = FabricLoader.getInstance().getGameDir().resolve("resourcepacks"); + if (!Files.isDirectory(packsRoot)) { + return result; + } + + try (var entries = Files.list(packsRoot)) { + entries.forEach(entry -> { + if (Files.isDirectory(entry)) { + collectFromDirectory(entry, result); + } else if (isArchive(entry)) { + collectFromArchive(entry, result); + } + }); + } catch (IOException ignored) { + } + + return result; + } + + private static void collectFromDirectory(Path packDir, Set out) { + Path assetsRoot = packDir.resolve("assets").resolve(MOD_ID); + if (!Files.isDirectory(assetsRoot)) { + return; + } + + Set models = collectBaseNamesFromDirectory(assetsRoot, ".json"); + if (models.isEmpty()) { + return; + } + + Set textures = collectBaseNamesFromDirectory(assetsRoot, ".png"); + if (textures.isEmpty()) { + return; + } + + for (String model : models) { + if (textures.contains(model)) { + out.add(model); + } + } + } + + private static Set collectBaseNamesFromDirectory(Path root, String suffix) { + Set names = new LinkedHashSet<>(); + try (var files = Files.walk(root)) { + files.filter(Files::isRegularFile).forEach(path -> { + String fileName = path.getFileName().toString(); + if (!fileName.toLowerCase(Locale.ROOT).endsWith(suffix)) { + return; + } + + String base = fileName.substring(0, fileName.length() - suffix.length()).toLowerCase(Locale.ROOT); + if (!base.isBlank()) { + names.add(base); + } + }); + } catch (IOException ignored) { + } + return names; + } + + private static void collectFromArchive(Path archive, Set out) { + try (ZipFile zip = new ZipFile(archive.toFile())) { + Set models = new LinkedHashSet<>(); + Set textures = new LinkedHashSet<>(); + + Enumeration entries = zip.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (entry.isDirectory()) { + continue; + } + + String name = entry.getName(); + if (!name.startsWith(ASSET_PREFIX)) { + continue; + } + + String fileName = name.substring(name.lastIndexOf('/') + 1); + String lower = fileName.toLowerCase(Locale.ROOT); + if (lower.endsWith(".json")) { + String base = fileName.substring(0, fileName.length() - 5).toLowerCase(Locale.ROOT); + if (!base.isBlank()) { + models.add(base); + } + } else if (lower.endsWith(".png")) { + String base = fileName.substring(0, fileName.length() - 4).toLowerCase(Locale.ROOT); + if (!base.isBlank()) { + textures.add(base); + } + } + } + + for (String model : models) { + if (textures.contains(model)) { + out.add(model); + } + } + } catch (IOException ignored) { + } + } + + private static boolean isArchive(Path path) { + String name = path.getFileName().toString().toLowerCase(Locale.ROOT); + return name.endsWith(".zip") || name.endsWith(".jar"); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/sound/CategorySoundTypes.java b/Fabric-26.2/src/main/java/com/box3lab/register/sound/CategorySoundTypes.java new file mode 100644 index 00000000..aff3f8bb --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/sound/CategorySoundTypes.java @@ -0,0 +1,33 @@ +package com.box3lab.register.sound; + +import java.util.Locale; + +import net.minecraft.world.level.block.SoundType; + +public final class CategorySoundTypes { + private CategorySoundTypes() { + } + + public static SoundType soundTypeForCategory(String category) { + if (category == null) { + return SoundType.STONE; + } + String c = category.toLowerCase(Locale.ROOT); + + return switch (c) { + case "structure" -> SoundType.STONE; + case "nature" -> SoundType.GRASS; + + case "symbol", "number", "letter", "color" -> SoundType.STONE; + + case "wood", "plant", "tree", "leaf", "leaves" -> SoundType.WOOD; + case "metal", "machine" -> SoundType.METAL; + case "glass" -> SoundType.GLASS; + case "wool", "cloth" -> SoundType.WOOL; + case "sand" -> SoundType.SAND; + case "snow" -> SoundType.SNOW; + case "slime" -> SoundType.SLIME_BLOCK; + default -> SoundType.STONE; + }; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockFactories.java b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockFactories.java new file mode 100644 index 00000000..75cb8588 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockFactories.java @@ -0,0 +1,57 @@ +package com.box3lab.register.voxel; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.function.Function; + +import com.box3lab.block.BarrierVoxelBlock; +import com.box3lab.block.BouncePadBlock; +import com.box3lab.block.ConveyorBlock; +import com.box3lab.block.GlassVoxelBlock; +import com.box3lab.block.SpiderWebBlock; +import com.box3lab.block.VoxelBlock; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; + +public final class VoxelBlockFactories { + private static final Function DEFAULT_FACTORY = VoxelBlock::new; + private static final Map> FACTORIES = new HashMap<>(); + + static { + register("conveyor", ConveyorBlock::new); + register("bounce_pad", BouncePadBlock::new); + register("spiderweb", SpiderWebBlock::new); + register("barrier", BarrierVoxelBlock::new); + } + + private VoxelBlockFactories() { + } + + public static void register(String texturePart, Function factory) { + if (texturePart == null || texturePart.isBlank() || factory == null) { + return; + } + FACTORIES.put(texturePart.toLowerCase(Locale.ROOT), factory); + } + + public static Function factoryFor(String texturePart, boolean transparent) { + if (texturePart == null) { + return DEFAULT_FACTORY; + } + + String key = texturePart.toLowerCase(Locale.ROOT); + + Function factory = FACTORIES.get(key); + if (factory != null) { + return factory; + } + + if (transparent) { + return GlassVoxelBlock::new; + } + + return DEFAULT_FACTORY; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockPropertiesFactory.java b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockPropertiesFactory.java new file mode 100644 index 00000000..60fb8ba2 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelBlockPropertiesFactory.java @@ -0,0 +1,26 @@ +package com.box3lab.register.voxel; + +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.material.MapColor; + +public final class VoxelBlockPropertiesFactory { + private VoxelBlockPropertiesFactory() { + } + + public static BlockBehaviour.Properties create(boolean solid, SoundType soundType, int lightLevel, float hardness, + float resistance, float friction) { + BlockBehaviour.Properties props = BlockBehaviour.Properties.of() + .sound(soundType) + .mapColor(MapColor.COLOR_CYAN) + .lightLevel(state -> lightLevel) + .strength(hardness, resistance) + .friction(friction); + + if (!solid) { + props = props.noOcclusion(); + } + + return props; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelLightLevelMapper.java b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelLightLevelMapper.java new file mode 100644 index 00000000..ef88bf45 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/register/voxel/VoxelLightLevelMapper.java @@ -0,0 +1,11 @@ +package com.box3lab.register.voxel; + +public final class VoxelLightLevelMapper { + private VoxelLightLevelMapper() { + } + + public static int lightLevelFromEmissivePacked(int emissivePacked) { + int rawLight = emissivePacked == 0 ? 0 : (int) Math.round(15.0 * (0.8 + 0.2 * emissivePacked / 4095.0)); + return Math.max(0, Math.min(15, rawLight)); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/util/BlockIdResolver.java b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIdResolver.java new file mode 100644 index 00000000..2b4b6490 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIdResolver.java @@ -0,0 +1,135 @@ +package com.box3lab.util; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import com.box3lab.register.ModBlocks; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; + +public final class BlockIdResolver { + + private static JsonObject blockIdMapping = null; + private static Map blockToIdMapping = null; + + private BlockIdResolver() { + } + + private static void loadBlockIdMapping() { + if (blockIdMapping != null) { + return; + } + + try (InputStream is = BlockIdResolver.class.getClassLoader().getResourceAsStream("block-id.json")) { + if (is == null) { + throw new RuntimeException(Component + .translatable("command.box3.block_id.missing_file") + .getString()); + } + try (InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { + blockIdMapping = JsonParser.parseReader(reader).getAsJsonObject(); + } + } catch (Exception e) { + throw new RuntimeException( + Component.translatable("command.box3.block_id.read_failed").getString(), + e); + } + } + + private static void loadReverseMapping() { + loadBlockIdMapping(); + if (blockToIdMapping != null) { + return; + } + + Map reverse = new HashMap<>(); + for (var entry : blockIdMapping.entrySet()) { + String registryKey = entry.getValue().getAsString().toLowerCase(Locale.ROOT); + reverse.putIfAbsent(registryKey, Integer.parseInt(entry.getKey())); + } + blockToIdMapping = reverse; + } + + public static Block getBlockById(int id) { + return getBlockById(id, false); + } + + public static Block getBlockById(int id, boolean ignoreWater) { + loadBlockIdMapping(); + + String idStr = String.valueOf(id); + if (!blockIdMapping.has(idStr)) { + System.err.println(Component + .translatable("command.box3.block_id.no_mapping_for_id", idStr) + .getString()); + return Blocks.STONE; + } + + // 364: spec_water_block (water) + // 412-430: spec_*_juice_block, milk, soy_sauce, coffee, peach_juice + if (id == 364 + || id == 412 + || id == 414 + || id == 416 + || id == 418 + || id == 420 + || id == 422 + || id == 424 + || id == 426 + || id == 428 + || id == 430) { + if (ignoreWater) { + return Blocks.AIR; + } + return Blocks.WATER; + } + + String registryKey = blockIdMapping.get(idStr).getAsString(); + String normalizedKey = registryKey.toLowerCase(Locale.ROOT); + + Block block = ModBlocks.BLOCKS.get(normalizedKey); + if (block == null) { + System.err.println(Component + .translatable("command.box3.block_id.missing_registered_block", registryKey) + .getString()); + return Blocks.STONE; + } + + return block; + } + + public static boolean isBarrierId(int id) { + loadBlockIdMapping(); + + String idStr = String.valueOf(id); + if (!blockIdMapping.has(idStr)) { + return false; + } + String registryKey = blockIdMapping.get(idStr).getAsString(); + return "barrier".equalsIgnoreCase(registryKey); + } + + public static int getIdByBlock(Block block) { + loadReverseMapping(); + String key = BuiltInRegistries.BLOCK.getKey(block).getPath().toLowerCase(Locale.ROOT); + Integer id = blockToIdMapping.get(key); + if (id != null) { + return id; + } + + if (block == Blocks.WATER) { + return 364; + } + + return 0; + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexData.java b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexData.java new file mode 100644 index 00000000..149eab2e --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexData.java @@ -0,0 +1,243 @@ +package com.box3lab.util; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Locale; +import java.util.Set; + +public final class BlockIndexData { + public static final class FluidInfo { + public final int id; + public final int mass; + public final long info; + public final double fluidExtinction; + + public FluidInfo(int id, int mass, long info, double fluidExtinction) { + this.id = id; + this.mass = mass; + this.info = info; + this.fluidExtinction = fluidExtinction; + } + } + + public final int[] ids; + public final String[] names; + public final int[] emissive; + public final float[] blockHardness; + public final float[] blockResistance; + public final float[] blockFriction; + public final Map categoryByName; + public final Set notSolidIds; + public final Map fluidsById; + + public final Map indexById; + public final Map idByName; + + private BlockIndexData( + int[] ids, + String[] names, + int[] emissive, + float[] blockHardness, + float[] blockResistance, + float[] blockFriction, + Map categoryByName, + Set notSolidIds, + Map fluidsById) { + this.ids = ids; + this.names = names; + this.emissive = emissive; + this.blockHardness = blockHardness; + this.blockResistance = blockResistance; + this.blockFriction = blockFriction; + this.categoryByName = categoryByName; + this.notSolidIds = notSolidIds; + this.fluidsById = fluidsById; + + Map indexByIdTmp = new HashMap<>(ids.length * 2); + for (int i = 0; i < ids.length; i++) { + indexByIdTmp.put(ids[i], i); + } + this.indexById = indexByIdTmp; + + Map idByNameTmp = new HashMap<>(names.length * 2); + int len = Math.min(ids.length, names.length); + for (int i = 0; i < len; i++) { + idByNameTmp.put(names[i], ids[i]); + } + this.idByName = idByNameTmp; + } + + private static volatile BlockIndexData INSTANCE; + + public static BlockIndexData get() { + BlockIndexData inst = INSTANCE; + if (inst != null) { + return inst; + } + synchronized (BlockIndexData.class) { + if (INSTANCE == null) { + INSTANCE = load(); + } + return INSTANCE; + } + } + + private static BlockIndexData load() { + JsonObject root; + try (InputStream is = BlockIndexData.class.getClassLoader().getResourceAsStream("block-spec.json")) { + if (is == null) { + throw new IllegalStateException("Missing resource: block-spec.json"); + } + root = JsonParser.parseReader(new InputStreamReader(is, StandardCharsets.UTF_8)).getAsJsonObject(); + } catch (Exception e) { + throw new RuntimeException("Failed to load block-spec.json", e); + } + + final class Entry { + final String name; + final int id; + final int emissive; + final String category; + final boolean transparent; + final boolean fluid; + final int mass; + final int fluidR; + final int fluidG; + final int fluidB; + final double fluidExtinction; + final float hardness; + final float resistance; + final float friction; + + Entry(String name, int id, int emissive, String category, boolean transparent, boolean fluid, int mass, + int fluidR, int fluidG, int fluidB, double fluidExtinction, float hardness, float resistance, + float friction) { + this.name = name; + this.id = id; + this.emissive = emissive; + this.category = category; + this.transparent = transparent; + this.fluid = fluid; + this.mass = mass; + this.fluidR = fluidR; + this.fluidG = fluidG; + this.fluidB = fluidB; + this.fluidExtinction = fluidExtinction; + this.hardness = hardness; + this.resistance = resistance; + this.friction = friction; + } + } + + List entries = new ArrayList<>(root.size()); + for (Map.Entry e : root.entrySet()) { + String name = e.getKey(); + JsonObject obj = e.getValue().getAsJsonObject(); + + int id = obj.has("id") ? obj.get("id").getAsInt() : -1; + String category = obj.has("category") ? obj.get("category").getAsString() : ""; + boolean transparent = obj.has("transparent") && obj.get("transparent").getAsBoolean(); + boolean fluid = obj.has("fluid") && obj.get("fluid").getAsBoolean(); + int mass = obj.has("mass") ? obj.get("mass").getAsInt() : 0; + + int emissivePacked = 0; + if (obj.has("emissive") && obj.get("emissive").isJsonArray() + && obj.getAsJsonArray("emissive").size() >= 3) { + double er = obj.getAsJsonArray("emissive").get(0).getAsDouble(); + double eg = obj.getAsJsonArray("emissive").get(1).getAsDouble(); + double eb = obj.getAsJsonArray("emissive").get(2).getAsDouble(); + double max = Math.max(er, Math.max(eg, eb)); + emissivePacked = (int) Math.round(Math.max(0.0, Math.min(1.0, max / 15.0)) * 4095.0); + } + + int fr = 0, fg = 0, fb = 0; + if (obj.has("fluidColor") && obj.get("fluidColor").isJsonArray() + && obj.getAsJsonArray("fluidColor").size() >= 3) { + double r = obj.getAsJsonArray("fluidColor").get(0).getAsDouble(); + double g = obj.getAsJsonArray("fluidColor").get(1).getAsDouble(); + double b = obj.getAsJsonArray("fluidColor").get(2).getAsDouble(); + + fr = (int) Math.round((r <= 1.0 ? r * 255.0 : r)); + fg = (int) Math.round((g <= 1.0 ? g * 255.0 : g)); + fb = (int) Math.round((b <= 1.0 ? b * 255.0 : b)); + + fr = Math.max(0, Math.min(255, fr)); + fg = Math.max(0, Math.min(255, fg)); + fb = Math.max(0, Math.min(255, fb)); + } + + double fluidExtinction = 0.0; + if (obj.has("fluidExtinction")) { + fluidExtinction = obj.get("fluidExtinction").getAsDouble(); + } + + // Parse strength values + float hardness = 1.0f; // default hardness + float resistance = 1.0f; // default resistance + + if (obj.has("strength") && obj.get("strength").isJsonObject()) { + JsonObject strengthObj = obj.get("strength").getAsJsonObject(); + hardness = strengthObj.has("hardness") ? strengthObj.get("hardness").getAsFloat() : 1.0f; + resistance = strengthObj.has("resistance") ? strengthObj.get("resistance").getAsFloat() : 1.0f; + } + + // Parse friction value (default 1.0 if missing) + float friction = 1.0f; + if (obj.has("friction")) { + friction = obj.get("friction").getAsFloat(); + } + + if (id >= 0) { + entries.add(new Entry(name, id, emissivePacked, category, transparent, fluid, mass, fr, fg, fb, + fluidExtinction, hardness, resistance, friction)); + } + } + + entries.sort((a, b) -> Integer.compare(a.id, b.id)); + + int[] ids = new int[entries.size()]; + String[] names = new String[entries.size()]; + int[] emissive = new int[entries.size()]; + float[] blockHardness = new float[entries.size()]; + float[] blockResistance = new float[entries.size()]; + float[] blockFriction = new float[entries.size()]; + Map categoryByName = new HashMap<>(entries.size() * 2); + + Set notSolidSet = new HashSet<>(); + Map fluidsById = new HashMap<>(); + + for (int i = 0; i < entries.size(); i++) { + Entry en = entries.get(i); + ids[i] = en.id; + names[i] = en.name; + emissive[i] = en.emissive; + blockHardness[i] = en.hardness; + blockResistance[i] = en.resistance; + blockFriction[i] = en.friction; + categoryByName.put(en.name.toLowerCase(Locale.ROOT), en.category == null ? "" : en.category); + + if (en.transparent || en.fluid) { + notSolidSet.add(en.id); + } + if (en.fluid) { + int a = 255; + long info = (en.fluidR & 255L) | ((en.fluidG & 255L) << 8) | ((en.fluidB & 255L) << 16) + | ((a & 255L) << 24); + fluidsById.put(en.id, new FluidInfo(en.id, en.mass, info, en.fluidExtinction)); + } + } + + return new BlockIndexData(ids, names, emissive, blockHardness, blockResistance, blockFriction, categoryByName, + notSolidSet, fluidsById); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexUtil.java b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexUtil.java new file mode 100644 index 00000000..2d4539b0 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/util/BlockIndexUtil.java @@ -0,0 +1,98 @@ +package com.box3lab.util; + +import java.util.Locale; + +public final class BlockIndexUtil { + private BlockIndexUtil() { + } + + public static final class RGBA { + public final int r; + public final int g; + public final int b; + public final float a; + + public RGBA(int r, int g, int b, float a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + } + + public static int normalizeId(int blockId) { + return blockId & 4095; + } + + public static String getNameById(int blockId) { + int id = normalizeId(blockId); + BlockIndexData data = BlockIndexData.get(); + Integer idx = data.indexById.get(id); + if (idx == null) { + return null; + } + if (idx < 0 || idx >= data.names.length) { + return null; + } + return data.names[idx]; + } + + public static Integer getIdByName(String name) { + if (name == null) { + return null; + } + BlockIndexData data = BlockIndexData.get(); + return data.idByName.get(name); + } + + public static boolean isFluid(int blockId) { + int id = normalizeId(blockId); + return BlockIndexData.get().fluidsById.containsKey(id); + } + + public static boolean isSolid(int blockId) { + int id = normalizeId(blockId); + return !BlockIndexData.get().notSolidIds.contains(id); + } + + public static boolean isSoild(int blockId) { + return isSolid(blockId); + } + + public static int blockEmissiveLight(int blockId) { + int id = normalizeId(blockId); + BlockIndexData data = BlockIndexData.get(); + Integer idx = data.indexById.get(id); + if (idx == null) { + return 0; + } + if (idx < 0 || idx >= data.emissive.length) { + return 0; + } + return data.emissive[idx]; + } + + public static RGBA getFluidColor(int blockId) { + int id = normalizeId(blockId); + BlockIndexData.FluidInfo fluid = BlockIndexData.get().fluidsById.get(id); + if (fluid == null) { + return null; + } + long info = fluid.info; + + int r = (int) (info & 255L); + int g = (int) ((info & 65280L) >> 8); + int b = (int) ((info & 16711680L) >>> 16); + float a = (float) (((info >>> 24) & 255L) / 255.0); + + return new RGBA(r, g, b, a); + } + + public static String getVoxelNameLowerCaseById(int blockId) { + String name = getNameById(blockId); + if (name == null) { + return null; + } + return name.toLowerCase(Locale.ROOT); + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/util/Box3ImportFiles.java b/Fabric-26.2/src/main/java/com/box3lab/util/Box3ImportFiles.java new file mode 100644 index 00000000..bb2c1c13 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/util/Box3ImportFiles.java @@ -0,0 +1,38 @@ +package com.box3lab.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; + +import net.fabricmc.loader.api.FabricLoader; + +import static com.box3lab.Box3.MOD_ID; + +public final class Box3ImportFiles { + + private Box3ImportFiles() { + } + + public static Path getImportDir() { + return FabricLoader.getInstance() + .getConfigDir() + .resolve(MOD_ID); + } + + public static List listJsonFiles() throws IOException { + Path dir = getImportDir(); + if (!Files.exists(dir)) { + return Collections.emptyList(); + } + + try (var stream = Files.list(dir)) { + return stream + .filter(path -> path.getFileName().toString().endsWith(".gz")) + .map(path -> path.getFileName().toString()) + .sorted() + .toList(); + } + } +} diff --git a/Fabric-26.2/src/main/java/com/box3lab/util/ConfigUtil.java b/Fabric-26.2/src/main/java/com/box3lab/util/ConfigUtil.java new file mode 100644 index 00000000..2c4c97f5 --- /dev/null +++ b/Fabric-26.2/src/main/java/com/box3lab/util/ConfigUtil.java @@ -0,0 +1,58 @@ +package com.box3lab.util; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; + +import net.fabricmc.loader.api.FabricLoader; + +import static com.box3lab.Box3.MOD_ID; + +public final class ConfigUtil { + + public static final String CONFIG_DIR_NAME = "config.json"; + + private ConfigUtil() { + } + + public static JsonObject readConfig(String fileName) { + try { + Path dir = FabricLoader.getInstance().getConfigDir().resolve(MOD_ID); + Path path = dir.resolve(fileName); + if (!Files.exists(path)) { + return null; + } + + try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + return JsonParser.parseReader(reader).getAsJsonObject(); + } + } catch (IOException | JsonParseException e) { + return null; + } + } + + public static void writeConfig(String fileName, JsonObject obj) { + if (obj == null) { + return; + } + try { + Path dir = FabricLoader.getInstance().getConfigDir().resolve(MOD_ID); + if (!Files.exists(dir)) { + Files.createDirectories(dir); + } + Path path = dir.resolve(fileName); + + try (Writer writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { + writer.write(obj.toString()); + } + } catch (IOException e) { + } + } +} diff --git a/Fabric-26.2/src/main/resources/assets/box3/icon.png b/Fabric-26.2/src/main/resources/assets/box3/icon.png new file mode 100644 index 00000000..8ef4da98 Binary files /dev/null and b/Fabric-26.2/src/main/resources/assets/box3/icon.png differ diff --git a/Fabric-26.2/src/main/resources/assets/box3/lang/en_us.json b/Fabric-26.2/src/main/resources/assets/box3/lang/en_us.json new file mode 100644 index 00000000..37a935c5 --- /dev/null +++ b/Fabric-26.2/src/main/resources/assets/box3/lang/en_us.json @@ -0,0 +1,434 @@ +{ + "block.box3.spec_air_block": "Air", + "block.box3.spec_blueberry_juice_block": "Blueberry Juice", + "block.box3.spec_coffee_block": "Coffee", + "block.box3.spec_grape_juice_block": "Grape Juice", + "block.box3.spec_lemon_juice_block": "Lemon Juice", + "block.box3.spec_lime_juice_block": "Lime Juice", + "block.box3.spec_milk_block": "Milk", + "block.box3.spec_orange_juice_block": "Orange Juice", + "block.box3.spec_peach_juice_block": "Peach Juice", + "block.box3.spec_soy_sauce_block": "Soy Sauce", + "block.box3.spec_strawberry_juice_block": "Strawberry Juice", + "block.box3.spec_water_block": "Water", + "block.box3.a": "A", + "block.box3.acacia": "Acacia", + "block.box3.add": "Add", + "block.box3.air_duct": "Air Duct", + "block.box3.ampersand": "Ampersand", + "block.box3.asterisk": "Asterisk", + "block.box3.at": "At", + "block.box3.b": "B", + "block.box3.backslash": "Backslash", + "block.box3.bamboo": "Bamboo", + "block.box3.barrier": "Barrier", + "block.box3.bat_window": "Bat Window", + "block.box3.bear_footprint": "Bear Footprint", + "block.box3.biscuit": "Biscuit", + "block.box3.black": "Black", + "block.box3.black_glass": "Black Glass", + "block.box3.blue": "Blue", + "block.box3.blue_decorative_light": "Blue Decorative Light", + "block.box3.blue_gift": "Blue Gift", + "block.box3.blue_glass": "Blue Glass", + "block.box3.blue_grass": "Blue Grass", + "block.box3.blue_grass_all": "Blue Grass All", + "block.box3.blue_light": "Blue Light", + "block.box3.blue_surface_01": "Blue Surface 01", + "block.box3.blue_surface_02": "Blue Surface 02", + "block.box3.board0": "board0", + "block.box3.board1": "board1", + "block.box3.board10": "board10", + "block.box3.board11": "board11", + "block.box3.board12": "board12", + "block.box3.board13": "board13", + "block.box3.board14": "board14", + "block.box3.board15": "board15", + "block.box3.board2": "board2", + "block.box3.board3": "board3", + "block.box3.board4": "board4", + "block.box3.board5": "board5", + "block.box3.board6": "board6", + "block.box3.board7": "board7", + "block.box3.board8": "board8", + "block.box3.board9": "board9", + "block.box3.board_01": "Board 01", + "block.box3.board_02": "Board 02", + "block.box3.board_03": "Board 03", + "block.box3.board_04": "Board 04", + "block.box3.board_05": "Board 05", + "block.box3.board_06": "Board 06", + "block.box3.board_07": "Board 07", + "block.box3.bookshelf": "Bookshelf", + "block.box3.bounce_pad": "Bounce Pad", + "block.box3.bracket_close": "Bracket Close", + "block.box3.bracket_open": "Bracket Open", + "block.box3.brick_01": "Brick 01", + "block.box3.brick_02": "Brick 02", + "block.box3.brick_red": "Brick Red", + "block.box3.button": "Button", + "block.box3.c": "C", + "block.box3.cadet_blue": "Cadet Blue", + "block.box3.candy": "Candy", + "block.box3.caret": "Caret", + "block.box3.carpet_01": "Carpet 01", + "block.box3.carpet_02": "Carpet 02", + "block.box3.carpet_03": "Carpet 03", + "block.box3.carpet_04": "Carpet 04", + "block.box3.carpet_05": "Carpet 05", + "block.box3.carpet_06": "Carpet 06", + "block.box3.carpet_07": "Carpet 07", + "block.box3.carpet_08": "Carpet 08", + "block.box3.carpet_09": "Carpet 09", + "block.box3.carpet_10": "Carpet 10", + "block.box3.carpet_11": "Carpet 11", + "block.box3.carpet_12": "Carpet 12", + "block.box3.carpet_13": "Carpet 13", + "block.box3.coffee_gray": "Coffee Gray", + "block.box3.colon": "Colon", + "block.box3.color_glass": "Color Glass", + "block.box3.comma": "Comma", + "block.box3.conveyor": "Conveyor", + "block.box3.crane_lantern": "Crane Lantern", + "block.box3.crane_roof_01": "Crane Roof 01", + "block.box3.crane_roof_02": "Crane Roof 02", + "block.box3.cross_window": "Cross Window", + "block.box3.d": "D", + "block.box3.dark_blue_grass": "Dark Blue Grass", + "block.box3.dark_blue_grass_all": "Dark Blue Grass All", + "block.box3.dark_brick_00": "Dark Brick 00", + "block.box3.dark_brick_01": "Dark Brick 01", + "block.box3.dark_brick_02": "Dark Brick 02", + "block.box3.dark_grass": "Dark Grass", + "block.box3.dark_grass_all": "Dark Grass All", + "block.box3.dark_grass_rock": "Dark Grass Rock", + "block.box3.dark_grass_sand": "Dark Grass Sand", + "block.box3.dark_gray": "Dark Gray", + "block.box3.dark_orchid": "Dark Orchid", + "block.box3.dark_purple_grass": "Dark Purple Grass", + "block.box3.dark_purple_grass_all": "Dark Purple Grass All", + "block.box3.dark_red": "Dark Red", + "block.box3.dark_red_grass": "Dark Red Grass", + "block.box3.dark_red_grass_all": "Dark Red Grass All", + "block.box3.dark_salmon": "Dark Salmon", + "block.box3.dark_sand": "Dark Sand", + "block.box3.dark_slate_blue": "Dark Slate Blue", + "block.box3.dark_stone": "Dark Stone", + "block.box3.dark_surface": "Dark Surface", + "block.box3.dark_volcanic_rock": "Dark Volcanic Rock", + "block.box3.dark_yellow_grass": "Dark Yellow Grass", + "block.box3.dark_yellow_grass_all": "Dark Yellow Grass All", + "block.box3.dirt": "Dirt", + "block.box3.divide": "Divide", + "block.box3.dollar": "Dollar", + "block.box3.e": "E", + "block.box3.eight": "Eight", + "block.box3.equal": "Equal", + "block.box3.exclamation_mark": "Exclamation Mark", + "block.box3.express_box": "Express Box", + "block.box3.f": "F", + "block.box3.fan": "Fan", + "block.box3.firecracker": "Firecracker", + "block.box3.five": "Five", + "block.box3.four": "Four", + "block.box3.fu": "Fu", + "block.box3.g": "G", + "block.box3.geometric_window_01": "Geometric Window 01", + "block.box3.geometric_window_02": "Geometric Window 02", + "block.box3.glass": "Glass", + "block.box3.gold_trim_brick": "Gold Trim Brick", + "block.box3.grass": "Grass", + "block.box3.grass_all": "Grass All", + "block.box3.grass_rock": "Grass Rock", + "block.box3.grass_sand": "Grass Sand", + "block.box3.greater_than": "Greater Than", + "block.box3.green_decorative_light": "Green Decorative Light", + "block.box3.green_glass": "Green Glass", + "block.box3.green_leaf": "Green Leaf", + "block.box3.green_light": "Green Light", + "block.box3.greenbelt_l": "Greenbelt L", + "block.box3.greenbelt_l1": "Greenbelt l1", + "block.box3.grey_stone_brick": "Grey Stone Brick", + "block.box3.h": "H", + "block.box3.honeycomb_01": "Honeycomb 01", + "block.box3.honeycomb_02": "Honeycomb 02", + "block.box3.i": "I", + "block.box3.ice": "Ice", + "block.box3.ice_brick": "Ice Brick", + "block.box3.ice_wall": "Ice Wall", + "block.box3.indigo_light": "Indigo Light", + "block.box3.j": "J", + "block.box3.k": "K", + "block.box3.l": "L", + "block.box3.lab_lamp_01": "Lab Lamp 01", + "block.box3.lab_lamp_02": "Lab Lamp 02", + "block.box3.lab_lamp_03": "Lab Lamp 03", + "block.box3.lab_material_01": "Lab Material 01", + "block.box3.lab_material_02": "Lab Material 02", + "block.box3.lab_material_03": "Lab Material 03", + "block.box3.lab_material_04": "Lab Material 04", + "block.box3.lab_material_05": "Lab Material 05", + "block.box3.lab_material_06": "Lab Material 06", + "block.box3.lab_material_07": "Lab Material 07", + "block.box3.lab_material_08": "Lab Material 08", + "block.box3.lab_material_09": "Lab Material 09", + "block.box3.lab_material_10": "Lab Material 10", + "block.box3.lab_material_11": "Lab Material 11", + "block.box3.lab_material_12": "Lab Material 12", + "block.box3.lab_material_13": "Lab Material 13", + "block.box3.lab_material_14": "Lab Material 14", + "block.box3.lab_material_15": "Lab Material 15", + "block.box3.lab_screen": "Lab Screen", + "block.box3.lab_wire": "Lab Wire", + "block.box3.lantern_01": "Lantern 01", + "block.box3.lantern_02": "Lantern 02", + "block.box3.lava01": "lava01", + "block.box3.lava02": "lava02", + "block.box3.leaf_01": "Leaf 01", + "block.box3.leaf_02": "Leaf 02", + "block.box3.leaf_03": "Leaf 03", + "block.box3.leaf_04": "Leaf 04", + "block.box3.leaf_05": "Leaf 05", + "block.box3.leaf_06": "Leaf 06", + "block.box3.ledfloor01": "ledfloor01", + "block.box3.ledfloor02": "ledfloor02", + "block.box3.lemon": "Lemon", + "block.box3.less_than": "Less Than", + "block.box3.light_blue_grass": "Light Blue Grass", + "block.box3.light_blue_grass_all": "Light Blue Grass All", + "block.box3.light_dirt": "Light Dirt", + "block.box3.light_gray": "Light Gray", + "block.box3.light_grey_stone_brick": "Light Grey Stone Brick", + "block.box3.light_purple_grass_": "Light Purple Grass", + "block.box3.light_purple_grass_all": "Light Purple Grass All", + "block.box3.light_sand": "Light Sand", + "block.box3.light_volcanic_rock": "Light Volcanic Rock", + "block.box3.m": "M", + "block.box3.macaroon": "Macaroon", + "block.box3.maroon": "Maroon", + "block.box3.medium_gray": "Medium Gray", + "block.box3.medium_green": "Medium Green", + "block.box3.medium_orchid": "Medium Orchid", + "block.box3.medium_purple": "Medium Purple", + "block.box3.medium_spring_green": "Medium Spring Green", + "block.box3.medium_violet_red": "Medium Violet Red", + "block.box3.medium_yellow": "Medium Yellow", + "block.box3.mint_green": "Mint Green", + "block.box3.mint_green_light": "Mint Green Light", + "block.box3.multiply": "Multiply", + "block.box3.n": "N", + "block.box3.navajo_white": "Navajo White", + "block.box3.nine": "Nine", + "block.box3.o": "O", + "block.box3.olive_green": "Olive Green", + "block.box3.one": "One", + "block.box3.orange": "Orange", + "block.box3.orange_grass": "Orange Grass", + "block.box3.orange_grass_all": "Orange Grass All", + "block.box3.orange_light": "Orange Light", + "block.box3.orange_red": "Orange Red", + "block.box3.p": "P", + "block.box3.palace_carving": "Palace Carving", + "block.box3.palace_cloud": "Palace Cloud", + "block.box3.palace_eaves_01": "Palace Eaves 01", + "block.box3.palace_eaves_02": "Palace Eaves 02", + "block.box3.palace_eaves_03": "Palace Eaves 03", + "block.box3.palace_eaves_04": "Palace Eaves 04", + "block.box3.palace_eaves_05": "Palace Eaves 05", + "block.box3.palace_eaves_06": "Palace Eaves 06", + "block.box3.palace_eaves_07": "Palace Eaves 07", + "block.box3.palace_eaves_08": "Palace Eaves 08", + "block.box3.palace_floor": "Palace Floor", + "block.box3.palace_lamp": "Palace Lamp", + "block.box3.palace_roof": "Palace Roof", + "block.box3.palace_window": "Palace Window", + "block.box3.pale_green": "Pale Green", + "block.box3.palm": "Palm", + "block.box3.paren_close": "Paren Close", + "block.box3.paren_open": "Paren Open", + "block.box3.percent": "Percent", + "block.box3.period": "Period", + "block.box3.peru": "Peru", + "block.box3.pink": "Pink", + "block.box3.pink_cake": "Pink Cake", + "block.box3.pink_grass": "Pink Grass", + "block.box3.pink_grass_all": "Pink Grass All", + "block.box3.pink_light": "Pink Light", + "block.box3.plank_01": "Plank 01", + "block.box3.plank_02": "Plank 02", + "block.box3.plank_03": "Plank 03", + "block.box3.plank_04": "Plank 04", + "block.box3.plank_05": "Plank 05", + "block.box3.plank_06": "Plank 06", + "block.box3.plank_07": "Plank 07", + "block.box3.polar_ice": "Polar Ice", + "block.box3.polar_region": "Polar Region", + "block.box3.pound": "Pound", + "block.box3.powder_blue": "Powder Blue", + "block.box3.pumpkin": "Pumpkin", + "block.box3.pumpkin_lantern": "Pumpkin Lantern", + "block.box3.purple": "Purple", + "block.box3.purple_grass": "Purple Grass", + "block.box3.purple_grass_all": "Purple Grass All", + "block.box3.purple_surface_01": "Purple Surface 01", + "block.box3.purple_surface_02": "Purple Surface 02", + "block.box3.q": "Q", + "block.box3.quartz_brick": "Quartz Brick", + "block.box3.question_mark": "Question Mark", + "block.box3.quotation_mark": "Quotation Mark", + "block.box3.r": "R", + "block.box3.rainbow_cube": "Rainbow Cube", + "block.box3.red": "Red", + "block.box3.red_brick": "Red Brick", + "block.box3.red_brick_floor": "Red Brick Floor", + "block.box3.red_brick_wall": "Red Brick Wall", + "block.box3.red_decorative_light": "Red Decorative Light", + "block.box3.red_gift": "Red Gift", + "block.box3.red_glass": "Red Glass", + "block.box3.red_light": "Red Light", + "block.box3.rock": "Rock", + "block.box3.roof_blue_04": "Roof Blue 04", + "block.box3.roof_green": "Roof Green", + "block.box3.roof_grey": "Roof Grey", + "block.box3.roof_purple": "Roof Purple", + "block.box3.roof_red": "Roof Red", + "block.box3.roof_yellow": "Roof Yellow", + "block.box3.s": "S", + "block.box3.sakura_pink": "Sakura Pink", + "block.box3.sand": "Sand", + "block.box3.sand_stones": "Sand Stones", + "block.box3.semicolon": "Semicolon", + "block.box3.seven": "Seven", + "block.box3.sienna": "Sienna", + "block.box3.six": "Six", + "block.box3.sky_blue": "Sky Blue", + "block.box3.slash": "Slash", + "block.box3.snow": "Snow", + "block.box3.snow_grass": "Snow Grass", + "block.box3.snow_land": "Snow Land", + "block.box3.snowflake_lamp": "Snowflake Lamp", + "block.box3.snowland": "Snowland", + "block.box3.snowman_body": "Snowman Body", + "block.box3.snowman_head": "Snowman Head", + "block.box3.special_grass_01": "Special Grass 01", + "block.box3.special_grass_02": "Special Grass 02", + "block.box3.special_grass_03": "Special Grass 03", + "block.box3.special_grass_04": "Special Grass 04", + "block.box3.special_grass_05": "Special Grass 05", + "block.box3.special_grass_06": "Special Grass 06", + "block.box3.special_grass_07": "Special Grass 07", + "block.box3.special_grass_08": "Special Grass 08", + "block.box3.special_grass_09": "Special Grass 09", + "block.box3.special_grass_10": "Special Grass 10", + "block.box3.special_grass_11": "Special Grass 11", + "block.box3.special_grass_12": "Special Grass 12", + "block.box3.special_grass_13": "Special Grass 13", + "block.box3.special_grass_14": "Special Grass 14", + "block.box3.special_grass_15": "Special Grass 15", + "block.box3.special_grass_16": "Special Grass 16", + "block.box3.special_land_01": "Special Land 01", + "block.box3.special_sand_01": "Special Sand 01", + "block.box3.special_sand_02": "Special Sand 02", + "block.box3.special_sand_03": "Special Sand 03", + "block.box3.special_sand_04": "Special Sand 04", + "block.box3.special_sand_05": "Special Sand 05", + "block.box3.spiderweb": "Spiderweb", + "block.box3.stained_glass": "Stained Glass", + "block.box3.stainless_steel": "Stainless Steel", + "block.box3.star_lamp": "Star Lamp", + "block.box3.stone": "Stone", + "block.box3.stone_brick_01": "Stone Brick 01", + "block.box3.stone_brick_02": "Stone Brick 02", + "block.box3.stone_pillar_03": "Stone Pillar 03", + "block.box3.stone_pillar_04": "Stone Pillar 04", + "block.box3.stone_pillar_05": "Stone Pillar 05", + "block.box3.stone_pillar_06": "Stone Pillar 06", + "block.box3.stone_wall": "Stone Wall", + "block.box3.stone_wall_01": "Stone Wall 01", + "block.box3.stripe_01": "Stripe 01", + "block.box3.stripe_02": "Stripe 02", + "block.box3.stripe_03": "Stripe 03", + "block.box3.stripe_04": "Stripe 04", + "block.box3.stripe_05": "Stripe 05", + "block.box3.subtract": "Subtract", + "block.box3.t": "T", + "block.box3.television": "Television", + "block.box3.three": "Three", + "block.box3.tilde": "Tilde", + "block.box3.toolbox": "Toolbox", + "block.box3.traditional_window": "Traditional Window", + "block.box3.treasure_chest": "Treasure Chest", + "block.box3.turquoise": "Turquoise", + "block.box3.two": "Two", + "block.box3.u": "U", + "block.box3.v": "V", + "block.box3.w": "W", + "block.box3.warm_yellow_light": "Warm Yellow Light", + "block.box3.white": "White", + "block.box3.white_grass": "White Grass", + "block.box3.white_light": "White Light", + "block.box3.window": "Window", + "block.box3.windygrass": "Windygrass", + "block.box3.winter_leaf": "Winter Leaf", + "block.box3.withered_grass": "Withered Grass", + "block.box3.withered_grass_land": "Withered Grass Land", + "block.box3.wood": "Wood", + "block.box3.wooden_box": "Wooden Box", + "block.box3.woodstone_12": "Woodstone 12", + "block.box3.x": "X", + "block.box3.y": "Y", + "block.box3.yellow_decorative_light": "Yellow Decorative Light", + "block.box3.yellow_grass": "Yellow Grass", + "block.box3.yellow_green": "Yellow Green", + "block.box3.yellow_light": "Yellow Light", + "block.box3.z": "Z", + "block.box3.zero": "Zero", + "itemGroup.box3.letter": "Box3:Letters", + "itemGroup.box3.number": "Box3:Numbers", + "itemGroup.box3.symbol": "Box3:Symbols", + "itemGroup.box3.color": "Box3:Colors", + "itemGroup.box3.element": "Box3:Elements", + "itemGroup.box3.food": "Box3:Food", + "itemGroup.box3.light": "Box3:Lighting", + "itemGroup.box3.nature": "Box3:Nature", + "itemGroup.box3.structure": "Box3:Structures", + "itemGroup.box3.models": "Box3:Models", + "command.box3.box3import.usage": "Usage: /box3import (reads from config/box3/.gz),It will generate a building at your current location. ", + "command.box3.box3export.usage": "Usage: /box3export (place 2 redstone blocks as opposite corners)", + "command.box3.box3import.success": "Imported building from config/box3/%s", + "command.box3.box3import.progress": "Importing %s... %s%%", + "command.box3.box3import.failure": "Import failed: %s", + "command.box3.box3import.config_invalid": "Config file is invalid, please check it exists and has correct format.", + "command.box3.box3import.config_missing": "Config file does not exist: %s", + "command.box3.box3import.config_read_failed": "Failed to read config file: %s", + "command.box3.block_id.missing_file": "Cannot find block-id.json in the mod resources.", + "command.box3.block_id.read_failed": "Failed to read block-id.json.", + "command.box3.block_id.no_mapping_for_id": "No block-id.json mapping found for ID %s.", + "command.box3.block_id.missing_fluid_block": "Missing fluid block for %s, using water instead.", + "command.box3.block_id.missing_registered_block": "Missing registered voxel block: %s.", + "command.box3.box3import.list.empty": "No Terrain files found in %s (excluding %s)", + "command.box3.box3import.list.success": "Available Terrain files in %s: %s", + "command.box3.box3import.list.error": "Failed to list Terrain files in %s: %s", + "command.box3.box3barrier.status": "Barrier visible: %s", + "command.box3.box3barrier.set": "Barrier visibility set to: %s", + "command.box3.box3barrier.toggled": "Barrier visibility toggled to: %s (re-enter the world to fully apply)", + "command.box3.box3export.success": "Exported successfully: %s (scanned %s blocks, exported %s)", + "command.box3.box3export.failure": "Export failed: %s", + "command.box3.box3export.player_only": "This command can only be used by a player.", + "command.box3.box3export.selection_incomplete": "Selection is incomplete. Set both pos1 and pos2 first.", + "command.box3.box3export.selection_cleared": "Export selection cleared.", + "command.box3.box3export.pos_set": "Set %s to (%s, %s, %s).", + "command.box3.box3export.marker_invalid": "Invalid marker block id: %s", + "command.box3.box3export.marker_count_invalid": "Within radius %s, found %s marker blocks (%s), but exactly 2 are required.", + "message.box3.model.config.mode": "Model config mode: %s (Stick: +, Blaze Rod: -, Paper: copy, Book: paste)", + "message.box3.model.config.status": "mode=%s scale=%s offset=(%s, %s, %s) rot=%s", + "message.box3.model.config.mode.scale": "Scale", + "message.box3.model.config.mode.offset_x": "Offset X", + "message.box3.model.config.mode.offset_y": "Offset Y", + "message.box3.model.config.mode.offset_z": "Offset Z", + "message.box3.model.config.mode.rotation": "Rotation", + "message.box3.model.config.copy.success": "Copied current model config.", + "message.box3.model.config.copy.empty": "No copied config found.", + "message.box3.model.config.copy.pasted": "Pasted copied model config.", + "flat_world_preset.box3.box3_plains_world": "Box3 Plains" +} diff --git a/Fabric-26.2/src/main/resources/assets/box3/lang/zh_cn.json b/Fabric-26.2/src/main/resources/assets/box3/lang/zh_cn.json new file mode 100644 index 00000000..5f82f635 --- /dev/null +++ b/Fabric-26.2/src/main/resources/assets/box3/lang/zh_cn.json @@ -0,0 +1,422 @@ +{ + "block.box3.a": "A", + "block.box3.acacia": "金合欢", + "block.box3.add": "加", + "block.box3.air_duct": "通风管", + "block.box3.ampersand": "和号", + "block.box3.asterisk": "星号", + "block.box3.at": "艾特", + "block.box3.b": "B", + "block.box3.backslash": "反斜杠", + "block.box3.bamboo": "竹子", + "block.box3.barrier": "屏障", + "block.box3.bat_window": "蝙蝠窗", + "block.box3.bear_footprint": "熊脚印", + "block.box3.biscuit": "饼干", + "block.box3.black": "黑色", + "block.box3.black_glass": "黑色玻璃", + "block.box3.blue": "蓝色", + "block.box3.blue_decorative_light": "蓝色装饰灯", + "block.box3.blue_gift": "蓝色礼物", + "block.box3.blue_glass": "蓝色玻璃", + "block.box3.blue_grass": "蓝色草", + "block.box3.blue_grass_all": "蓝色全草", + "block.box3.blue_light": "蓝色灯", + "block.box3.blue_surface_01": "蓝色表面01", + "block.box3.blue_surface_02": "蓝色表面02", + "block.box3.board0": "木板0", + "block.box3.board1": "木板1", + "block.box3.board10": "木板10", + "block.box3.board11": "木板11", + "block.box3.board12": "木板12", + "block.box3.board13": "木板13", + "block.box3.board14": "木板14", + "block.box3.board15": "木板15", + "block.box3.board2": "木板2", + "block.box3.board3": "木板3", + "block.box3.board4": "木板4", + "block.box3.board5": "木板5", + "block.box3.board6": "木板6", + "block.box3.board7": "木板7", + "block.box3.board8": "木板8", + "block.box3.board9": "木板9", + "block.box3.board_01": "木板01", + "block.box3.board_02": "木板02", + "block.box3.board_03": "木板03", + "block.box3.board_04": "木板04", + "block.box3.board_05": "木板05", + "block.box3.board_06": "木板06", + "block.box3.board_07": "木板07", + "block.box3.bookshelf": "书架", + "block.box3.bounce_pad": "弹跳垫", + "block.box3.bracket_close": "右方括号", + "block.box3.bracket_open": "左方括号", + "block.box3.brick_01": "砖块01", + "block.box3.brick_02": "砖块02", + "block.box3.brick_red": "红砖", + "block.box3.button": "按钮", + "block.box3.c": "C", + "block.box3.cadet_blue": "军蓝", + "block.box3.candy": "糖果", + "block.box3.caret": "脱字符", + "block.box3.carpet_01": "地毯01", + "block.box3.carpet_02": "地毯02", + "block.box3.carpet_03": "地毯03", + "block.box3.carpet_04": "地毯04", + "block.box3.carpet_05": "地毯05", + "block.box3.carpet_06": "地毯06", + "block.box3.carpet_07": "地毯07", + "block.box3.carpet_08": "地毯08", + "block.box3.carpet_09": "地毯09", + "block.box3.carpet_10": "地毯10", + "block.box3.carpet_11": "地毯11", + "block.box3.carpet_12": "地毯12", + "block.box3.carpet_13": "地毯13", + "block.box3.coffee_gray": "咖啡灰", + "block.box3.colon": "冒号", + "block.box3.color_glass": "彩色玻璃", + "block.box3.comma": "逗号", + "block.box3.conveyor": "传送带", + "block.box3.crane_lantern": "起重机灯笼", + "block.box3.crane_roof_01": "起重机屋顶01", + "block.box3.crane_roof_02": "起重机屋顶02", + "block.box3.cross_window": "十字窗", + "block.box3.d": "D", + "block.box3.dark_blue_grass": "深蓝草", + "block.box3.dark_blue_grass_all": "深蓝全草", + "block.box3.dark_brick_00": "深砖00", + "block.box3.dark_brick_01": "深砖01", + "block.box3.dark_brick_02": "深砖02", + "block.box3.dark_grass": "深草", + "block.box3.dark_grass_all": "深全草", + "block.box3.dark_grass_rock": "深草岩", + "block.box3.dark_grass_sand": "深草沙", + "block.box3.dark_gray": "深灰", + "block.box3.dark_orchid": "深兰花", + "block.box3.dark_purple_grass": "深紫草", + "block.box3.dark_purple_grass_all": "深紫全草", + "block.box3.dark_red": "深红", + "block.box3.dark_red_grass": "深红草", + "block.box3.dark_red_grass_all": "深红全草", + "block.box3.dark_salmon": "深鲑鱼", + "block.box3.dark_sand": "深沙", + "block.box3.dark_slate_blue": "深板岩蓝", + "block.box3.dark_stone": "深石", + "block.box3.dark_surface": "深表面", + "block.box3.dark_volcanic_rock": "深火山岩", + "block.box3.dark_yellow_grass": "深黄草", + "block.box3.dark_yellow_grass_all": "深黄全草", + "block.box3.dirt": "泥土", + "block.box3.divide": "除", + "block.box3.dollar": "美元", + "block.box3.e": "E", + "block.box3.eight": "八", + "block.box3.equal": "等号", + "block.box3.exclamation_mark": "感叹号", + "block.box3.express_box": "快递箱", + "block.box3.f": "F", + "block.box3.fan": "风扇", + "block.box3.firecracker": "鞭炮", + "block.box3.five": "五", + "block.box3.four": "四", + "block.box3.fu": "福", + "block.box3.g": "G", + "block.box3.geometric_window_01": "几何窗01", + "block.box3.geometric_window_02": "几何窗02", + "block.box3.glass": "玻璃", + "block.box3.gold_trim_brick": "金边砖", + "block.box3.grass": "草", + "block.box3.grass_all": "全草", + "block.box3.grass_rock": "草岩", + "block.box3.grass_sand": "草沙", + "block.box3.greater_than": "大于号", + "block.box3.green_decorative_light": "绿色装饰灯", + "block.box3.green_glass": "绿色玻璃", + "block.box3.green_leaf": "绿叶", + "block.box3.green_light": "绿色灯", + "block.box3.greenbelt_l": "绿化带L", + "block.box3.greenbelt_l1": "绿化带L1", + "block.box3.grey_stone_brick": "灰石砖", + "block.box3.h": "H", + "block.box3.honeycomb_01": "蜂巢01", + "block.box3.honeycomb_02": "蜂巢02", + "block.box3.i": "I", + "block.box3.ice": "冰", + "block.box3.ice_brick": "冰砖", + "block.box3.ice_wall": "冰墙", + "block.box3.indigo_light": "靛蓝灯", + "block.box3.j": "J", + "block.box3.k": "K", + "block.box3.l": "L", + "block.box3.lab_lamp_01": "实验室灯01", + "block.box3.lab_lamp_02": "实验室灯02", + "block.box3.lab_lamp_03": "实验室灯03", + "block.box3.lab_material_01": "实验室材料01", + "block.box3.lab_material_02": "实验室材料02", + "block.box3.lab_material_03": "实验室材料03", + "block.box3.lab_material_04": "实验室材料04", + "block.box3.lab_material_05": "实验室材料05", + "block.box3.lab_material_06": "实验室材料06", + "block.box3.lab_material_07": "实验室材料07", + "block.box3.lab_material_08": "实验室材料08", + "block.box3.lab_material_09": "实验室材料09", + "block.box3.lab_material_10": "实验室材料10", + "block.box3.lab_material_11": "实验室材料11", + "block.box3.lab_material_12": "实验室材料12", + "block.box3.lab_material_13": "实验室材料13", + "block.box3.lab_material_14": "实验室材料14", + "block.box3.lab_material_15": "实验室材料15", + "block.box3.lab_screen": "实验室屏幕", + "block.box3.lab_wire": "实验室电线", + "block.box3.lantern_01": "灯笼01", + "block.box3.lantern_02": "灯笼02", + "block.box3.lava01": "熔岩01", + "block.box3.lava02": "熔岩02", + "block.box3.leaf_01": "叶子01", + "block.box3.leaf_02": "叶子02", + "block.box3.leaf_03": "叶子03", + "block.box3.leaf_04": "叶子04", + "block.box3.leaf_05": "叶子05", + "block.box3.leaf_06": "叶子06", + "block.box3.ledfloor01": "LED地板01", + "block.box3.ledfloor02": "LED地板02", + "block.box3.lemon": "柠檬", + "block.box3.less_than": "小于号", + "block.box3.light_blue_grass": "浅蓝草", + "block.box3.light_blue_grass_all": "浅蓝全草", + "block.box3.light_dirt": "浅土", + "block.box3.light_gray": "浅灰", + "block.box3.light_grey_stone_brick": "浅灰石砖", + "block.box3.light_purple_grass_": "浅紫草", + "block.box3.light_purple_grass_all": "浅紫全草", + "block.box3.light_sand": "浅沙", + "block.box3.light_volcanic_rock": "浅火山岩", + "block.box3.m": "M", + "block.box3.macaroon": "马卡龙", + "block.box3.maroon": "栗色", + "block.box3.medium_gray": "中灰", + "block.box3.medium_green": "中绿", + "block.box3.medium_orchid": "中兰花", + "block.box3.medium_purple": "中紫", + "block.box3.medium_spring_green": "中春绿", + "block.box3.medium_violet_red": "中紫红", + "block.box3.medium_yellow": "中黄", + "block.box3.mint_green": "薄荷绿", + "block.box3.mint_green_light": "薄荷绿灯", + "block.box3.multiply": "乘", + "block.box3.n": "N", + "block.box3.navajo_white": "纳瓦霍白", + "block.box3.nine": "九", + "block.box3.o": "O", + "block.box3.olive_green": "橄榄绿", + "block.box3.one": "一", + "block.box3.orange": "橙色", + "block.box3.orange_grass": "橙草", + "block.box3.orange_grass_all": "橙全草", + "block.box3.orange_light": "橙色灯", + "block.box3.orange_red": "橙红", + "block.box3.p": "P", + "block.box3.palace_carving": "宫殿雕刻", + "block.box3.palace_cloud": "宫殿云", + "block.box3.palace_eaves_01": "宫殿屋檐01", + "block.box3.palace_eaves_02": "宫殿屋檐02", + "block.box3.palace_eaves_03": "宫殿屋檐03", + "block.box3.palace_eaves_04": "宫殿屋檐04", + "block.box3.palace_eaves_05": "宫殿屋檐05", + "block.box3.palace_eaves_06": "宫殿屋檐06", + "block.box3.palace_eaves_07": "宫殿屋檐07", + "block.box3.palace_eaves_08": "宫殿屋檐08", + "block.box3.palace_floor": "宫殿地板", + "block.box3.palace_lamp": "宫殿灯", + "block.box3.palace_roof": "宫殿屋顶", + "block.box3.palace_window": "宫殿窗", + "block.box3.pale_green": "淡绿", + "block.box3.palm": "棕榈", + "block.box3.paren_close": "右圆括号", + "block.box3.paren_open": "左圆括号", + "block.box3.percent": "百分号", + "block.box3.period": "句号", + "block.box3.peru": "秘鲁色", + "block.box3.pink": "粉色", + "block.box3.pink_cake": "粉色蛋糕", + "block.box3.pink_grass": "粉草", + "block.box3.pink_grass_all": "粉全草", + "block.box3.pink_light": "粉色灯", + "block.box3.plank_01": "木板01", + "block.box3.plank_02": "木板02", + "block.box3.plank_03": "木板03", + "block.box3.plank_04": "木板04", + "block.box3.plank_05": "木板05", + "block.box3.plank_06": "木板06", + "block.box3.plank_07": "木板07", + "block.box3.polar_ice": "极地冰", + "block.box3.polar_region": "极地区域", + "block.box3.pound": "井号", + "block.box3.powder_blue": "粉蓝", + "block.box3.pumpkin": "南瓜", + "block.box3.pumpkin_lantern": "南瓜灯", + "block.box3.purple": "紫色", + "block.box3.purple_grass": "紫草", + "block.box3.purple_grass_all": "紫全草", + "block.box3.purple_surface_01": "紫色表面01", + "block.box3.purple_surface_02": "紫色表面02", + "block.box3.q": "Q", + "block.box3.quartz_brick": "石英砖", + "block.box3.question_mark": "问号", + "block.box3.quotation_mark": "引号", + "block.box3.r": "R", + "block.box3.rainbow_cube": "彩虹方块", + "block.box3.red": "红色", + "block.box3.red_brick": "红砖", + "block.box3.red_brick_floor": "红砖地板", + "block.box3.red_brick_wall": "红砖墙", + "block.box3.red_decorative_light": "红色装饰灯", + "block.box3.red_gift": "红色礼物", + "block.box3.red_glass": "红色玻璃", + "block.box3.red_light": "红色灯", + "block.box3.rock": "岩石", + "block.box3.roof_blue_04": "蓝色屋顶04", + "block.box3.roof_green": "绿色屋顶", + "block.box3.roof_grey": "灰色屋顶", + "block.box3.roof_purple": "紫色屋顶", + "block.box3.roof_red": "红色屋顶", + "block.box3.roof_yellow": "黄色屋顶", + "block.box3.s": "S", + "block.box3.sakura_pink": "樱花粉", + "block.box3.sand": "沙子", + "block.box3.sand_stones": "沙石", + "block.box3.semicolon": "分号", + "block.box3.seven": "七", + "block.box3.sienna": "赭石", + "block.box3.six": "六", + "block.box3.sky_blue": "天蓝", + "block.box3.slash": "斜杠", + "block.box3.snow": "雪", + "block.box3.snow_grass": "雪草", + "block.box3.snow_land": "雪地", + "block.box3.snowflake_lamp": "雪花灯", + "block.box3.snowland": "雪境", + "block.box3.snowman_body": "雪人身体", + "block.box3.snowman_head": "雪人头", + "block.box3.special_grass_01": "特殊草01", + "block.box3.special_grass_02": "特殊草02", + "block.box3.special_grass_03": "特殊草03", + "block.box3.special_grass_04": "特殊草04", + "block.box3.special_grass_05": "特殊草05", + "block.box3.special_grass_06": "特殊草06", + "block.box3.special_grass_07": "特殊草07", + "block.box3.special_grass_08": "特殊草08", + "block.box3.special_grass_09": "特殊草09", + "block.box3.special_grass_10": "特殊草10", + "block.box3.special_grass_11": "特殊草11", + "block.box3.special_grass_12": "特殊草12", + "block.box3.special_grass_13": "特殊草13", + "block.box3.special_grass_14": "特殊草14", + "block.box3.special_grass_15": "特殊草15", + "block.box3.special_grass_16": "特殊草16", + "block.box3.special_land_01": "特殊陆地01", + "block.box3.special_sand_01": "特殊沙01", + "block.box3.special_sand_02": "特殊沙02", + "block.box3.special_sand_03": "特殊沙03", + "block.box3.special_sand_04": "特殊沙04", + "block.box3.special_sand_05": "特殊沙05", + "block.box3.spiderweb": "蜘蛛网", + "block.box3.stained_glass": "染色玻璃", + "block.box3.stainless_steel": "不锈钢", + "block.box3.star_lamp": "星星灯", + "block.box3.stone": "石头", + "block.box3.stone_brick_01": "石砖01", + "block.box3.stone_brick_02": "石砖02", + "block.box3.stone_pillar_03": "石柱03", + "block.box3.stone_pillar_04": "石柱04", + "block.box3.stone_pillar_05": "石柱05", + "block.box3.stone_pillar_06": "石柱06", + "block.box3.stone_wall": "石墙", + "block.box3.stone_wall_01": "石墙01", + "block.box3.stripe_01": "条纹01", + "block.box3.stripe_02": "条纹02", + "block.box3.stripe_03": "条纹03", + "block.box3.stripe_04": "条纹04", + "block.box3.stripe_05": "条纹05", + "block.box3.subtract": "减", + "block.box3.t": "T", + "block.box3.television": "电视", + "block.box3.three": "三", + "block.box3.tilde": "波浪号", + "block.box3.toolbox": "工具箱", + "block.box3.traditional_window": "传统窗", + "block.box3.treasure_chest": "宝箱", + "block.box3.turquoise": "绿松石", + "block.box3.two": "二", + "block.box3.u": "U", + "block.box3.v": "V", + "block.box3.w": "W", + "block.box3.warm_yellow_light": "暖黄灯", + "block.box3.white": "白色", + "block.box3.white_grass": "白草", + "block.box3.white_light": "白灯", + "block.box3.window": "窗户", + "block.box3.windygrass": "风草", + "block.box3.winter_leaf": "冬叶", + "block.box3.withered_grass": "枯草", + "block.box3.withered_grass_land": "枯草地", + "block.box3.wood": "木头", + "block.box3.wooden_box": "木箱", + "block.box3.woodstone_12": "木石12", + "block.box3.x": "X", + "block.box3.y": "Y", + "block.box3.yellow_decorative_light": "黄色装饰灯", + "block.box3.yellow_grass": "黄草", + "block.box3.yellow_green": "黄绿", + "block.box3.yellow_light": "黄灯", + "block.box3.z": "Z", + "block.box3.zero": "零", + "itemGroup.box3.letter": "Box3:字母", + "itemGroup.box3.number": "Box3:数字", + "itemGroup.box3.symbol": "Box3:符号", + "itemGroup.box3.color": "Box3:颜色", + "itemGroup.box3.element": "Box3:元素", + "itemGroup.box3.food": "Box3:食物", + "itemGroup.box3.light": "Box3:灯光", + "itemGroup.box3.nature": "Box3:自然", + "itemGroup.box3.structure": "Box3:建筑", + "itemGroup.box3.models": "Box3:模型", + "command.box3.box3import.usage": "用法:/box3import <文件名>(从 config/box3/<文件名>.gz 读取),会在你的当前位置生成建筑", + "command.box3.box3export.usage": "用法:/box3export <文件名>(放置2个红石块作为对角点)", + "command.box3.box3import.success": "已从 %s 导入建筑", + "command.box3.box3import.progress": "正在导入 %s... %s%%", + "command.box3.box3import.failure": "导入失败:%s", + "command.box3.box3import.config_invalid": "配置文件读取失败,请检查文件是否存在且格式正确。", + "command.box3.box3import.config_missing": "配置文件不存在:%s", + "command.box3.box3import.config_read_failed": "读取配置失败:%s", + "command.box3.block_id.missing_file": "无法找到 block-id.json 文件。", + "command.box3.block_id.read_failed": "读取 block-id.json 失败。", + "command.box3.block_id.no_mapping_for_id": "未找到 ID %s 对应的方块映射。", + "command.box3.block_id.missing_fluid_block": "未找到流体方块:%s,使用水方块代替。", + "command.box3.block_id.missing_registered_block": "未找到注册的方块:%s。", + "command.box3.box3import.list.empty": "在 %s 中没有找到可用的地形文件(不包括 %s)", + "command.box3.box3import.list.success": "%s 中可用的地形文件:%s", + "command.box3.box3import.list.error": "列出 %s 中的地形文件失败:%s", + "command.box3.box3barrier.status": "屏障可见状态:%s", + "command.box3.box3barrier.set": "屏障可见状态已设置为:%s", + "command.box3.box3barrier.toggled": "屏障可见状态已切换为:%s(重新进入世界以完全生效)", + "command.box3.box3export.success": "导出成功:%s(扫描 %s 方块,导出 %s 个)", + "command.box3.box3export.failure": "导出失败:%s", + "command.box3.box3export.player_only": "该命令只能由玩家执行。", + "command.box3.box3export.selection_incomplete": "选区不完整,请先设置 pos1 和 pos2。", + "command.box3.box3export.selection_cleared": "已清空导出选区。", + "command.box3.box3export.pos_set": "已设置 %s:(%s, %s, %s)", + "command.box3.box3export.marker_invalid": "无效的标记方块ID:%s", + "command.box3.box3export.marker_count_invalid": "在半径 %s 内找到 %s 个标记方块(%s),需要刚好 2 个。", + "message.box3.model.config.mode": "模型配置模式:%s(木棍:增加,烈焰棒:减少,纸:复制,书:粘贴)", + "message.box3.model.config.status": "模式=%s 缩放=%s 偏移=(%s, %s, %s) 旋转=%s", + "message.box3.model.config.mode.scale": "缩放", + "message.box3.model.config.mode.offset_x": "X偏移", + "message.box3.model.config.mode.offset_y": "Y偏移", + "message.box3.model.config.mode.offset_z": "Z偏移", + "message.box3.model.config.mode.rotation": "旋转", + "message.box3.model.config.copy.success": "已复制当前模型参数。", + "message.box3.model.config.copy.empty": "没有可粘贴的已复制参数。", + "message.box3.model.config.copy.pasted": "已粘贴模型参数。", + "flat_world_preset.box3.box3_plains_world": "神岛平原" +} diff --git a/Fabric-26.2/src/main/resources/box3.mixins.json b/Fabric-26.2/src/main/resources/box3.mixins.json new file mode 100644 index 00000000..a28781d5 --- /dev/null +++ b/Fabric-26.2/src/main/resources/box3.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "package": "com.box3lab.mixin", + "compatibilityLevel": "JAVA_25", + "mixins": [], + "injectors": { + "defaultRequire": 1 + }, + "overwrites": { + "requireAnnotations": true + } +} \ No newline at end of file diff --git a/Fabric-26.2/src/main/resources/fabric.mod.json b/Fabric-26.2/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..4831713d --- /dev/null +++ b/Fabric-26.2/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "box3", + "version": "${version}", + "name": "Box3Blocks(神岛材质包)", + "description": "Box3 方块模组为 Minecraft 添加 372 款独特装饰方块,涵盖字母、符号、色块与发光方块,并统一整理至创造模式标签页。同时支持将神奇代码岛中的建筑/模型一键迁移到 Minecraft 中。", + "authors": ["神岛实验室"], + "contact": { + "homepage": "https://box3lab.com/", + "sources": "https://github.com/box3lab/Fabric-mcMod" + }, + "license": "Apache License 2.0", + "icon": "assets/box3/icon.png", + "environment": "*", + "entrypoints": { + "main": ["com.box3lab.Box3"], + "client": ["com.box3lab.Box3Client"] + }, + "mixins": [ + "box3.mixins.json", + { + "config": "box3.client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.19.3", + "minecraft": "~26.2", + "java": ">=25", + "fabric-api": "*" + } +}