mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-13 17:04:15 +00:00
Quick fix PBR Resourcepack loader error (#1043)
This commit is contained in:
1 parent
c9d59c3b90
commit
5b67eaa474
2 files changed
+39
-12
No files matched your search
@@ -4,6 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public enum PBRType {
|
||||
NORMAL("_n", 0x7F7FFFFF),
|
||||
SPECULAR("_s", 0x00000000);
|
||||
@@ -26,17 +29,37 @@ public enum PBRType {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public ResourceLocation appendToFileLocation(ResourceLocation location) {
|
||||
String path = location.getResourcePath();
|
||||
String newPath;
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(path);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = path.substring(0, extensionIndex) + suffix + path.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = path + suffix;
|
||||
}
|
||||
return new ResourceLocation(location.getResourceDomain(), newPath);
|
||||
}
|
||||
public ResourceLocation appendToFileLocation(ResourceLocation location) {
|
||||
String domain = location.getResourceDomain();
|
||||
String path = location.getResourcePath();
|
||||
String newPath;
|
||||
|
||||
try {
|
||||
URI uri = new URI(null, null, path, null);
|
||||
String cleanPath = uri.getPath();
|
||||
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(cleanPath);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = cleanPath.substring(0, extensionIndex) + suffix + cleanPath.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = cleanPath + suffix;
|
||||
}
|
||||
|
||||
URI newUri = new URI(null, null, newPath, null);
|
||||
newPath = newUri.getPath();
|
||||
|
||||
} catch (URISyntaxException e) {
|
||||
String fallback = path.replace(':', '/');
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(fallback);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = fallback.substring(0, extensionIndex) + suffix + fallback.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = fallback + suffix;
|
||||
}
|
||||
}
|
||||
|
||||
return new ResourceLocation(domain, newPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PBR type corresponding to the suffix of the given file location.
|
||||
|
||||
@@ -103,7 +103,11 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
NativeImage nativeImage = NativeImage.read(resource.getInputStream());
|
||||
AnimationMetadataSection animationMetadata = (AnimationMetadataSection) resource.getMetadata("animation");
|
||||
if (animationMetadata == null) {
|
||||
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
|
||||
final IResource resourceOriginal = resourceManager.getResource(imageLocation);
|
||||
animationMetadata = (AnimationMetadataSection) resourceOriginal.getMetadata("animation");
|
||||
if (animationMetadata == null) {
|
||||
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
final Pair<Integer, Integer> frameSize = this.getFrameSize(nativeImage.getWidth(), nativeImage.getHeight(), animationMetadata);
|
||||
|
||||
Reference in new issue
Block a user