Skip to content

Commit

Permalink
Compatible with ID-based dynamic resources
Browse files Browse the repository at this point in the history
When there is a dynamic resource address, the client crashes directly.
This is clearly not what players want to see.
  • Loading branch information
ketikai authored Sep 29, 2024
1 parent 313d36a commit 2a99696
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/glowredman/txloader/TXResourcePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.InvalidPathException;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -37,7 +38,18 @@ public InputStream getInputStream(ResourceLocation rl) throws IOException {

@Override
public boolean resourceExists(ResourceLocation rl) {
return Files.exists(this.getResourcePath(rl));
try {
return Files.exists(this.getResourcePath(rl));
} catch (InvalidPathException e) {
/*
* Some mods load resources dynamically by id.
* (example: java.nio.file.InvalidPathException: Illegal char <:> at index 30: textures/blocks/bw_(extrautils:golden_bag)_n.png.mcmeta)
*/
if(rl.getResourcePath().contains(":")) {
return false;
}
throw e;
}
}

@SuppressWarnings("rawtypes")
Expand Down

0 comments on commit 2a99696

Please sign in to comment.