diff options
author | GlodBlock <60341015+GlodBlock@users.noreply.github.com> | 2021-09-27 15:39:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 15:39:31 +0800 |
commit | 097438be70486735a8940dd5ce4e9484b6d951af (patch) | |
tree | 90f26b34d5059eb9858d9c82aabbd5373638acfa /src/main/java/gregtech/api/render | |
parent | a0a77f0b9868a4ca8a3df8ae8d50b4dcfb4030db (diff) | |
parent | 92433a5b85bb2fcca541ac25ca4033fac24f841e (diff) | |
download | GT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.tar.gz GT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.tar.bz2 GT5-Unofficial-097438be70486735a8940dd5ce4e9484b6d951af.zip |
Merge pull request #1 from GlodBlock/fix-crack-recipe-check
Fix crack recipe check
Diffstat (limited to 'src/main/java/gregtech/api/render')
-rw-r--r-- | src/main/java/gregtech/api/render/TextureFactory.java | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/render/TextureFactory.java b/src/main/java/gregtech/api/render/TextureFactory.java new file mode 100644 index 0000000000..8c67cd6740 --- /dev/null +++ b/src/main/java/gregtech/api/render/TextureFactory.java @@ -0,0 +1,126 @@ +package gregtech.api.render; + +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.ITextureBuilder; +import gregtech.common.render.GT_TextureBuilder; +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * <p>This class contains a collection of static factory methods to access the New Texture API.</p> + * <p>The {@link #of} methods directly returns ready-to-use instances of {@link ITexture} implementations.</p> + * <p>To get more specific implementations of {@link ITexture} instances, use the {@link #builder()} method.</p> + * <p>Example of the {@link #builder()}:</p> + * <pre>{@code + * // Texture that glows in the dark + * TextureFactory.builder().addIcon(OVERLAY_FUSION1_GLOW).glow().build()); + * + * // Texture with same bottom flipped orientation as vanilla + * TextureFactory.builder().addIcon(GRANITE_RED_STONE).stdOrient().build(); + * }</pre> + * See: the {@link ITextureBuilder} interface + */ +@SuppressWarnings("unused") +public final class TextureFactory { + private TextureFactory() { + throw new AssertionError("Non-instantiable class"); + } + + /** + * Multi-layered {@link ITexture} factory + * + * @param textures The layers of {@link ITexture} from bottom to top + * @return The instance of an {@link ITexture} implementation + */ + public static ITexture of(final ITexture... textures) { + return builder().addLayer(textures).build(); + } + + /** + * All-Sided {@link ITexture} factory + * + * @param bottom The {@link IIconContainer} Icon for the Bottom Side. + * @param top The {@link IIconContainer} Icon for the Top Side. + * @param north The {@link IIconContainer} Icon for the North Side. + * @param south The {@link IIconContainer} Icon for the South Side. + * @param west The {@link IIconContainer} Icon for the West Side. + * @param east The {@link IIconContainer} Icon for the East Side. + * @param rgba The {@code short[]} RGBA tint for all sides. + * @return The instance of an {@link ITexture} implementation + */ + public static ITexture of(final IIconContainer bottom, final IIconContainer top, final IIconContainer north, + final IIconContainer south, final IIconContainer west, final IIconContainer east, + final short[] rgba) { + return builder().addIcon(bottom, top, north, south, west, east).setRGBA(rgba).setAllowAlpha(true).build(); + } + + /** + * Bottom-Top-Sides-Sided {@link ITexture} factory + * + * @param bottom The {@link IIconContainer} Icon for the Bottom Side. + * @param top The {@link IIconContainer} Icon for the Top Side. + * @param sides The {@link IIconContainer} Icon for the North, South, West and East Sides. + * @param rgba The {@code short[]} RGBA tint for all sides. + * @return The instance of an {@link ITexture} implementation + */ + public static ITexture of(final IIconContainer bottom, final IIconContainer top, final IIconContainer sides, + final short[] rgba) { + return builder().addIcon(bottom, top, sides, sides, sides, sides).setRGBA(rgba).setAllowAlpha(true).build(); + } + + /** + * Rendered {@link ITexture} factory + * + * @param iconContainer The {@link IIconContainer} to render + * @param rgba The {@code short[]} RGBA tint for the texture. + * @param allowAlpha Determine if texture will use alpha blending (Not yet implemented) + * @return The instance of an {@link ITexture} implementation + */ + public static ITexture of(final IIconContainer iconContainer, final short[] rgba, final boolean allowAlpha) { + return builder().addIcon(iconContainer).setRGBA(rgba).setAllowAlpha(allowAlpha).build(); + } + + public static ITexture of(final IIconContainer iconContainer, final short[] rgba) { + return builder().addIcon(iconContainer).setRGBA(rgba).build(); + } + + public static ITexture of(final IIconContainer iconContainer) { + return builder().addIcon(iconContainer).build(); + } + + /** + * Copied-Block {@link ITexture} factory + * that will render a texture copied from the side of a {@link Block}. + * + * @param block The {@link Block} that will provide the texture + * @param meta The meta value for the Block + * @param side The {@link ForgeDirection} side providing the texture + * @param rgba The RGBA tint to apply + * @return The instance of an {@link ITexture} implementation + */ + public static ITexture of(final Block block, final int meta, final ForgeDirection side, final short[] rgba) { + return builder().setFromBlock(block, meta).setFromSide(side).setRGBA(rgba).build(); + } + + public static ITexture of(final Block block, final int meta, final ForgeDirection side) { + return builder().setFromBlock(block, meta).setFromSide(side).build(); + } + + public static ITexture of(final Block block, final int meta) { + return builder().setFromBlock(block, meta).build(); + } + + public static ITexture of(final Block block) { + return of(block, 0); + } + + /** + * {@link ITextureBuilder} factory + * + * @return An instance of the {@link ITextureBuilder} implementation + */ + public static ITextureBuilder builder() { + return new GT_TextureBuilder(); + } +} |