aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/render
diff options
context:
space:
mode:
authorLéa Gris <lea.gris@noiraude.net>2021-05-08 22:31:58 +0200
committerLéa Gris <lea.gris@noiraude.net>2021-05-21 13:38:39 +0200
commit04468545985a4fed401d9b6626670e8af5938920 (patch)
tree1941b545ac1e07ea64a605911ca245b5e836d56d /src/main/java/gregtech/api/render
parent9fcbc16e436ef745d761cb934834d8070fb68a8c (diff)
downloadGT5-Unofficial-04468545985a4fed401d9b6626670e8af5938920.tar.gz
GT5-Unofficial-04468545985a4fed401d9b6626670e8af5938920.tar.bz2
GT5-Unofficial-04468545985a4fed401d9b6626670e8af5938920.zip
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
Diffstat (limited to 'src/main/java/gregtech/api/render')
-rw-r--r--src/main/java/gregtech/api/render/GT_CopiedBlockTexture.java128
-rw-r--r--src/main/java/gregtech/api/render/GT_MultiTexture.java59
-rw-r--r--src/main/java/gregtech/api/render/GT_RenderedGlowTexture.java208
-rw-r--r--src/main/java/gregtech/api/render/GT_RenderedTexture.java219
-rw-r--r--src/main/java/gregtech/api/render/GT_SidedTexture.java91
-rw-r--r--src/main/java/gregtech/api/render/GT_StdRenderedTexture.java45
6 files changed, 750 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/render/GT_CopiedBlockTexture.java b/src/main/java/gregtech/api/render/GT_CopiedBlockTexture.java
new file mode 100644
index 0000000000..4ffdf8ca92
--- /dev/null
+++ b/src/main/java/gregtech/api/render/GT_CopiedBlockTexture.java
@@ -0,0 +1,128 @@
+package gregtech.api.render;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.util.LightingHelper;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class GT_CopiedBlockTexture implements ITexture {
+ private final Block mBlock;
+ private final byte mSide, mMeta;
+ private final boolean mAllowAlpha;
+ /**
+ * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
+ * <p/>
+ * Just set this variable to another different Array instead.
+ * Otherwise some colored things will get Problems.
+ */
+ public short[] mRGBa;
+
+ public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean aAllowAlpha) {
+ if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_CopiedBlockTexture");
+ mBlock = aBlock;
+ mRGBa = aRGBa;
+ mSide = (byte) aSide;
+ mMeta = (byte) aMeta;
+ mAllowAlpha = aAllowAlpha;
+ }
+
+ public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa) {
+ this(aBlock, aSide, aMeta, aRGBa, true);
+ }
+
+ public GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta) {
+ this(aBlock, aSide, aMeta, Dyes._NULL.mRGBa);
+ }
+
+ private IIcon getIcon(int aSide) {
+ if (mSide == 6) return mBlock.getIcon(aSide, mMeta);
+ return mBlock.getIcon(mSide, mMeta);
+ }
+
+ @Override
+ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal());
+ aRenderer.field_152631_f = true;
+ startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f);
+ new LightingHelper(aRenderer)
+ .setupLightingXPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.EAST.ordinal(), 0xffffff);
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f);
+ IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal());
+ new LightingHelper(aRenderer)
+ .setupLightingXNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.WEST.ordinal(), 0xffffff);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f);
+ IIcon aIcon = getIcon(ForgeDirection.UP.ordinal());
+ new LightingHelper(aRenderer)
+ .setupLightingYPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.UP.ordinal(), 0xffffff);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f);
+ IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal());
+ new LightingHelper(aRenderer)
+ .setupLightingYNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f);
+ IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal());
+ new LightingHelper(aRenderer)
+ .setupLightingZPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff);
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f);
+ IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal());
+ aRenderer.field_152631_f = true;
+ new LightingHelper(aRenderer)
+ .setupLightingZNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff);
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon);
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ return mBlock != null;
+ }
+
+ public Block getBlock() {
+ return mBlock;
+ }
+
+ public byte getMeta() {
+ return mMeta;
+ }
+}
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.
+ * <p/>
+ * 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;
+ }
+}
diff --git a/src/main/java/gregtech/api/render/GT_RenderedGlowTexture.java b/src/main/java/gregtech/api/render/GT_RenderedGlowTexture.java
new file mode 100644
index 0000000000..8b66196997
--- /dev/null
+++ b/src/main/java/gregtech/api/render/GT_RenderedGlowTexture.java
@@ -0,0 +1,208 @@
+package gregtech.api.render;
+
+import gregtech.GT_Mod;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.Textures.BlockIcons;
+import gregtech.api.interfaces.IColorModulationContainer;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.interfaces.ITexture;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.IIcon;
+
+import static gregtech.api.util.LightingHelper.MAX_BRIGHTNESS;
+
+public class GT_RenderedGlowTexture implements ITexture, IColorModulationContainer {
+ final IIconContainer mIconContainer;
+ final boolean mAllowAlpha;
+ /**
+ * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
+ * <p/>
+ * Just set this variable to another different Array instead.
+ * Otherwise some colored things will get Problems.
+ */
+ public short[] mRGBa;
+
+ public GT_RenderedGlowTexture(IIconContainer aIcon) {
+ this(aIcon, Dyes._NULL.mRGBa);
+ }
+
+ public GT_RenderedGlowTexture(IIconContainer aIcon, short[] aRGBa) {
+ this(aIcon, aRGBa, true);
+ }
+
+ public GT_RenderedGlowTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) {
+ if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture");
+ mIconContainer = GT_Mod.gregtechproxy.mRenderGlowTextures ? aIcon : BlockIcons.VOID;
+ mAllowAlpha = aAllowAlpha;
+ mRGBa = aRGBa;
+ }
+
+ @Override
+ public short[] getRGBA() {
+ return mRGBa;
+ }
+
+ @Override
+ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ aRenderer.field_152631_f = true;
+ final boolean enableAO = aRenderer.enableAO;
+ aRenderer.enableAO = false;
+ startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f);
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ Tessellator.instance.setColorOpaque(255, 255, 255);
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ final boolean enableAO = aRenderer.enableAO;
+ aRenderer.enableAO = false;
+ startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f);
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ Tessellator.instance.setColorOpaque(255, 255, 255);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ final boolean enableAO = aRenderer.enableAO;
+ aRenderer.enableAO = false;
+ startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f);
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ Tessellator.instance.setColorOpaque(255, 255, 255);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ final boolean enableAO = aRenderer.enableAO;
+ startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f);
+ final Tessellator tessellator = Tessellator.instance;
+ IIcon aIcon = mIconContainer.getIcon();
+
+ float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ double minX = aX + aRenderer.renderMinX;
+ double maxX = aX + aRenderer.renderMaxX;
+ double minY = aY + aRenderer.renderMinY;
+ double minZ = aZ + aRenderer.renderMinZ;
+ double maxZ = aZ + aRenderer.renderMaxZ;
+
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
+
+ if (mIconContainer.getOverlayIcon() != null) {
+ minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ minX = aX + (float) aRenderer.renderMinX;
+ maxX = aX + (float) aRenderer.renderMaxX;
+ minY = aY + (float) aRenderer.renderMinY;
+ minZ = aZ + (float) aRenderer.renderMinZ;
+ maxZ = aZ + (float) aRenderer.renderMaxZ;
+
+ Tessellator.instance.setColorOpaque(255, 255, 255);
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
+ }
+ draw(aRenderer);
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ final boolean enableAO = aRenderer.enableAO;
+ aRenderer.enableAO = false;
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f);
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return;
+ final boolean enableAO = aRenderer.enableAO;
+ aRenderer.enableAO = false;
+ aRenderer.field_152631_f = true;
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f);
+ Tessellator.instance.setBrightness(MAX_BRIGHTNESS);
+ Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]);
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ Tessellator.instance.setColorOpaque(255, 255, 255);
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ aRenderer.enableAO = enableAO;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ return mIconContainer != null;
+ }
+}
diff --git a/src/main/java/gregtech/api/render/GT_RenderedTexture.java b/src/main/java/gregtech/api/render/GT_RenderedTexture.java
new file mode 100644
index 0000000000..9efc81738f
--- /dev/null
+++ b/src/main/java/gregtech/api/render/GT_RenderedTexture.java
@@ -0,0 +1,219 @@
+package gregtech.api.render;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.interfaces.IColorModulationContainer;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.util.LightingHelper;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class GT_RenderedTexture implements ITexture, IColorModulationContainer {
+ final IIconContainer mIconContainer;
+ final boolean mAllowAlpha;
+ /**
+ * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
+ * <p/>
+ * Just set this variable to another different Array instead.
+ * Otherwise some colored things will get Problems.
+ */
+ public short[] mRGBa;
+
+ public GT_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) {
+ if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture");
+ mIconContainer = aIcon;
+ mAllowAlpha = aAllowAlpha;
+ mRGBa = aRGBa;
+ }
+
+ public GT_RenderedTexture(IIconContainer aIcon, short[] aRGBa) {
+ this(aIcon, aRGBa, true);
+ }
+
+ public GT_RenderedTexture(IIconContainer aIcon) {
+ this(aIcon, Dyes._NULL.mRGBa);
+ }
+
+ @Override
+ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ aRenderer.field_152631_f = true;
+ startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f);
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingXPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.EAST.ordinal(), mRGBa);
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff);
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f);
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingXNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.WEST.ordinal(), mRGBa);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f);
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingYPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.UP.ordinal(), mRGBa);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f);
+ final Tessellator tessellator = Tessellator.instance;
+ IIcon aIcon = mIconContainer.getIcon();
+
+ float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ double minX = aX + aRenderer.renderMinX;
+ double maxX = aX + aRenderer.renderMaxX;
+ double minY = aY + aRenderer.renderMinY;
+ double minZ = aZ + aRenderer.renderMinZ;
+ double maxZ = aZ + aRenderer.renderMaxZ;
+
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingYNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa);
+
+ if (aRenderer.enableAO) {
+ tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft);
+ tessellator.setBrightness(aRenderer.brightnessTopLeft);
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft);
+ tessellator.setBrightness(aRenderer.brightnessBottomLeft);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight);
+ tessellator.setBrightness(aRenderer.brightnessBottomRight);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight);
+ tessellator.setBrightness(aRenderer.brightnessTopRight);
+ } else {
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ }
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
+
+ if (mIconContainer.getOverlayIcon() != null) {
+ minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D);
+ maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D);
+ minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D);
+ maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D);
+
+ if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) {
+ minU = 16.0F - aIcon.getMaxU();
+ maxU = 16.0F - aIcon.getMinU();
+ }
+
+ if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) {
+ minV = aIcon.getMinV();
+ maxV = aIcon.getMaxV();
+ }
+
+ minX = aX + (float)aRenderer.renderMinX;
+ maxX = aX + (float)aRenderer.renderMaxX;
+ minY = aY + (float)aRenderer.renderMinY;
+ minZ = aZ + (float)aRenderer.renderMinZ;
+ maxZ = aZ + (float)aRenderer.renderMaxZ;
+
+ lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff);
+
+ if (aRenderer.enableAO) {
+ tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft);
+ tessellator.setBrightness(aRenderer.brightnessTopLeft);
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft);
+ tessellator.setBrightness(aRenderer.brightnessBottomLeft);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight);
+ tessellator.setBrightness(aRenderer.brightnessBottomRight);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight);
+ tessellator.setBrightness(aRenderer.brightnessTopRight);
+ } else {
+ tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV);
+ tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV);
+ tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV);
+ }
+ tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV);
+ }
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f);
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingZPos(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa);
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff);
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f);
+ aRenderer.field_152631_f = true;
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingZNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.NORTH.ordinal(), mRGBa);
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff);
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public short[] getRGBA() {
+ return mRGBa;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ return mIconContainer != null;
+ }
+}
diff --git a/src/main/java/gregtech/api/render/GT_SidedTexture.java b/src/main/java/gregtech/api/render/GT_SidedTexture.java
new file mode 100644
index 0000000000..1e940ba814
--- /dev/null
+++ b/src/main/java/gregtech/api/render/GT_SidedTexture.java
@@ -0,0 +1,91 @@
+package gregtech.api.render;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.interfaces.IColorModulationContainer;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.interfaces.ITexture;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+
+public class GT_SidedTexture implements ITexture, IColorModulationContainer {
+ private final ITexture[] mTextures;
+ /**
+ * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
+ * <p/>
+ * Just set this variable to another different Array instead.
+ * Otherwise some colored things will get Problems.
+ */
+ public short[] mRGBa;
+
+ public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa, boolean aAllowAlpha) {
+ if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture");
+ mTextures = new ITexture[]{
+ new GT_RenderedTexture(aIcon0, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon1, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon2, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon3, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon4, aRGBa, aAllowAlpha),
+ new GT_RenderedTexture(aIcon5, aRGBa, aAllowAlpha)
+ };
+ mRGBa = aRGBa;
+ }
+
+ public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa) {
+ this(aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5, aRGBa, true);
+ }
+
+ public GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, IIconContainer aIcon4, IIconContainer aIcon5) {
+ this(aIcon0, aIcon1, aIcon2, aIcon3, aIcon4, aIcon5, Dyes._NULL.mRGBa);
+ }
+
+ public GT_SidedTexture(IIconContainer aBottom, IIconContainer aTop, IIconContainer aSides, short[] aRGBa) {
+ this(aBottom, aTop, aSides, aSides, aSides, aSides, aRGBa);
+ }
+
+ public GT_SidedTexture(IIconContainer aBottom, IIconContainer aTop, IIconContainer aSides) {
+ this(aBottom, aTop, aSides, Dyes._NULL.mRGBa);
+ }
+
+ @Override
+ public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[5].renderXPos(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[4].renderXNeg(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[1].renderYPos(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[0].renderYNeg(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[3].renderZPos(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ mTextures[2].renderZNeg(aRenderer, aBlock, aX ,aY, aZ);
+ }
+
+ @Override
+ public short[] getRGBA() {
+ return mRGBa;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ for (ITexture renderedTexture : mTextures) {
+ if (!renderedTexture.isValidTexture()) return false;
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/gregtech/api/render/GT_StdRenderedTexture.java b/src/main/java/gregtech/api/render/GT_StdRenderedTexture.java
new file mode 100644
index 0000000000..9337ff59af
--- /dev/null
+++ b/src/main/java/gregtech/api/render/GT_StdRenderedTexture.java
@@ -0,0 +1,45 @@
+package gregtech.api.render;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.util.LightingHelper;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraftforge.common.util.ForgeDirection;
+
+/**
+ * This ITexture implementation extends the GT_RenderedTexture class
+ * to render with bottom side flipped as with dumb blocks rendering.
+ * It is used in Ore blocks rendering so they better blends with dumb block ores
+ * from vanilla or other mods, when seen from bottom.
+ */
+public class GT_StdRenderedTexture extends GT_RenderedTexture{
+
+ @SuppressWarnings("unused")
+ public GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) {
+ super(aIcon, aRGBa, aAllowAlpha);
+ }
+
+ public GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa) {
+ super(aIcon, aRGBa, true);
+ }
+
+ @SuppressWarnings("unused")
+ public GT_StdRenderedTexture(IIconContainer aIcon) {
+ super(aIcon, Dyes._NULL.mRGBa);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f);
+ LightingHelper lighting = new LightingHelper(aRenderer);
+ lighting.setupLightingYNeg(aBlock, aX, aY, aZ)
+ .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon());
+ if (mIconContainer.getOverlayIcon() != null) {
+ lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon());
+ }
+ draw(aRenderer);
+ }
+}