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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Java Edition の MOD を、Bedrock Edition のプレイヤーが改造なしの
| モード | 実行主体 | 状態 |
|---|---|---|
| A: Java MOD サーバー接続 | Fabric サーバー + Geyser + Hydraulic | Bedrock 2人の同時入場と試験用ブロックの設置・破壊の同期を確認([試験結果](docs/adr/0005-mode-a-connection-gate.md#v010-の認証実機検証)) |
| B: Bedrock ネイティブ変換 | BDS / ローカルワールド | Windows のローカルワールドで基本素材の描画を確認。BDS の動作は未検証([ADR-0004](docs/adr/0004-asset-compiler-and-mapping.md)) |
| B: Bedrock ネイティブ変換 | BDS / ローカルワールド | Windows のローカルワールドで基本素材の描画と作業台のレシピを確認。公式 BDS は未検証([ADR-0006](docs/adr/0006-mode-b-behavior-pack.md)) |
| C: プロキシ・複数サーバー | 各 Java バックエンド | 未着手(v0.6.0) |

## 必要なもの
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ private static Recipe recipe(String bid, JsonObject r, Set<String> available) {
String type = str(r.get("type"));
List<String> notes = new ArrayList<>();
Set<String> vanilla = new TreeSet<>();
Set<String> ingredientsForUnlock = new TreeSet<>();
Map<String, Object> result = result(r.get("result"), available, vanilla);
if (result == null) {
return Recipe.fail("結果が単一のアイテムでないか、変換していないアイテム");
Expand All @@ -183,7 +184,8 @@ private static Recipe recipe(String bid, JsonObject r, Set<String> available) {
}
Set<String> used = new TreeSet<>();
rows.forEach(row -> row.chars().filter(c -> c != ' ').forEach(c -> used.add(String.valueOf((char) c))));
if (!used.equals(new TreeSet<>(keys.keySet())) || keys.keySet().stream().anyMatch(k -> k.length() != 1 || k.equals(" "))) {
if (used.isEmpty() || !used.equals(new TreeSet<>(keys.keySet()))
|| keys.keySet().stream().anyMatch(k -> k.length() != 1 || k.equals(" "))) {
return Recipe.fail("pattern の文字と key が対応していない(未定義の文字か、使われないキーがある)");
}
Map<String, Object> outKeys = new TreeMap<>();
Expand All @@ -192,6 +194,7 @@ private static Recipe recipe(String bid, JsonObject r, Set<String> available) {
if (id == null) {
return Recipe.fail("材料 " + k.getKey() + " がタグ・複数候補・変換していないアイテムのどれか(非対応)");
}
ingredientsForUnlock.add(id);
outKeys.put(k.getKey(), Map.of("item", id));
}
body.put("pattern", rows);
Expand All @@ -209,6 +212,7 @@ private static Recipe recipe(String bid, JsonObject r, Set<String> available) {
}
counts.merge(id, 1, Integer::sum);
}
ingredientsForUnlock.addAll(counts.keySet());
List<Object> outIngredients = new ArrayList<>();
counts.forEach((id, n) -> {
Map<String, Object> m = new LinkedHashMap<>();
Expand All @@ -221,6 +225,8 @@ private static Recipe recipe(String bid, JsonObject r, Set<String> available) {
} else {
return Recipe.fail("レシピの種類 " + type + " は非対応(作業台のレシピだけ。かまどなどは v0.4.0)");
}
// Bedrock の 1.20 以降の書式には発見条件が必要なので、変換した材料を使う。
body.put("unlock", ingredientsForUnlock.stream().map(id -> Map.of("item", id)).toList());
body.put("result", result);
if (!vanilla.isEmpty()) {
notes.add("バニラのアイテム ID は Java と同じとみなした(Bedrock で名前が違うものがある): " + String.join(", ", vanilla));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public final class PackCompiler {
/** 公開する成果物(キャッシュもこの 4 つが揃っているときだけ使う)。 */
public static final List<String> OUTPUT_FILES = List.of(PACK_FILE, BEHAVIOR_PACK_FILE, ADDON_FILE, MAPPING_FILE);
/** 生成器の版。出力の形式を変えたら上げる(キャッシュの鍵に入る)。 */
static final String COMPILER_VERSION = "pack-compiler/4";
static final String COMPILER_VERSION = "pack-compiler/9";
static final long MAX_PACK_BYTES = 256L << 20;
static final int MAX_TEXTURES = 16_384;
/** パックが要求する Bedrock の最低版。1.21.80 以降の書式(ブロックの geometry と material_instances)に合わせる(ADR-0006)。 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.gson.JsonParser;
import dev.puicore.modbridge.core.ir.BridgeIr;
import dev.puicore.modbridge.core.scan.Analyzer;
import java.awt.image.BufferedImage;
Expand Down Expand Up @@ -488,8 +489,10 @@ private static dev.puicore.modbridge.core.compile.BehaviorPack.Entry bpEntry(Pac
assertFalse(bp.containsKey("items/pmb_fixture/test_block.json"), "ブロックアイテムはファイルを作らない");
String shaped = text(bp, "recipes/pmb_fixture/test_block.json");
assertTrue(shaped.contains("minecraft:recipe_shaped") && shaped.contains("\"item\": \"pmb_fixture:test_ingot\""), shaped);
assertEquals("pmb_fixture:test_ingot", unlockedBy(shaped, "minecraft:recipe_shaped"));
String shapeless = text(bp, "recipes/pmb_fixture/test_ingot_from_block.json");
assertTrue(shapeless.contains("minecraft:recipe_shapeless") && shapeless.contains("\"count\": 9"), shapeless);
assertEquals("pmb_fixture:test_block", unlockedBy(shapeless, "minecraft:recipe_shapeless"));
assertEquals("GENERATED", bpEntry(r, "RECIPE", "pmb_fixture:test_block").status());
assertEquals("PARTIAL", bpEntry(r, "ITEM", "pmb_fixture:test_ingot").status(), "コードで決まる性質は変換しない");
assertTrue(bpEntry(r, "BLOCK", "pmb_fixture:test_block").notes().get(0).contains("コードで決まる"));
Expand All @@ -509,6 +512,11 @@ private static dev.puicore.modbridge.core.compile.BehaviorPack.Entry bpEntry(Pac
assertEquals(1, mapping(r).notConverted().size());
}

private static String unlockedBy(String recipe, String kind) {
return JsonParser.parseString(recipe).getAsJsonObject().getAsJsonObject(kind)
.getAsJsonArray("unlock").get(0).getAsJsonObject().get("item").getAsString();
}

@Test
void 変換できないレシピは理由を付けて外し_バニラのIDは注記する() throws IOException {
Map<String, byte[]> m = fixture("rec");
Expand Down
11 changes: 8 additions & 3 deletions docs/adr/0006-mode-b-behavior-pack.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0006: Mode B のビヘイビアパック生成と .mcaddon

- 状態: 採用(BDS・実機では未検証)
- 状態: 採用(Minecraft for Windows 26.65 で素材とレシピを確認、公式 BDS は未検証)
- 日付: 2026-11-27
- 関連: #6, #4, #1、前提は ADR-0004

Expand Down Expand Up @@ -90,10 +90,15 @@ Mode B では、Java の MOD のコードを BDS で動かさず、宣言デー
- `DATA_NOT_CONVERTED`: pmb_fixture(`data/minecraft/tags` 1、`data/pmb_fixture/loot_table` 1)
- 別々の JVM で 3 回作って、成果物のバイト列が一致した

## Minecraft for Windows 26.65 のローカル実測(2026-11-28)

- Bedrock のコンテンツログで、`unlock` がない 1.20 以降のレシピが読み込まれないことを確認した。
- 変換後の材料 ID を解放条件に入れた定形・不定形レシピは、純正クライアントで読み込みエラーがなく、作業台で fixture のブロック1個からインゴット9個を得て、ブロック1個へ戻せた。Java の進捗に基づく解放条件の変換は対象外。

## 未検証・既知の制約

- **BDS とローカルワールドでの動作確認は未実施**。書式は資料(Microsoft Learn)に基づく。BDS の起動には、Minecraft の EULA とプライバシーポリシーへの同意が要る。これは owner の判断なので、別に確認してから行う。
- 次の PR で、BDS への配置(dry-run 既定、停止中のバックアップ、apply・rollback、`world_resource_packs.json`・`world_behavior_packs.json`)を扱う。
- 公式 BDS でのパック読込、複数人参加、再起動後の保存は未確認。
- BDS への配置と復旧の設計は [ADR-0007](0007-bds-install-and-rollback.md) を参照。
- Java のコードで決まる性質は、Mode A で取得した実行時レジストリから補える見込み。実行時レジストリにスタック数・硬さなどを足すのは、将来の課題。
- レシピのバニラのアイテム ID の対応表は無い。
- 立方体以外の形、状態を持つブロック、ブロックのドロップ(ルートテーブル)、道具の条件は変換しない。
Expand Down
Loading