Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cjb.rebirth.blocks.client.renderer;
- import cjb.rebirth.blocks.client.BlockData;
- import cjb.rebirth.blocks.tileentity.TileEntityHoloTable;
- import java.nio.FloatBuffer;
- import java.util.List;
- import java.util.Random;
- import net.minecraft.client.entity.EntityClientPlayerMP;
- import net.minecraft.client.renderer.GLAllocation;
- 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.EntityLiving;
- import net.minecraft.entity.monster.IMob;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- import org.lwjgl.opengl.ARBVertexBufferObject;
- import org.lwjgl.opengl.GL11;
- import org.lwjgl.util.glu.Sphere;
- public class TileEntityHoloTableRenderer extends TileEntitySpecialRenderer
- {
- private static FloatBuffer colorBuffer = GLAllocation.func_74529_h(16);
- private static final Vec3 field_82884_b = Vec3.func_72443_a(0.2000000029802322D, 1.0D, -0.699999988079071D).func_72432_b();
- private static final Vec3 field_82885_c = Vec3.func_72443_a(-0.2000000029802322D, 1.0D, 0.699999988079071D).func_72432_b();
- public void func_76894_a(TileEntity tileentity, double d0, double d1, double d2, float f)
- {
- renderVOB((TileEntityHoloTable)tileentity, d0, d1, d2, f);
- }
- public void render(TileEntityHoloTable tile, double d0, double d1, double d2, float partialTick) {
- if ((tile.isThePlayerNearby()) && (!tile.blocklist.isEmpty()))
- {
- GL11.glPushMatrix();
- GL11.glTranslated(d0 + 0.5D, d1 + 1.05D, d2 + 0.5D);
- GL11.glPushMatrix();
- GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
- GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
- GL11.glEnable(2896);
- GL11.glEnable(16384);
- GL11.glEnable(16385);
- GL11.glEnable(2903);
- GL11.glColorMaterial(1032, 5634);
- float f = 1.0F;
- float f1 = -0.0055F;
- float f2 = 0.0F;
- GL11.glLight(16384, 4611, setColorBuffer(field_82884_b.field_72450_a, -20.0D, field_82884_b.field_72449_c, 0.0D));
- GL11.glLight(16384, 4609, setColorBuffer(f1, f1, f1, 1.0F));
- GL11.glLight(16384, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
- GL11.glLight(16384, 4610, setColorBuffer(f2, f2, f2, 1.0F));
- GL11.glLight(16385, 4611, setColorBuffer(field_82885_c.field_72450_a, -20.0D, field_82885_c.field_72449_c, 0.0D));
- GL11.glLight(16385, 4609, setColorBuffer(f1, f1, f1, 1.0F));
- GL11.glLight(16385, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
- GL11.glLight(16385, 4610, setColorBuffer(f2, f2, f2, 1.0F));
- GL11.glShadeModel(7424);
- GL11.glLightModel(2899, setColorBuffer(f, f, f, 1.0F));
- GL11.glPopMatrix();
- float scale = 0.03030303F;
- GL11.glScalef(scale, scale, scale);
- GL11.glDisable(3553);
- GL11.glEnable(2884);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- Tessellator tes = Tessellator.field_78398_a;
- tes.func_78382_b();
- for (BlockData data : tile.blocklist) {
- renderBlock(tes, data.x, data.y, data.z, data.sides, tile.field_70331_k.field_73012_v);
- }
- tes.func_78381_a();
- GL11.glPopMatrix();
- }
- }
- public void renderVOB(TileEntityHoloTable tile, double d0, double d1, double d2, float partialTick) {
- if ((tile.isThePlayerNearby()) && (!tile.blocklist.isEmpty()))
- {
- GL11.glPushMatrix();
- GL11.glTranslated(d0 + 0.5D, d1 + 1.05D, d2 + 0.5D);
- GL11.glPushMatrix();
- GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
- GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
- GL11.glEnable(2896);
- GL11.glEnable(16384);
- GL11.glEnable(16385);
- GL11.glEnable(2903);
- GL11.glColorMaterial(1032, 5634);
- float f = 1.0F;
- float f1 = -0.0055F;
- float f2 = 0.0F;
- GL11.glLight(16384, 4611, setColorBuffer(field_82884_b.field_72450_a, -20.0D, field_82884_b.field_72449_c, 0.0D));
- GL11.glLight(16384, 4609, setColorBuffer(f1, f1, f1, 1.0F));
- GL11.glLight(16384, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
- GL11.glLight(16384, 4610, setColorBuffer(f2, f2, f2, 1.0F));
- GL11.glLight(16385, 4611, setColorBuffer(field_82885_c.field_72450_a, -20.0D, field_82885_c.field_72449_c, 0.0D));
- GL11.glLight(16385, 4609, setColorBuffer(f1, f1, f1, 1.0F));
- GL11.glLight(16385, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
- GL11.glLight(16385, 4610, setColorBuffer(f2, f2, f2, 1.0F));
- GL11.glShadeModel(7424);
- GL11.glLightModel(2899, setColorBuffer(f, f, f, 1.0F));
- GL11.glPopMatrix();
- float scale = 0.03030303F;
- GL11.glScalef(scale, scale, scale);
- GL11.glDisable(3553);
- GL11.glEnable(2884);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- int offx = 0;
- int offz = 0;
- if (!tile.main) {
- offx = (tile.field_70329_l - tile.parentX) * tile.size * 2;
- offz = (tile.field_70327_n - tile.parentZ) * tile.size * 2;
- }
- AxisAlignedBB box = AxisAlignedBB.func_72330_a(tile.field_70329_l + offx - 16, tile.field_70330_m - 16, tile.field_70327_n + offz - 16, tile.field_70329_l + offx + 17, tile.field_70330_m + 17, tile.field_70327_n + offz + 17);
- Sphere sph = new Sphere();
- for (Entity ent : tile.field_70331_k.func_72910_y()) {
- if (((ent instanceof EntityLiving)) && (box.func_72326_a(ent.field_70121_D)) && (!(ent instanceof EntityClientPlayerMP)) && (tile.field_70331_k.field_73012_v.nextBoolean()))
- {
- float[] col = { 0.0F, 1.0F, 0.0F };
- if ((ent instanceof IMob)) {
- col = new float[] { 1.0F, 0.0F, 0.0F };
- }
- if ((ent instanceof EntityPlayer)) {
- col = new float[] { 1.0F, 1.0F, 1.0F };
- }
- GL11.glColor4f(col[0], col[1], col[2], 1.0F);
- double dx = tile.field_70329_l + offx - ent.field_70165_t;
- double dy = tile.field_70330_m - ent.field_70163_u;
- double dz = tile.field_70327_n + offz - ent.field_70161_v;
- GL11.glTranslated(-dx, -dy, -dz);
- sph.draw(0.8F, 6, 6);
- GL11.glTranslated(dx, dy, dz);
- }
- }
- OpenGlHelper.func_77472_b(OpenGlHelper.field_77476_b);
- GL11.glEnableClientState(32884);
- GL11.glEnableClientState(32885);
- GL11.glEnableClientState(32886);
- GL11.glEnableClientState(32888);
- if ((tile.buffid > 0) && (tile.buff != null)) {
- ARBVertexBufferObject.glBindBufferARB(34962, tile.buffid);
- GL11.glVertexPointer(3, 5126, 48, 0L);
- GL11.glNormalPointer(5126, 48, 12L);
- GL11.glColorPointer(4, 5126, 48, 24L);
- GL11.glTexCoordPointer(2, 5126, 48, 40L);
- GL11.glDrawArrays(7, 0, tile.buff.limit() / 12);
- ARBVertexBufferObject.glBindBufferARB(34962, 0);
- }
- GL11.glDisableClientState(32888);
- GL11.glDisableClientState(32884);
- GL11.glDisableClientState(32885);
- GL11.glDisableClientState(32886);
- OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a);
- GL11.glEnable(3553);
- GL11.glPopMatrix();
- }
- }
- public void renderBlock(Tessellator tes, int x, int y, int z, boolean[] sides, Random rand)
- {
- float f = 0.5F;
- float f1 = 2.0F / (5 + rand.nextInt(100));
- tes.func_78369_a(0.5F, 0.5F, 1.0F, 0.6F + f1);
- tes.func_78380_c(200);
- if (sides[0] != 0) {
- tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
- tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
- tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
- tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
- }
- if (sides[1] != 0) {
- tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
- tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
- tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
- tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
- }
- if (sides[2] != 0) {
- tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
- }
- if (sides[3] != 0) {
- tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
- tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
- }
- if (sides[4] != 0) {
- tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
- tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
- tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
- tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
- }
- if (sides[5] != 0) {
- tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
- tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
- tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
- tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
- }
- }
- private static FloatBuffer setColorBuffer(double par0, double par2, double par4, double par6)
- {
- return setColorBuffer((float)par0, (float)par2, (float)par4, (float)par6);
- }
- private static FloatBuffer setColorBuffer(float par0, float par1, float par2, float par3)
- {
- colorBuffer.clear();
- colorBuffer.put(par0).put(par1).put(par2).put(par3);
- colorBuffer.flip();
- return colorBuffer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement