Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short_grass #101

Merged
merged 4 commits into from
Jan 6, 2024
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
72 changes: 69 additions & 3 deletions scripts/average.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is a good idea, the implementation of this script will make it harder to run on non-mac platforms. I will rework it to keep all of the code but make it more modular.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,72 @@

set -eo pipefail

printf '%s\t%s\n' \
"$(basename "${1}")" \
"$(convert "${1}" -resize 1x1 txt:- | grep -Po "#[[:xdigit:]]{6}" | tr A-F a-f)"
SYSTEM="$(uname)"
EXTRACTDIR=/tmp/extracted_blocks

macos::install_deps() {
# Script requires imagemagick
if ! command -v convert &>/dev/null; then
if [[ "$SYSTEM" == "Darwin" ]] && command -v brew &>/dev/null; then
brew install imagemagick
fi
fi
}

macos::mc_home() {
echo $HOME/Library/Application Support/minecraft/versions
}

linux::mc_home() {
echo $HOME/.minecraft/versions
}

unpack_assets() {
case "$SYSTEM" in
Darwin)
MC_HOME="$(macos::mc_home)"
;;
Linux)
MC_HOME="$(linux::mc_home)"
;;
esac

if [[ -z "$MINECRAFT_VER" ]]; then
return
fi

JAR="$MC_HOME/$MINECRAFT_VER/$MINECRAFT_VER.jar"

if [[ -n "$JAR" ]]; then
mkdir -p "$EXTRACTDIR/$MINECRAFT_VER"
pushd "$EXTRACTDIR/$MINECRAFT_VER"
jar xf "$JAR" assets/minecraft/textures/block
popd
fi
}

average() {
FILE="$1"
EXTRACTED="$EXTRACTDIR/$MINECRAFT_VER/assets/minecraft/textures/block/$1.png"
if [[ -f "$EXTRACTED" ]] ; then
FILE="$EXTRACTED"
fi

COLOR="$(convert "$FILE" -resize 1x1 txt:- \
| grep -o "#[[:xdigit:]]\{6\}" \
| tr A-F a-f)"

printf '%s\t%s\n' \
"$(basename "$FILE")" \
"$COLOR"
}

if [[ "$SYSTEM" == Darwin ]] ; then
macos::install_deps

if [[ ! -d "$EXTRACTDIR/assets/minecraft/textures/" ]] ; then
unpack_assets
fi
fi

average "$1"
1 change: 1 addition & 0 deletions src/colors.json
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@
"minecraft:sea_lantern": "#90b8ad",
"minecraft:sea_pickle": { "color": "#4e531dfe", "type": "Head" },
"minecraft:seagrass": { "color": "#389306fe", "type": "UnderwaterPlant" },
"minecraft:short_grass": { "color": "#426539fe", "type": "Plant" },
"minecraft:shroomlight": "#f2974c",
"minecraft:shulker_box": "#8535c3",
"minecraft:skeleton_skull": { "color": "#969696fe", "type": "Head" },
Expand Down
Loading