Skip to content

Commit

Permalink
Support custom noise textures using a ResourceLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Justsnoopy30 committed Nov 28, 2021
1 parent 4160392 commit 64811c7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/java/net/coderbot/iris/pipeline/CustomTextureManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ public CustomTextureManager(PackDirectives packDirectives, Object2ObjectMap<Text
});

noise = customNoiseTextureData.flatMap(textureData -> {
try {
// TODO: Support CustomTextureData types other than PngData
AbstractTexture customNoiseTexture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);

return Optional.of(customNoiseTexture);
} catch (IOException e) {
Iris.logger.error("Unable to parse the image data for the custom noise texture", e);
return Optional.empty();
if (textureData instanceof CustomTextureData.PngData) {
try {
AbstractTexture customNoiseTexture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);

return Optional.of(customNoiseTexture);
} catch (IOException e) {
Iris.logger.error("Unable to parse the image data for the custom noise texture", e);
return Optional.empty();
}
} else if (textureData instanceof CustomTextureData.ResourceData) {
AbstractTexture customNoiseTexture = Minecraft.getInstance().getTextureManager().getTexture(((CustomTextureData.ResourceData) textureData).getResourceLocation());

// TODO: Should we give something else if the texture isn't there? This will need some thought
return Optional.of(customNoiseTexture != null ? customNoiseTexture : MissingTextureAtlasSprite.getTexture());
}
return Optional.empty();
}).orElseGet(() -> {
final int noiseTextureResolution = packDirectives.getNoiseTextureResolution();

Expand Down

0 comments on commit 64811c7

Please sign in to comment.