From 3c3997ec7dd9dd1deac00cd1159ca21ebf9077b9 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Tue, 21 Jul 2026 16:44:58 +0300 Subject: [PATCH] feat(datapacks): add ironchest recipes and datapack sync automation - Add crafting recipes for copper, iron, gold, and diamond chests using IronChest mod - Remove vanilla copper chest recipe to prevent conflicts - Introduce `.env.example` for local world configuration - Add `bash/sync-datapacks-to-world.sh` script to mirror datapacks to Minecraft world saves - Supports one-time sync and watch mode for real-time updates - Uses `rsync` for efficient file synchronization --- .env.example | 2 + bash/sync-datapacks-to-world.sh | 67 ++++++++++++++++++++++ .../m2621/data/ironchest/recipe/copper_chest.json | 15 +++++ .../m2621/data/ironchest/recipe/diamond_chest.json | 15 +++++ .../m2621/data/ironchest/recipe/gold_chest.json | 15 +++++ .../m2621/data/ironchest/recipe/iron_chest.json | 15 +++++ .../m2621/data/minecraft/recipe/copper_chest.json | 8 +-- 7 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100755 bash/sync-datapacks-to-world.sh create mode 100644 datapacks/m2621/data/ironchest/recipe/copper_chest.json create mode 100644 datapacks/m2621/data/ironchest/recipe/diamond_chest.json create mode 100644 datapacks/m2621/data/ironchest/recipe/gold_chest.json create mode 100644 datapacks/m2621/data/ironchest/recipe/iron_chest.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..370d3e1 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +# Локальный мир для синхронизации datapacks (bash/sync-datapacks-to-world.sh) +LOCAL_WORLD="Новый мир" diff --git a/bash/sync-datapacks-to-world.sh b/bash/sync-datapacks-to-world.sh new file mode 100755 index 0000000..023a68d --- /dev/null +++ b/bash/sync-datapacks-to-world.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Зеркальная синхронизация ./datapacks → ./saves/$LOCAL_WORLD/datapacks +# LOCAL_WORLD берётся из .env (см. .env.example). +# +# Использование: +# bash/sync-datapacks-to-world.sh # один раз +# bash/sync-datapacks-to-world.sh --watch # следить за изменениями +# +set -euo pipefail + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) +REPO_ROOT="${SCRIPT_DIR}/.." +ENV_FILE="${REPO_ROOT}/.env" +DATAPACKS_SRC="${REPO_ROOT}/datapacks/" + +if [[ -f "${ENV_FILE}" ]]; then + set -a + # shellcheck disable=SC1090 + source "${ENV_FILE}" + set +a +fi + +LOCAL_WORLD="${LOCAL_WORLD:-Новый мир}" +DATAPACKS_DST="${REPO_ROOT}/saves/${LOCAL_WORLD}/datapacks/" + +sync_once() { + if [[ ! -d "${DATAPACKS_SRC}" ]]; then + echo "Ошибка: не найдена папка ${DATAPACKS_SRC}" + exit 1 + fi + + mkdir -p "${DATAPACKS_DST}" + echo "[$(date '+%H:%M:%S')] ${DATAPACKS_SRC} → ${DATAPACKS_DST}" + rsync -a --delete "${DATAPACKS_SRC}" "${DATAPACKS_DST}" + echo "[$(date '+%H:%M:%S')] готово" +} + +watch_mode() { + if ! command -v inotifywait &> /dev/null; then + echo "Ошибка: inotifywait не найден (пакет inotify-tools)" + exit 1 + fi + + sync_once + echo "Watching ${DATAPACKS_SRC} for changes..." + + while inotifywait -r -e modify,create,delete,move "${DATAPACKS_SRC}" &> /dev/null; do + sync_once + done +} + +case "${1:-}" in + --watch|-w) + watch_mode + ;; + --help|-h) + echo "Usage: $(basename "$0") [--watch]" + ;; + "") + sync_once + ;; + *) + echo "Неизвестный аргумент: $1" + exit 1 + ;; +esac diff --git a/datapacks/m2621/data/ironchest/recipe/copper_chest.json b/datapacks/m2621/data/ironchest/recipe/copper_chest.json new file mode 100644 index 0000000..a9e2d06 --- /dev/null +++ b/datapacks/m2621/data/ironchest/recipe/copper_chest.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "III", + "ISI", + "III" + ], + "key": { + "I": "minecraft:copper_ingot", + "S": "minecraft:chest" + }, + "result": { + "id": "ironchest:copper_chest" + } +} \ No newline at end of file diff --git a/datapacks/m2621/data/ironchest/recipe/diamond_chest.json b/datapacks/m2621/data/ironchest/recipe/diamond_chest.json new file mode 100644 index 0000000..dae2b2f --- /dev/null +++ b/datapacks/m2621/data/ironchest/recipe/diamond_chest.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "III", + "ISI", + "III" + ], + "key": { + "I": "minecraft:diamond", + "S": "ironchest:gold_chest" + }, + "result": { + "id": "ironchest:diamond_chest" + } +} diff --git a/datapacks/m2621/data/ironchest/recipe/gold_chest.json b/datapacks/m2621/data/ironchest/recipe/gold_chest.json new file mode 100644 index 0000000..83c8e01 --- /dev/null +++ b/datapacks/m2621/data/ironchest/recipe/gold_chest.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "III", + "ISI", + "III" + ], + "key": { + "I": "minecraft:gold_ingot", + "S": "ironchest:iron_chest" + }, + "result": { + "id": "ironchest:gold_chest" + } +} diff --git a/datapacks/m2621/data/ironchest/recipe/iron_chest.json b/datapacks/m2621/data/ironchest/recipe/iron_chest.json new file mode 100644 index 0000000..3ba3d33 --- /dev/null +++ b/datapacks/m2621/data/ironchest/recipe/iron_chest.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "III", + "ISI", + "III" + ], + "key": { + "I": "minecraft:iron_ingot", + "S": "ironchest:copper_chest" + }, + "result": { + "id": "ironchest:iron_chest" + } +} diff --git a/datapacks/m2621/data/minecraft/recipe/copper_chest.json b/datapacks/m2621/data/minecraft/recipe/copper_chest.json index d8f4a23..24f380a 100644 --- a/datapacks/m2621/data/minecraft/recipe/copper_chest.json +++ b/datapacks/m2621/data/minecraft/recipe/copper_chest.json @@ -1,7 +1,5 @@ { "type": "minecraft:crafting_shapeless", - "ingredients": [ - "minecraft:copper_ingot" - ], - "result": {"id": "minecraft:copper_chest", "count": 0} -} \ No newline at end of file + "ingredients": [], + "result": {"item": "minecraft:air", "count": 0} +}