Skip to content

Instantly share code, notes, and snippets.

@Kas-tle
Last active December 29, 2020 06:54
Show Gist options
  • Save Kas-tle/e2fae70f9e18eadc32b7ce2f01d275ea to your computer and use it in GitHub Desktop.
Save Kas-tle/e2fae70f9e18eadc32b7ce2f01d275ea to your computer and use it in GitHub Desktop.
Java to Bedrock JQ Mappings
// mappings reference java_model.json below
// note that 2 in the UV mapping multiplcation is derived from dividing .texture_size[0] by 16 for x and .texture_size[1] by 16 for y
{
"format_version": "1.12.0", // arbitrary
"minecraft:geometry": [{
"description": {
"identifier": "geometry.geometry.armor_stand", // arbitrary
"texture_width": 32, // '.texture_size[0]'
"texture_height": 32, // '.texture_size[1]'
"visible_bounds_width": 3, // arbitrary (entity rendering box)
"visible_bounds_height": 3.5, // arbitrary (entity rendering box)
"visible_bounds_offset": [0, 1.25, 0] // arbitrary (entity rendering box)
},
"bones": [{
"name": "head", // '.groups[0].name'
"pivot": [0, 24, 0], // '.groups[0].origin'
"mirror": true, // mirror UV on x-axis & flip e/w faces. We add this as in most cases it simplifies our remappings.
"cubes": [{
"origin": [-1, 24, -1], // '[(- .elements[0].from[0] - (.elements[0].to[0] - .elements[0].from[0])), (.elements[0].from[1]), (.elements[0].from[2])]'
"size": [2, 7, 2], // '[.elements[0].to[0] - .elements[0].from[0], .elements[0].to[1] - .elements[0].from[1], .elements[0].to[2] - .elements[0].from[2]]'
"uv": { // note that our north, south, east, and west UV mappings use the same exression, while our up and down mappings use a slightly different one.
"north": {
"uv": [8, 12], // '.elements[0].faces.north.uv[:2] | map_values(.*2)'
"uv_size": [2, 7] // '[(.elements[0].faces.north.uv[2] - .elements[0].faces.north.uv[0]) * 2, (.elements[0].faces.north.uv[3] - .elements[0].faces.north.uv[1]) * 2]'
},
"east": {
"uv": [10, 12], // '.elements[0].faces.east.uv[:2] | map_values(.*2)'
"uv_size": [2, 7] // '[(.elements[0].faces.east.uv[2] - .elements[0].faces.east.uv[0]) * 2, (.elements[0].faces.east.uv[3] - .elements[0].faces.east.uv[1]) * 2]'
},
"south": {
"uv": [12, 12], // '.elements[0].faces.south.uv[:2] | map_values(.*2)'
"uv_size": [2, 7] // '[(.elements[0].faces.south.uv[2] - .elements[0].faces.south.uv[0]) * 2, (.elements[0].faces.south.uv[3] - .elements[0].faces.south.uv[1]) * 2]'
},
"west": {
"uv": [12, 0], // '.elements[0].faces.west.uv[:2] | map_values(.*2)'
"uv_size": [2, 7] // '[(.elements[0].faces.west.uv[2] - .elements[0].faces.west.uv[0]) * 2, (.elements[0].faces.west.uv[3] - .elements[0].faces.west.uv[1]) * 2]'
},
"up": {
"uv": [12, 10], // '.elements[0].faces.up.uv[2:] | map_values(.*2)'
"uv_size": [2, 2] // '[(.elements[0].faces.up.uv[2] - .elements[0].faces.up.uv[0]) * -2, (.elements[0].faces.up.uv[3] - .elements[0].faces.up.uv[1]) * -2]'
},
"down": {
"uv": [14, 2], // '.elements[0].faces.down.uv[2:] | map_values(.*2)'
"uv_size": [2, -2] // '[(.elements[0].faces.down.uv[2] - .elements[0].faces.down.uv[0]) * -2, (.elements[0].faces.down.uv[3] - .elements[0].faces.down.uv[1]) * -2]'
}
}
}]
},
{
"name": "body", // '.groups[1].name'
"pivot": [0, 24, 0], // '.groups[1].origin'
"mirror": true,
"cubes": [{
"origin": [-6, 21, -1.5], // Size and origin follow same format as previous (iterate elements array by 1)
"size": [12, 3, 3],
"uv": { // UV values follow same format as previous (iterate elements array by 1)
"north": {
"uv": [0, 0],
"uv_size": [12, 3]
},
"east": {
"uv": [12, 7],
"uv_size": [3, 3]
},
"south": {
"uv": [0, 3],
"uv_size": [12, 3]
},
"west": {
"uv": [14, 14],
"uv_size": [3, 3]
},
"up": {
"uv": [0, 6],
"uv_size": [12, 3]
},
"down": {
"uv": [0, 12],
"uv_size": [12, -3]
}
}
}]
},
{
"name": "rightArm", // '.groups[1].children[1].name'
"parent": "body", // applied to all groups listed in '.groups[1].children[]'
"pivot": [5, 22, 0], // '.groups[1].children[1].origin'
"mirror": true,
"cubes": [{
"origin": [4.5, 11.5, -1.5], // Size and origin follow same format as previous (iterate elements array by 1)
"size": [3, 13, 3],
"pivot": [-8, 8, 8], // [- .elements[2].rotation.origin[0], .elements[2].rotation.origin[1], .elements[2].rotation.origin[2]]
"rotation": [-22.5, 0, 0], // 'if (.elements[2].rotation.axis) == "x" then [(.elements[2].rotation.angle | tonumber), 0, 0] elif (.elements[2].rotation.origin) == "y" then [0, (.elements[2].rotation.angle | tonumber), 0] elif (.elements[2].rotation.origin) == "z" then [0, 0, (.elements[2].rotation.angle | tonumber)] else empty end'
"uv": { // UV values follow same format as previous (iterate elements array by 1)
"north": {
"uv": [0, 12],
"uv_size": [2, 12]
},
"east": {
"uv": [2, 12],
"uv_size": [2, 12]
},
"south": {
"uv": [4, 12],
"uv_size": [2, 12]
},
"west": {
"uv": [6, 12],
"uv_size": [2, 12]
},
"up": {
"uv": [14, 2],
"uv_size": [2, 2]
},
"down": {
"uv": [14, 6],
"uv_size": [2, -2]
}
}
}]
}
]
}]
}
{
"credit": "Made by with Blockbench.",
"texture_size": [32, 32],
"textures": {
"0": "block/texture",
"particle": "block/texture"
},
"elements": [{
"name": "head",
"from": [-1, 24, -1],
"to": [1, 31, 1],
"shade": false,
"faces": {
"north": {
"uv": [4, 6, 5, 9.5],
"texture": "#0"
},
"east": {
"uv": [5, 6, 6, 9.5],
"texture": "#0"
},
"south": {
"uv": [6, 6, 7, 9.5],
"texture": "#0"
},
"west": {
"uv": [6, 0, 7, 3.5],
"texture": "#0"
},
"up": {
"uv": [7, 6, 6, 5],
"texture": "#0"
},
"down": {
"uv": [8, 0, 7, 1],
"texture": "#0"
}
}
},
{
"name": "body",
"from": [-6, 21, -1.5],
"to": [6, 24, 1.5],
"shade": false,
"faces": {
"north": {
"uv": [0, 0, 6, 1.5],
"texture": "#0"
},
"east": {
"uv": [6, 3.5, 7.5, 5],
"texture": "#0"
},
"south": {
"uv": [0, 1.5, 6, 3],
"texture": "#0"
},
"west": {
"uv": [7, 7, 8.5, 8.5],
"texture": "#0"
},
"up": {
"uv": [6, 4.5, 0, 3],
"texture": "#0"
},
"down": {
"uv": [6, 4.5, 0, 6],
"texture": "#0"
}
}
},
{
"name": "rightArm",
"from": [-7.5, 11.5, -1.5],
"to": [-4.5, 24.5, 1.5],
"shade": false,
"rotation": {"angle": 22.5, "axis": "x", "origin": [8, 8, 8]},
"faces": {
"north": {
"uv": [0, 6, 1, 12],
"texture": "#0"
},
"east": {
"uv": [1, 6, 2, 12],
"texture": "#0"
},
"south": {
"uv": [2, 6, 3, 12],
"texture": "#0"
},
"west": {
"uv": [3, 6, 4, 12],
"texture": "#0"
},
"up": {
"uv": [8, 2, 7, 1],
"texture": "#0"
},
"down": {
"uv": [8, 2, 7, 3],
"texture": "#0"
}
}
}
],
"groups": [{
"name": "head",
"origin": [0, 24, 0],
"shade": false,
"children": [0]
},
{
"name": "body",
"origin": [0, 24, 0],
"shade": false,
"children": [1,
{
"name": "rightArm",
"origin": [-5, 22, 0],
"shade": false,
"children": [2]
}
]
}
]
}
@Kas-tle
Copy link
Author

Kas-tle commented Dec 18, 2020

Also would just like to note that I have also included how to map the groups over, though this is entirely not needed for the conversion process, so I would just ignore .groups entirely. Do also note that in the actual model you will need to bring over the bone structure of the player model and place the root bone of the item model we have generated in the appropriate bone for the player (e.g. rightItem, hat). Also keep in mind that no single face is required to exist, so no reliance should be made on the number of faces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment