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
This commit is contained in:
2
.env.example
Normal file
2
.env.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Локальный мир для синхронизации datapacks (bash/sync-datapacks-to-world.sh)
|
||||||
|
LOCAL_WORLD="Новый мир"
|
||||||
67
bash/sync-datapacks-to-world.sh
Executable file
67
bash/sync-datapacks-to-world.sh
Executable file
@ -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
|
||||||
15
datapacks/m2621/data/ironchest/recipe/copper_chest.json
Normal file
15
datapacks/m2621/data/ironchest/recipe/copper_chest.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
datapacks/m2621/data/ironchest/recipe/diamond_chest.json
Normal file
15
datapacks/m2621/data/ironchest/recipe/diamond_chest.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
datapacks/m2621/data/ironchest/recipe/gold_chest.json
Normal file
15
datapacks/m2621/data/ironchest/recipe/gold_chest.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
datapacks/m2621/data/ironchest/recipe/iron_chest.json
Normal file
15
datapacks/m2621/data/ironchest/recipe/iron_chest.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shapeless",
|
"type": "minecraft:crafting_shapeless",
|
||||||
"ingredients": [
|
"ingredients": [],
|
||||||
"minecraft:copper_ingot"
|
"result": {"item": "minecraft:air", "count": 0}
|
||||||
],
|
}
|
||||||
"result": {"id": "minecraft:copper_chest", "count": 0}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user