summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 16:52:41 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 16:52:41 +0200
commit06415dc21d71e8ac363dae5c56c5317971f7aede (patch)
tree7ddbe2cc709a5a39c3fe8b8a80d7ac77f336a220 /common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
parent9342967bd8a6a9451591325c7c5deb5416819adc (diff)
parent943f1a493b27c630e95730b385e6524643d98564 (diff)
Merge branch 'master' of https://github.com/sor1n/Modjam-Mod
As well as added the smelter and working on the molder
Diffstat (limited to 'common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java')
-rw-r--r--common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
new file mode 100644
index 0000000..d3cd2ad
--- /dev/null
+++ b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
@@ -0,0 +1,88 @@
+package darkknight.jewelrycraft.renders;
+
+import org.lwjgl.opengl.GL11;
+
+import darkknight.jewelrycraft.model.ModelSmelter;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+
+public class TileEntitySmelterRender extends TileEntitySpecialRenderer
+{
+ ModelSmelter modelSmelter = new ModelSmelter();
+ String texture = "textures/tileentities/Smelter.png", lava = "texture/blocks/lava_still.png";
+
+ @Override
+ public void renderTileEntityAt (TileEntity te, double x, double y, double z, float scale)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
+
+ ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture);
+ Tessellator tessellator = Tessellator.instance;
+ ResourceLocation lava = new ResourceLocation(null, "textures/blocks/lava_still.png");
+ Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
+ int block = te.getBlockMetadata();
+
+ GL11.glPushMatrix();
+ if(block == 0) GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
+ else if(block == 1) GL11.glRotatef(180F, 1F, 0.0F, 1F);
+ else if(block == 2) GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
+ else if(block == 3) GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
+
+ modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
+
+ //Mrkol's liquid render code base - thank you man for the help :) I used only the top
+ Minecraft.getMinecraft().renderEngine.bindTexture(lava);
+ Block.lavaStill.getIcon(3, 0).getInterpolatedU(0);
+ double minu = Block.lavaStill.getIcon(0, 0).getInterpolatedU(0);
+ double minv = Block.lavaStill.getIcon(0, 0).getInterpolatedV(0);
+ double maxu = Block.lavaStill.getIcon(0, 0).getInterpolatedU(16);
+ double maxv = Block.lavaStill.getIcon(0, 0).getInterpolatedV(16);
+ GL11.glPushMatrix();
+ GL11.glScalef(1f/16f, 1f/16f, 1f/16f);
+ GL11.glDisable(GL11.GL_LIGHTING);
+ // without F it scales it down to 0, 0, 0. That's because it is trying to make 0.0625 an integer, and 0.0625 without .0625 is 0.
+ tessellator.startDrawingQuads();
+ tessellator.addVertexWithUV(5, 20, 6, maxu, maxv);
+ tessellator.addVertexWithUV(-5, 20, 6, maxu, minv);
+ tessellator.addVertexWithUV(-5, 20, -6, minu, minv);
+ tessellator.addVertexWithUV(5, 20, -6, minu, maxv);
+
+ tessellator.addVertexWithUV(4, 20, -6, maxu, maxv);
+ tessellator.addVertexWithUV(-4, 20, -6, maxu, minv);
+ tessellator.addVertexWithUV(-4, 20, -7, minu, minv);
+ tessellator.addVertexWithUV(4, 20, -7, minu, maxv);
+
+ tessellator.addVertexWithUV(4, 20, 7, maxu, maxv);
+ tessellator.addVertexWithUV(-4, 20, 7, maxu, minv);
+ tessellator.addVertexWithUV(-4, 20, 6, minu, minv);
+ tessellator.addVertexWithUV(4, 20, 6, minu, maxv);
+ tessellator.draw();
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+
+ GL11.glPopMatrix();
+ GL11.glPopMatrix();
+ }
+
+ public void adjustLightFixture (World world, int i, int j, int k, Block block)
+ {
+ Tessellator tess = Tessellator.instance;
+ float brightness = block.getBlockBrightness(world, i, j, k);
+ int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
+ int modulousModifier = skyLight % 65536;
+ int divModifier = skyLight / 65536;
+ tess.setColorOpaque_F(brightness, brightness, brightness);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier);
+ }
+
+
+}