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
|
package fyresmodjam.tileentities.renderers;
import java.awt.Color;
import org.lwjgl.opengl.GL11;
import fyresmodjam.ModjamMod;
import fyresmodjam.items.ItemCrystal;
import fyresmodjam.models.ModelCrystal;
import fyresmodjam.tileentities.TileEntityCrystal;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class TileEntityCrystalRenderer extends TileEntitySpecialRenderer {
private ModelCrystal modelCrystal = new ModelCrystal();
public static ResourceLocation texture = new ResourceLocation("fyresmodjam", "textures/blocks/crystal.png");
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
GL11.glPushMatrix();
GL11.glTranslatef((float) d0, (float) d1, (float) d2);
TileEntityCrystal crystal = (TileEntityCrystal) tileentity;
Block block = ModjamMod.crystal;
World world = crystal.getWorldObj();
Tessellator tessellator = Tessellator.instance;
float f2 = block.getMixedBrightnessForBlock(world, crystal.xCoord, crystal.yCoord, crystal.zCoord);
int l = world.getLightBrightnessForSkyBlocks(crystal.xCoord, crystal.yCoord, crystal.zCoord, 0);
int l1 = l % 65536;
int l2 = l / 65536;
tessellator.setColorOpaque_F(f2, f2, f2);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
float f3 = world.getWorldInfo().getWorldTime() % 20 / 20.0F;
GL11.glTranslatef(0.5F, -0.4F + (f3 > 0.5F ? 0.25F - 0.25F * f3 : 0.25F * f3), 0.5F);
GL11.glRotatef((float) world.getWorldInfo().getWorldTime() % 360, 0.0F, 1.0F, 0.0F);
Color color = ItemCrystal.colors[crystal.getBlockMetadata() % ItemCrystal.colors.length];
GL11.glColor3f(color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F);
bindTexture(texture);
modelCrystal.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
}
|