diff --git a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java index c4bb25bdee..b96414b7ce 100644 --- a/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java +++ b/src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java @@ -40,6 +40,7 @@ import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.phys.Vec3; @@ -184,7 +185,16 @@ public DeferredWorldRenderingPipeline(ProgramSet programs) { AbstractTexture customTexture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData); customTextureIds.put(samplerName, customTexture::getId); } else if (textureData instanceof CustomTextureData.ResourceData) { - customTextureIds.put(samplerName, ((CustomTextureData.ResourceData) textureData)::getGlId); + AbstractTexture texture = Minecraft.getInstance().getTextureManager().getTexture(((CustomTextureData.ResourceData) textureData).getResourceLocation()); + + IntSupplier glId; + if (texture != null) { + glId = texture::getId; + } else { + // TODO: Should we give something else if the texture isn't there? This will need some thought + glId = MissingTextureAtlasSprite.getTexture()::getId; + } + customTextureIds.put(samplerName, glId); } } catch (IOException e) { Iris.logger.error("Unable to parse the image data for the custom texture on sampler " + samplerName, e); diff --git a/src/main/java/net/coderbot/iris/shaderpack/texture/CustomTextureData.java b/src/main/java/net/coderbot/iris/shaderpack/texture/CustomTextureData.java index d1ed24d80d..c3d11b584f 100644 --- a/src/main/java/net/coderbot/iris/shaderpack/texture/CustomTextureData.java +++ b/src/main/java/net/coderbot/iris/shaderpack/texture/CustomTextureData.java @@ -38,14 +38,8 @@ public ResourceData(ResourceLocation resourceLocation) { this.resourceLocation = resourceLocation; } - public int getGlId() { - AbstractTexture texture = Minecraft.getInstance().getTextureManager().getTexture(resourceLocation); - if (texture != null) { - return texture.getId(); - } else { - // TODO: Should we give something else if the texture isn't there? This will need some thought - return MissingTextureAtlasSprite.getTexture().getId(); - } + public ResourceLocation getResourceLocation() { + return resourceLocation; } }