aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java')
-rw-r--r--src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java
new file mode 100644
index 0000000000..fdd20026ab
--- /dev/null
+++ b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java
@@ -0,0 +1,123 @@
+package gregtech.common.render;
+
+import gregtech.api.interfaces.IBlockContainer;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.util.LightingHelper;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.common.util.ForgeDirection;
+
+class GT_CopiedBlockTexture implements ITexture, IBlockContainer {
+ private final Block mBlock;
+ private final byte mSide, mMeta;
+
+ GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean allowAlpha) {
+ if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_CopiedBlockTexture");
+ mBlock = aBlock;
+ mSide = (byte) aSide;
+ mMeta = (byte) aMeta;
+ }
+
+ 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;
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ }
+
+ @Override
+ public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ }
+
+ @Override
+ public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ }
+
+ @Override
+ public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ }
+
+ @Override
+ public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) {
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //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);
+ // TODO: Uncomment this once all addons have migrated to the new Texture API
+ //draw(aRenderer);
+ aRenderer.field_152631_f = false;
+ }
+
+ @Override
+ public boolean isValidTexture() {
+ return mBlock != null;
+ }
+
+ @Override
+ public Block getBlock() {
+ return mBlock;
+ }
+
+ @Override
+ public byte getMeta() {
+ return mMeta;
+ }
+}