Another small fix & optimisation

This commit is contained in:
paulevsGitch 2021-08-01 14:39:21 +03:00
parent 47655f9a01
commit 3de67d42b3

View file

@ -29,7 +29,7 @@ public class SimpleReloadableResourceManagerMixin {
@Shadow @Shadow
private Map<String, FallbackResourceManager> namespacedPacks; private Map<String, FallbackResourceManager> namespacedPacks;
private Resource bclib_alphaEmissionMaterial; private ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json");
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true) @Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Resource> info) throws IOException { private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Resource> info) throws IOException {
@ -51,14 +51,8 @@ public class SimpleReloadableResourceManagerMixin {
} }
ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace()); ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace());
if (resourceManager != null) { if (resourceManager != null && !resourceManager.hasResource(resourceLocation)) {
Resource resource = resourceManager.getResource(resourceLocation); info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial));
if (resource != null) {
info.setReturnValue(resource);
return;
}
resourceLocation = BCLib.makeID("materialmaps/block/alpha_emission.json");
info.setReturnValue(resourceManager.getResource(resourceLocation));
} }
} }
} }