1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package darkknight.jewelrycraft.tileentity.renders;
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.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import darkknight.jewelrycraft.model.ModelShadowEye;
import darkknight.jewelrycraft.tileentity.TileEntityShadowEye;
import darkknight.jewelrycraft.util.Variables;
public class TileEntityShadowEyeRender extends TileEntitySpecialRenderer
{
ModelShadowEye eye = new ModelShadowEye();
/**
* @param te
* @param x
* @param y
* @param z
* @param scale
*/
@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.6F, (float)z + 0.5F);
TileEntityShadowEye eyeS = (TileEntityShadowEye)te;
String texture = "textures/tileentities/ShadowEye" + eyeS.opening + ".png";
ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture);
Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
GL11.glPushMatrix();
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
try{
int block = te.getBlockMetadata();
if (block == 0) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
else if (block == 1){
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
}else if (block == 2){
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
}
}
catch(Exception e){}
try{
EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 16D);
if (player != null) eye.render(player, te.xCoord, te.yCoord, te.zCoord, te.blockMetadata, eyeS.opening, 0.0625F);
}
catch(Exception e){
eye.render((Entity)null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
}
GL11.glPopMatrix();
GL11.glPopMatrix();
}
/**
* @param world
* @param i
* @param j
* @param k
* @param block
*/
public void adjustLightFixture(World world, int i, int j, int k, Block block)
{
Tessellator tess = Tessellator.instance;
float brightness = block.getLightOpacity(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, modulousModifier, divModifier);
}
}
|