Convert skull floor geometries into a template

Should be easier to modify in needed in the future.
This commit is contained in:
davchoo 2022-07-27 18:43:42 -04:00
parent 5676870dd8
commit 8244afa8c7
No known key found for this signature in database
GPG key ID: A0168C8E45799B7D
6 changed files with 22 additions and 96 deletions

View file

@ -53,7 +53,7 @@ import java.util.zip.ZipOutputStream;
public class SkullResourcePackManager {
private static final long RESOURCE_PACK_VERSION = 5;
private static final long RESOURCE_PACK_VERSION = 6;
private static final Path SKULL_SKIN_CACHE_PATH = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("cache").resolve("player_skulls");
@ -170,6 +170,8 @@ public class SkullResourcePackManager {
zipOS.closeEntry();
}
addFloorGeometries(zipOS);
ZipEntry entry = new ZipEntry("skull_resource_pack/pack_icon.png");
zipOS.putNextEntry(entry);
zipOS.write(FileUtils.readAllBytes("icon.png"));
@ -177,6 +179,23 @@ public class SkullResourcePackManager {
}
}
private static void addFloorGeometries(ZipOutputStream zipOS) throws IOException {
String template = new String(FileUtils.readAllBytes("bedrock/skull_resource_pack/models/blocks/player_skull_floor.geo.json"), StandardCharsets.UTF_8);
String[] quadrants = {"a", "b", "c", "d"};
for (int i = 0; i < quadrants.length; i++) {
String quadrant = quadrants[i];
float yRotation = i * 22.5f;
String contents = template
.replace("${quadrant}", quadrant)
.replace("${y_rotation}", String.valueOf(yRotation));
ZipEntry entry = new ZipEntry("skull_resource_pack/models/blocks/player_skull_floor_" + quadrant + ".geo.json");
zipOS.putNextEntry(entry);
zipOS.write(contents.getBytes(StandardCharsets.UTF_8));
zipOS.closeEntry();
}
}
private static void addAttachables(ZipOutputStream zipOS) throws IOException {
String template = new String(FileUtils.readAllBytes("bedrock/skull_resource_pack/attachables/template_attachable.json"), StandardCharsets.UTF_8);
for (String skinHash : SKULL_SKINS.keySet()) {

View file

@ -3,7 +3,7 @@
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.geyser.player_skull_floor_a",
"identifier": "geometry.geyser.player_skull_floor_${quadrant}",
"texture_width": 64,
"texture_height": 64
},
@ -11,6 +11,7 @@
{
"name": "head",
"pivot": [0, 24, 0],
"rotation": [0, ${y_rotation}, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [0, 0]}
]

View file

@ -1,30 +0,0 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.geyser.player_skull_floor_b",
"texture_width": 64,
"texture_height": 64
},
"bones": [
{
"name": "head",
"pivot": [0, 24, 0],
"rotation": [0, 22.5, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [0, 0]}
]
},
{
"name": "hat",
"parent": "head",
"pivot": [0, 24, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [32, 0], "inflate": 0.5}
]
}
]
}
]
}

View file

@ -1,30 +0,0 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.geyser.player_skull_floor_c",
"texture_width": 64,
"texture_height": 64
},
"bones": [
{
"name": "head",
"pivot": [0, 24, 0],
"rotation": [0, 45, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [0, 0]}
]
},
{
"name": "hat",
"parent": "head",
"pivot": [0, 24, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [32, 0], "inflate": 0.5}
]
}
]
}
]
}

View file

@ -1,30 +0,0 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.geyser.player_skull_floor_d",
"texture_width": 64,
"texture_height": 64
},
"bones": [
{
"name": "head",
"pivot": [0, 24, 0],
"rotation": [0, 67.5, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [0, 0]}
]
},
{
"name": "hat",
"parent": "head",
"pivot": [0, 24, 0],
"cubes": [
{"origin": [-4, 0.5, -4], "size": [8, 8, 8], "uv": [32, 0], "inflate": 0.5}
]
}
]
}
]
}

View file

@ -1,10 +1,6 @@
skull_resource_pack/animations/disable.animation.json
skull_resource_pack/animations/player_skull.animation.json
skull_resource_pack/models/blocks/player_skull.geo.json
skull_resource_pack/models/blocks/player_skull_floor_a.geo.json
skull_resource_pack/models/blocks/player_skull_floor_c.geo.json
skull_resource_pack/models/blocks/player_skull_floor_b.geo.json
skull_resource_pack/models/blocks/player_skull_floor_d.geo.json
skull_resource_pack/models/blocks/player_skull_hand.geo.json
skull_resource_pack/models/blocks/player_skull_wall.geo.json
skull_resource_pack/textures/terrain_texture.json