From 04468545985a4fed401d9b6626670e8af5938920 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Sat, 8 May 2021 22:31:58 +0200 Subject: fix(render): move new textures rendering to new package Old textures rendering are kept in api/objects for backward compatibility. The old textures rendering does not handle glow textures or independant inventory tessellation. The old textures will only work with the old GT_Renderer_Block class New textures rendering with own tessellation in inventory and handling of glow emisssive textures are moved to the api/render package. These must not be used with the Old GT_Renderer_Block class or it will crash with: Already Tessellating Exception from the Tessellator class --- .../java/gregtech/api/render/GT_MultiTexture.java | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/gregtech/api/render/GT_MultiTexture.java (limited to 'src/main/java/gregtech/api/render/GT_MultiTexture.java') diff --git a/src/main/java/gregtech/api/render/GT_MultiTexture.java b/src/main/java/gregtech/api/render/GT_MultiTexture.java new file mode 100644 index 0000000000..907876cd29 --- /dev/null +++ b/src/main/java/gregtech/api/render/GT_MultiTexture.java @@ -0,0 +1,59 @@ +package gregtech.api.render; + +import gregtech.api.interfaces.ITexture; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; + +/** + * Lets Multiple ITextures Render overlay over each other. + *

+ * I should have done this much earlier... + */ +public class GT_MultiTexture implements ITexture { + private final ITexture[] mTextures; + + public GT_MultiTexture(ITexture... aTextures) { + mTextures = aTextures; + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public boolean isValidTexture() { + return true; + } +} -- cgit