mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Trunc skinhash to 32 chars due to 80 char limit
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
parent
bbd297c5d9
commit
cd62048a4d
1 changed files with 8 additions and 4 deletions
|
@ -205,7 +205,7 @@ public class SkullResourcePackManager {
|
||||||
private static void addAttachables(ZipOutputStream zipOS) throws IOException {
|
private static void addAttachables(ZipOutputStream zipOS) throws IOException {
|
||||||
String template = FileUtils.readToString("bedrock/skull_resource_pack/attachables/template_attachable.json");
|
String template = FileUtils.readToString("bedrock/skull_resource_pack/attachables/template_attachable.json");
|
||||||
for (CustomSkull skull : BlockRegistries.CUSTOM_SKULLS.get().values()) {
|
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.putNextEntry(entry);
|
||||||
zipOS.write(fillAttachableJson(template, skull).getBytes(StandardCharsets.UTF_8));
|
zipOS.write(fillAttachableJson(template, skull).getBytes(StandardCharsets.UTF_8));
|
||||||
zipOS.closeEntry();
|
zipOS.closeEntry();
|
||||||
|
@ -214,7 +214,7 @@ public class SkullResourcePackManager {
|
||||||
|
|
||||||
private static void addSkinTextures(ZipOutputStream zipOS) throws IOException {
|
private static void addSkinTextures(ZipOutputStream zipOS) throws IOException {
|
||||||
for (Path skinPath : SKULL_SKINS.values()) {
|
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);
|
zipOS.putNextEntry(entry);
|
||||||
try (InputStream stream = Files.newInputStream(skinPath)) {
|
try (InputStream stream = Files.newInputStream(skinPath)) {
|
||||||
stream.transferTo(zipOS);
|
stream.transferTo(zipOS);
|
||||||
|
@ -231,7 +231,7 @@ public class SkullResourcePackManager {
|
||||||
|
|
||||||
private static String fillAttachableJson(String template, CustomSkull skull) {
|
private static String fillAttachableJson(String template, CustomSkull skull) {
|
||||||
return template.replace("${identifier}", skull.getCustomBlockData().identifier())
|
return template.replace("${identifier}", skull.getCustomBlockData().identifier())
|
||||||
.replace("${texture}", skull.getSkinHash());
|
.replace("${texture}", truncateHash(skull.getSkinHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String fillManifestJson(String template) {
|
private static String fillManifestJson(String template) {
|
||||||
|
@ -243,7 +243,7 @@ public class SkullResourcePackManager {
|
||||||
private static String fillTerrainTextureJson(String template) {
|
private static String fillTerrainTextureJson(String template) {
|
||||||
StringBuilder textures = new StringBuilder();
|
StringBuilder textures = new StringBuilder();
|
||||||
for (String skinHash : SKULL_SKINS.keySet()) {
|
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);
|
textures.append(texture);
|
||||||
}
|
}
|
||||||
if (textures.length() != 0) {
|
if (textures.length() != 0) {
|
||||||
|
@ -298,4 +298,8 @@ public class SkullResourcePackManager {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String truncateHash(String hash) {
|
||||||
|
return hash.substring(0, Math.min(hash.length(), 32));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue