From 8244afa8c7889cfc40fdeed894db74513aea108b Mon Sep 17 00:00:00 2001 From: davchoo Date: Wed, 27 Jul 2022 18:43:42 -0400 Subject: [PATCH] Convert skull floor geometries into a template Should be easier to modify in needed in the future. --- .../geyser/pack/SkullResourcePackManager.java | 21 ++++++++++++- ...a.geo.json => player_skull_floor.geo.json} | 3 +- .../blocks/player_skull_floor_b.geo.json | 30 ------------------- .../blocks/player_skull_floor_c.geo.json | 30 ------------------- .../blocks/player_skull_floor_d.geo.json | 30 ------------------- .../bedrock/skull_resource_pack_files.txt | 4 --- 6 files changed, 22 insertions(+), 96 deletions(-) rename core/src/main/resources/bedrock/skull_resource_pack/models/blocks/{player_skull_floor_a.geo.json => player_skull_floor.geo.json} (92%) delete mode 100644 core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_b.geo.json delete mode 100644 core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_c.geo.json delete mode 100644 core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_d.geo.json diff --git a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java index 2e6c60339..e61b9190d 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java +++ b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java @@ -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()) { diff --git a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_a.geo.json b/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor.geo.json similarity index 92% rename from core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_a.geo.json rename to core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor.geo.json index 743236a5d..992ab4aab 100644 --- a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_a.geo.json +++ b/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor.geo.json @@ -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]} ] diff --git a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_b.geo.json b/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_b.geo.json deleted file mode 100644 index 0bbe1c1f6..000000000 --- a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_b.geo.json +++ /dev/null @@ -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} - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_c.geo.json b/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_c.geo.json deleted file mode 100644 index c633977ab..000000000 --- a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_c.geo.json +++ /dev/null @@ -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} - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_d.geo.json b/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_d.geo.json deleted file mode 100644 index 7436944e7..000000000 --- a/core/src/main/resources/bedrock/skull_resource_pack/models/blocks/player_skull_floor_d.geo.json +++ /dev/null @@ -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} - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/core/src/main/resources/bedrock/skull_resource_pack_files.txt b/core/src/main/resources/bedrock/skull_resource_pack_files.txt index ecb441cad..83a82b5d2 100644 --- a/core/src/main/resources/bedrock/skull_resource_pack_files.txt +++ b/core/src/main/resources/bedrock/skull_resource_pack_files.txt @@ -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