Skip to content

Instantly share code, notes, and snippets.

@thebrightspark
Last active August 16, 2023 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebrightspark/ae22459e162fd2b3d5d0c4746a534341 to your computer and use it in GitHub Desktop.
Save thebrightspark/ae22459e162fd2b3d5d0c4746a534341 to your computer and use it in GitHub Desktop.
BlockBench GeckoLib Plugin Armor JSON Export Fix JQ Filter

Description

This Gist contains a JQ filter to fix the broken armour JSON exports from the BlockBench GeckoLib plugin in two different formats, but using the exact same solution.

This solution was created using Ubuntu, but you can adapt it to be used for others assuming you can install jq.
See the jq docs for more info and how to install: https://jqlang.github.io/jq/

How To Use

Use either one of the below options:

Single Command

Use the single_command.sh to execute the jq command directly in your (Linux) CLI.

This assumes the input (broken) file is named broken_armor.geo.json, and the output will be a file named armor.geo.json.

Filter File

Create a file and put the contents of jqFilter into it.

Then execute echo $(<broken_armor.geo.json) | jq -f jqFilter > armor.geo.json. Replace file names as appropriate.

# BlockBench GeckoLib Plugin Armor JSON Export Fix Filter
# by bright_spark
#
# This does 2 things:
# 1) Sets the geometry identifier to "geometry.geckoarmor"
# 2) Adds the base biped bones to the bones array
[{name:"bipedHead",pivot:[0,24,0]},{name:"bipedBody",pivot:[0,24,0]},{name:"bipedRightArm",pivot:[-4,22,0]},{name:"bipedLeftArm",pivot:[4,22,0]},{name:"bipedLeftLeg",pivot:[-1.9,12,0]},{n>as $biped_bones |
{
format_version,
"minecraft:geometry": (.["minecraft:geometry"] | .[0] | .description.identifier = "geometry.geckoarmor" | .bones = .bones + $biped_bones)
}
echo $(<broken_armor.geo.json) | jq '{format_version, "minecraft:geometry": (.["minecraft:geometry"] | .[0] | .description.identifier = "geometry.geckoarmor" | .bones = .bones + [{name:"bipedHead",pivot:[0,24,0]},{name:"bipedBody",pivot:[0,24,0]},{name:"bipedRightArm",pivot:[-4,22,0]},{name:"bipedLeftArm",pivot:[4,22,0]},{name:"bipedLeftLeg",pivot:[-1.9,12,0]},{name:"bipedRightLeg",pivot:[1.9,12,0]}])}' > armor.geo.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment