From bb67f82701f2ef9da153f878491cd618f1860c1b Mon Sep 17 00:00:00 2001 From: danyadev Date: Sun, 6 Sep 2026 19:43:18 +0300 Subject: [PATCH] optimize resource reload (#2070) --- gradle/libs.versions.toml | 2 +- .../mal/resource/ResourceLocationWithSource.java | 11 ++++++----- .../prupe/mcpatcher/mal/resource/TexturePackAPI.java | 11 +++++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ae61f4c5a..19f6ae345 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ log4j = "2.0-beta9" asmCompile = "5.0.3" # End Frozen -lwjgl3 = "3.4.2-20260602.093430-9" +lwjgl3 = "3.4.2" lwjgl3ify = "3.0.31" celeritas = "2.5.10-GTNH" diff --git a/src/main/java/com/prupe/mcpatcher/mal/resource/ResourceLocationWithSource.java b/src/main/java/com/prupe/mcpatcher/mal/resource/ResourceLocationWithSource.java index 9deca80b3..aa26024aa 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/resource/ResourceLocationWithSource.java +++ b/src/main/java/com/prupe/mcpatcher/mal/resource/ResourceLocationWithSource.java @@ -15,14 +15,15 @@ public class ResourceLocationWithSource extends ResourceLocation { private final boolean isDirectory; public ResourceLocationWithSource(IResourcePack source, ResourceLocation resource) { + String resourcePath = resource.getResourcePath(); + boolean isDirectory = resourcePath.endsWith("/"); + super( resource.getResourceDomain(), - resource.getResourcePath() - .replaceFirst("/$", "")); + isDirectory ? resourcePath.substring(0, resourcePath.length() - 1) : resourcePath); this.source = source; - order = ResourceList.getResourcePackOrder(source); - isDirectory = resource.getResourcePath() - .endsWith("/"); + this.order = ResourceList.getResourcePackOrder(source); + this.isDirectory = isDirectory; } public IResourcePack getSource() { diff --git a/src/main/java/com/prupe/mcpatcher/mal/resource/TexturePackAPI.java b/src/main/java/com/prupe/mcpatcher/mal/resource/TexturePackAPI.java index 80e3aa56c..771724ab1 100644 --- a/src/main/java/com/prupe/mcpatcher/mal/resource/TexturePackAPI.java +++ b/src/main/java/com/prupe/mcpatcher/mal/resource/TexturePackAPI.java @@ -196,10 +196,13 @@ public class TexturePackAPI { } path = path.replace(File.separatorChar, '/'); if (path.startsWith(ASSETS)) { - path = path.substring(ASSETS.length()); - int slash = path.indexOf('/'); - if (slash > 0 && slash + 1 < path.length()) { - return new ResourceLocation(path.substring(0, slash), path.substring(slash + 1)); + int namespaceStart = ASSETS.length(); + int slash = path.indexOf('/', namespaceStart); + + if (slash > namespaceStart && slash + 1 < path.length()) { + return new ResourceLocation( + path.substring(namespaceStart, slash), + path.substring(slash + 1)); } } return null;