Skip to content

Commit

Permalink
Crop the first frame from animated item textures.
Browse files Browse the repository at this point in the history
Item textures are not animated in minetest.
See minetest-tools#9
  • Loading branch information
ensonic committed Aug 6, 2017
1 parent 1937437 commit e37b6eb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions mcresconvert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ convert_alphatex() {
fi
}

copy_or_crop_from_anim() {
IN=$1
OUT=$2

crop="0"
if [ -f "$IN.mcmeta" ]; then
if grep -q "animation" "$IN.mcmeta"; then
# items are never animated in minetest
if echo $IN | grep -q "/items/"; then
crop="1"
fi
fi
fi

if [ "$crop" == "1" ]; then
convert "$IN" -crop ${PXSIZE}x${PXSIZE} -depth 8 "$OUT"
else
cp "$IN" "$OUT"
fi
}

compose_door() {
l=$1
u=$2
Expand Down Expand Up @@ -343,10 +364,10 @@ RENAMES
echo -e "." >> _n/_tot
if [ -f "_n/$IN" ]; then
echo -e "." >> _n/_counter
cp "_n/$IN" "$OUT"
copy_or_crop_from_anim "_n/$IN" "$OUT"
elif [ -f "_z/$IN" ]; then
echo -e "." >> _n/_counter
cp "_z/$IN" "$OUT"
copy_or_crop_from_anim "_z/$IN" "$OUT"
# uncomment below 2 lines to see if any textures were not found.
else
echo "+$IN $OUT $FLAG: Not Found"
Expand Down

0 comments on commit e37b6eb

Please sign in to comment.