summaryrefslogtreecommitdiff
path: root/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-08-10 18:50:56 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-08-10 18:50:56 +0300
commit877312184c472d9845e5ef1008bc538f4634059f (patch)
tree4e098cc94296cc11f3b87e8ef64c3c568b6aeb51 /main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
parent939d2ea16679ce64d98b98c716b85f851aa576e2 (diff)
fix missing source folder
Diffstat (limited to 'main/java/gregtech/api/objects/GT_CopiedBlockTexture.java')
-rw-r--r--main/java/gregtech/api/objects/GT_CopiedBlockTexture.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java b/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
new file mode 100644
index 0000000..ffbbe09
--- /dev/null
+++ b/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java
@@ -0,0 +1,96 @@
+package gregtech.api.objects;
+
+import gregtech.api.enums.Dyes;
+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;
+
+public class GT_CopiedBlockTexture implements ITexture {
+ private final Block mBlock;
+ private final byte mSide, mMeta;
+
+ /**
+ * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!!
+ *
+ * Just set this variable to another different Array instead.
+ * Otherwise some colored things will get Problems.
+ */
+ public short[] mRGBa;
+
+ private final boolean mAllowAlpha;
+
+ 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(5);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 0.6F), (int)(mRGBa[1] * 0.6F), (int)(mRGBa[2] * 0.6F), mAllowAlpha?255-mRGBa[3]:255);
+// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon);
+// aRenderer.flipTexture = !aRenderer.flipTexture;
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(4);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 0.6F), (int)(mRGBa[1] * 0.6F), (int)(mRGBa[2] * 0.6F), mAllowAlpha?255-mRGBa[3]:255);
+ aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon);
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(1);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 1.0F), (int)(mRGBa[1] * 1.0F), (int)(mRGBa[2] * 1.0F), mAllowAlpha?255-mRGBa[3]:255);
+ aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(0);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 0.5F), (int)(mRGBa[1] * 0.5F), (int)(mRGBa[2] * 0.5F), mAllowAlpha?255-mRGBa[3]:255);
+ aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon);
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(3);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 0.8F), (int)(mRGBa[1] * 0.8F), (int)(mRGBa[2] * 0.8F), mAllowAlpha?255-mRGBa[3]:255);
+ aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon);
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ IIcon aIcon = getIcon(2);
+ Tessellator.instance.setColorRGBA((int)(mRGBa[0] * 0.8F), (int)(mRGBa[1] * 0.8F), (int)(mRGBa[2] * 0.8F), mAllowAlpha?255-mRGBa[3]:255);
+// aRenderer.flipTexture = !aRenderer.flipTexture;
+ aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon);
+// aRenderer.flipTexture = !aRenderer.flipTexture;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ return mBlock != null;
+ }
+} \ No newline at end of file