From cd62048a4dcff0c5e784ed3cf8d45570243ba53d Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Fri, 12 May 2023 21:12:28 -0700 Subject: [PATCH] Trunc skinhash to 32 chars due to 80 char limit Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- .../geyser/pack/SkullResourcePackManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 821251454..1e9f296fc 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java +++ b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java @@ -205,7 +205,7 @@ public class SkullResourcePackManager { private static void addAttachables(ZipOutputStream zipOS) throws IOException { String template = FileUtils.readToString("bedrock/skull_resource_pack/attachables/template_attachable.json"); for (CustomSkull skull : BlockRegistries.CUSTOM_SKULLS.get().values()) { - ZipEntry entry = new ZipEntry("skull_resource_pack/attachables/" + skull.getSkinHash() + ".json"); + ZipEntry entry = new ZipEntry("skull_resource_pack/attachables/" + truncateHash(skull.getSkinHash()) + ".json"); zipOS.putNextEntry(entry); zipOS.write(fillAttachableJson(template, skull).getBytes(StandardCharsets.UTF_8)); zipOS.closeEntry(); @@ -214,7 +214,7 @@ public class SkullResourcePackManager { private static void addSkinTextures(ZipOutputStream zipOS) throws IOException { for (Path skinPath : SKULL_SKINS.values()) { - ZipEntry entry = new ZipEntry("skull_resource_pack/textures/blocks/" + skinPath.getFileName()); + ZipEntry entry = new ZipEntry("skull_resource_pack/textures/blocks/" + truncateHash(skinPath.getFileName().toString()) + ".png"); zipOS.putNextEntry(entry); try (InputStream stream = Files.newInputStream(skinPath)) { stream.transferTo(zipOS); @@ -231,7 +231,7 @@ public class SkullResourcePackManager { private static String fillAttachableJson(String template, CustomSkull skull) { return template.replace("${identifier}", skull.getCustomBlockData().identifier()) - .replace("${texture}", skull.getSkinHash()); + .replace("${texture}", truncateHash(skull.getSkinHash())); } private static String fillManifestJson(String template) { @@ -243,7 +243,7 @@ public class SkullResourcePackManager { private static String fillTerrainTextureJson(String template) { StringBuilder textures = new StringBuilder(); for (String skinHash : SKULL_SKINS.keySet()) { - String texture = String.format("\"geyser.%s_player_skin\":{\"textures\":\"textures/blocks/%s\"},\n", skinHash, skinHash); + String texture = String.format("\"geyser.%s_player_skin\":{\"textures\":\"textures/blocks/%s\"},\n", skinHash, truncateHash(skinHash)); textures.append(texture); } if (textures.length() != 0) { @@ -298,4 +298,8 @@ public class SkullResourcePackManager { } return false; } + + private static String truncateHash(String hash) { + return hash.substring(0, Math.min(hash.length(), 32)); + } }