[Shell屎山系列 - 1] MC材质打包器1.0
本帖最后由 我是李君子 于 2024-3-3 15:40 编辑本人由于高考在即( 开学了 ) 暂时不会经常在论坛发言
功能 :
• 将特定格式的目录做成Java版和基岩版的材质包
指定目录格式 :
• icon.png/jpg #图标
• 其他与基岩版textures文件夹下文件的命名一致
代码 :
( 屎山准备
• 初始化
#!/bin/sh
clear
date=`date +"%Y-%m-%d %H:%M:%S"`
if mkdir texture_packs; then
echo -e "材质包存放目录创建完成"
touch README.txt
echo -e "目录介绍\nTexture_packs : 存放完成的材质包\n你可以在里面找到你的材质包和打包好的文件\n另外 请讲包图标命名为icon.png/jpg/jpeg" > README.txt
touch PATH.log
echo -e "[ $date ] 初始化完成" > PATH.log
cat README.txt
fi
• 日志查看
#!/bin/sh
dialog --msgbox "全部日志:\n$(cat ./PATH.log)" 70 20
• 制作 ( 你们想看的屎山
LINUX 用
#!/bin/sh
clear
date=`date +"%Y-%m-%d %H:%M:%S"`
uuid1=`cat /proc/sys/kernel/random/uuid`
uuid2=`cat /proc/sys/kernel/random/uuid`
#echo -e "--------该脚本适用于Linux系统-------\n"
texture_pack_name=$(dialog --inputbox "材质包名称: " 50 25 --stdout)
texture_pack_show=$(dialog --inputbox "材质包介绍: " 50 25 --stdout)
texture_pack_ver=$(dialog --inputbox "材质适配版本( 版本号最后一个数+1 ): " 50 25 --stdout)
texture_pack_path=$(dialog --inputbox "材质源Path: " 50 25 --stdout)
icon(){
if [ -e $texture_pack_path/icon.png ]; then
cp $texture_pack_path/icon.png $1
cp $texture_pack_path/icon.png $2
elif [ -e $texture_pack_path/icon.jpg ]; then
cp $texture_pack_path/icon.jpg $1
cp $texture_pack_path/icon.jpg $2
fi; }
mkdir ./texture_packs/$texture_pack_name
mkdir ./texture_packs/$texture_pack_name/Java
mkdir ./texture_packs/$texture_pack_name/Java/assets
mkdir ./texture_packs/$texture_pack_name/Java/assets/minecraft
#mkdir ./texture_packs/$texture_pack_name/Java/assets/minecraft/textures
touch ./texture_packs/$texture_pack_name/Java/pack.mcmeta
cp -r $texture_pack_path ./texture_packs/$texture_pack_name/Java/assets/minecraft/textures/
echo -e "{\"pack\": {\"pack_format\": $texture_pack_ver,\"description\": \"$texture_pack_show\"}}" > ./texture_packs/$texture_pack_name/Java/pack.mcmeta
echo "[ $date ] 创建JAVA版材质包$texture_pack_name" >> PATH.log
mkdir ./texture_packs/$texture_pack_name/Bedrock
touch ./texture_packs/$texture_pack_name/Bedrock/manifest.json
echo -e "{\"format_version\": 2,\"header\": {\"description\": \"$texture_pack_show\",\"name\": \"$texture_pack_name\",\"uuid\": \"$uuid1\",\"version\": ,\"min_engine_version\": [ 1, 1`expr $texture_pack_ver - 1`,00 ]},\"modules\": [{\"type\": \"resources\", \"uuid\": \"$uuid2\",\"version\": }]}" > ./texture_packs/$texture_pack_name/Bedrock/manifest.json
cp -r $texture_pack_path ./texture_packs/$texture_pack_name/Bedrock/textures/
echo "[ $date ] 创建BEDROCK版材质包$texture_pack_name" >> PATH.log
icon ./texture_packs/$texture_pack_name/Java/pack.png ./texture_packs/$texture_pack_name/Bedrock/pack_icon.png
if zip -r "./texture_packs/$texture_pack_name/Java/$texture_pack_name.zip" ./texture_packs/$texture_pack_name/Java/; then
dialog --msgbox "$texture_pack_name.zip 打包成功" 200 120
else
dialog --msgbox "$texture_pack_name.zip 打包失败" 200 120; fi
if zip -r "./texture_packs/$texture_pack_name/Bedrock/$texture_pack_name.mcpack" ./texture_packs/$texture_pack_name/Bedrock/; then
dialog --msgbox "$texture_pack_name.zip 打包成功" 200 120
else
dialog --msgbox "$texture_pack_name.zip 打包失败" 200 120; fi
dialog --msgbox "制作完成" 200 120
手机模拟器用
#!/bin/sh
clear
date=`date +"%Y-%m-%d %H:%M:%S"`
uuid1=`cat /proc/sys/kernel/random/uuid`
uuid2=`cat /proc/sys/kernel/random/uuid`
echo -e "--------该脚本适用于Android的虚拟Linux环境-------\n"
echo -e "材质包名称: \c"
read texture_pack_name
echo -e "材质包介绍: \c"
read texture_pack_show
echo -e "材质包版本号\n版本号最后一个数字加一 例如: 1.12 => 3: \c"
read texture_pack_ver
echo -e "贴图源目录位置: \c"
read texture_pack_path
icon(){
if [ -e $texture_pack_path/icon.png ]; then
cp $texture_pack_path/icon.png $1
cp $texture_pack_path/icon.png $2
elif [ -e $texture_pack_path/icon.jpg ]; then
cp $texture_pack_path/icon.jpg $1
cp $texture_pack_path/icon.jpg $2
fi; }
mkdir ./texture_packs/$texture_pack_name
mkdir ./texture_packs/$texture_pack_name/Java
mkdir ./texture_packs/$texture_pack_name/Java/assets
mkdir ./texture_packs/$texture_pack_name/Java/assets/minecraft
#mkdir ./texture_packs/$texture_pack_name/Java/assets/minecraft/textures
touch ./texture_packs/$texture_pack_name/Java/pack.mcmeta
cp -r $texture_pack_path ./texture_packs/$texture_pack_name/Java/assets/minecraft/textures/
echo -e "{\"pack\": {\"pack_format\": $texture_pack_ver,\"description\": \"$texture_pack_show\"}}" > ./texture_packs/$texture_pack_name/Java/pack.mcmeta
echo "[ $date ] 创建JAVA版材质包$texture_pack_name" >> PATH.log
mkdir ./texture_packs/$texture_pack_name/Bedrock
touch ./texture_packs/$texture_pack_name/Bedrock/manifest.json
echo -e "{\"format_version\": 2,\"header\": {\"description\": \"$texture_pack_show\",\"name\": \"$texture_pack_name\",\"uuid\": \"$uuid1\",\"version\": ,\"min_engine_version\": [ 1, 1`expr $texture_pack_ver - 1`,00 ]},\"modules\": [{\"type\": \"resources\", \"uuid\": \"$uuid2\",\"version\": }]}" > ./texture_packs/$texture_pack_name/Bedrock/manifest.json
cp -r $texture_pack_path ./texture_packs/$texture_pack_name/Bedrock/textures/
echo "[ $date ] 创建BEDROCK版材质包$texture_pack_name" >> PATH.log
icon ./texture_packs/$texture_pack_name/Java/pack.png ./texture_packs/$texture_pack_name/Bedrock/pack_icon.png
if zip -r "./texture_packs/$texture_pack_name/Java/$texture_pack_name.zip" ./texture_packs/$texture_pack_name/Java/; then
echo -e "$texture_pack_name.zip 打包成功"
else
echo -e "$texture_pack_name.zip 打包失败"; fi
if zip -r "./texture_packs/$texture_pack_name/Bedrock/$texture_pack_name.mcpack" ./texture_packs/$texture_pack_name/Bedrock/; then
echo -e "$texture_pack_name.zip 打包成功"
else
echo -e "$texture_pack_name.zip 打包失败"; fi
echo "\n创建完成"
• 快捷观看
• 代码优化方法
将线路转换为变量
将重复的地方封装为函数
• 屎山评级
#原创脚本 所以这是在给自己评级
4.5
• 下载
• 项目官网
( 待补 ) skxhajajnsja 不懂就问:我的世界基岩版支持shell吗?
页: [1]