Advertisement
Corosus

Untitled

May 6th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. package cjb.rebirth.blocks.client.renderer;
  2.  
  3. import cjb.rebirth.blocks.client.BlockData;
  4. import cjb.rebirth.blocks.tileentity.TileEntityHoloTable;
  5. import java.nio.FloatBuffer;
  6. import java.util.List;
  7. import java.util.Random;
  8. import net.minecraft.client.entity.EntityClientPlayerMP;
  9. import net.minecraft.client.renderer.GLAllocation;
  10. import net.minecraft.client.renderer.OpenGlHelper;
  11. import net.minecraft.client.renderer.Tessellator;
  12. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  13. import net.minecraft.entity.Entity;
  14. import net.minecraft.entity.EntityLiving;
  15. import net.minecraft.entity.monster.IMob;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.tileentity.TileEntity;
  18. import net.minecraft.util.AxisAlignedBB;
  19. import net.minecraft.util.Vec3;
  20. import net.minecraft.world.World;
  21. import org.lwjgl.opengl.ARBVertexBufferObject;
  22. import org.lwjgl.opengl.GL11;
  23. import org.lwjgl.util.glu.Sphere;
  24.  
  25. public class TileEntityHoloTableRenderer extends TileEntitySpecialRenderer
  26. {
  27. private static FloatBuffer colorBuffer = GLAllocation.func_74529_h(16);
  28. private static final Vec3 field_82884_b = Vec3.func_72443_a(0.2000000029802322D, 1.0D, -0.699999988079071D).func_72432_b();
  29. private static final Vec3 field_82885_c = Vec3.func_72443_a(-0.2000000029802322D, 1.0D, 0.699999988079071D).func_72432_b();
  30.  
  31. public void func_76894_a(TileEntity tileentity, double d0, double d1, double d2, float f)
  32. {
  33. renderVOB((TileEntityHoloTable)tileentity, d0, d1, d2, f);
  34. }
  35.  
  36. public void render(TileEntityHoloTable tile, double d0, double d1, double d2, float partialTick) {
  37. if ((tile.isThePlayerNearby()) && (!tile.blocklist.isEmpty()))
  38. {
  39. GL11.glPushMatrix();
  40. GL11.glTranslated(d0 + 0.5D, d1 + 1.05D, d2 + 0.5D);
  41.  
  42. GL11.glPushMatrix();
  43. GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
  44. GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
  45.  
  46. GL11.glEnable(2896);
  47. GL11.glEnable(16384);
  48. GL11.glEnable(16385);
  49. GL11.glEnable(2903);
  50. GL11.glColorMaterial(1032, 5634);
  51. float f = 1.0F;
  52. float f1 = -0.0055F;
  53. float f2 = 0.0F;
  54. GL11.glLight(16384, 4611, setColorBuffer(field_82884_b.field_72450_a, -20.0D, field_82884_b.field_72449_c, 0.0D));
  55. GL11.glLight(16384, 4609, setColorBuffer(f1, f1, f1, 1.0F));
  56. GL11.glLight(16384, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
  57. GL11.glLight(16384, 4610, setColorBuffer(f2, f2, f2, 1.0F));
  58.  
  59. GL11.glLight(16385, 4611, setColorBuffer(field_82885_c.field_72450_a, -20.0D, field_82885_c.field_72449_c, 0.0D));
  60. GL11.glLight(16385, 4609, setColorBuffer(f1, f1, f1, 1.0F));
  61. GL11.glLight(16385, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
  62. GL11.glLight(16385, 4610, setColorBuffer(f2, f2, f2, 1.0F));
  63.  
  64. GL11.glShadeModel(7424);
  65. GL11.glLightModel(2899, setColorBuffer(f, f, f, 1.0F));
  66.  
  67. GL11.glPopMatrix();
  68.  
  69. float scale = 0.03030303F;
  70. GL11.glScalef(scale, scale, scale);
  71. GL11.glDisable(3553);
  72. GL11.glEnable(2884);
  73. GL11.glEnable(3042);
  74. GL11.glBlendFunc(770, 771);
  75.  
  76. Tessellator tes = Tessellator.field_78398_a;
  77. tes.func_78382_b();
  78. for (BlockData data : tile.blocklist) {
  79. renderBlock(tes, data.x, data.y, data.z, data.sides, tile.field_70331_k.field_73012_v);
  80. }
  81. tes.func_78381_a();
  82. GL11.glPopMatrix();
  83. }
  84. }
  85.  
  86. public void renderVOB(TileEntityHoloTable tile, double d0, double d1, double d2, float partialTick) {
  87. if ((tile.isThePlayerNearby()) && (!tile.blocklist.isEmpty()))
  88. {
  89. GL11.glPushMatrix();
  90. GL11.glTranslated(d0 + 0.5D, d1 + 1.05D, d2 + 0.5D);
  91.  
  92. GL11.glPushMatrix();
  93. GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
  94. GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
  95.  
  96. GL11.glEnable(2896);
  97. GL11.glEnable(16384);
  98. GL11.glEnable(16385);
  99. GL11.glEnable(2903);
  100. GL11.glColorMaterial(1032, 5634);
  101. float f = 1.0F;
  102. float f1 = -0.0055F;
  103. float f2 = 0.0F;
  104. GL11.glLight(16384, 4611, setColorBuffer(field_82884_b.field_72450_a, -20.0D, field_82884_b.field_72449_c, 0.0D));
  105. GL11.glLight(16384, 4609, setColorBuffer(f1, f1, f1, 1.0F));
  106. GL11.glLight(16384, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
  107. GL11.glLight(16384, 4610, setColorBuffer(f2, f2, f2, 1.0F));
  108.  
  109. GL11.glLight(16385, 4611, setColorBuffer(field_82885_c.field_72450_a, -20.0D, field_82885_c.field_72449_c, 0.0D));
  110. GL11.glLight(16385, 4609, setColorBuffer(f1, f1, f1, 1.0F));
  111. GL11.glLight(16385, 4608, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
  112. GL11.glLight(16385, 4610, setColorBuffer(f2, f2, f2, 1.0F));
  113.  
  114. GL11.glShadeModel(7424);
  115. GL11.glLightModel(2899, setColorBuffer(f, f, f, 1.0F));
  116.  
  117. GL11.glPopMatrix();
  118.  
  119. float scale = 0.03030303F;
  120. GL11.glScalef(scale, scale, scale);
  121. GL11.glDisable(3553);
  122. GL11.glEnable(2884);
  123. GL11.glEnable(3042);
  124. GL11.glBlendFunc(770, 771);
  125.  
  126. int offx = 0;
  127. int offz = 0;
  128.  
  129. if (!tile.main) {
  130. offx = (tile.field_70329_l - tile.parentX) * tile.size * 2;
  131. offz = (tile.field_70327_n - tile.parentZ) * tile.size * 2;
  132. }
  133.  
  134. 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);
  135. Sphere sph = new Sphere();
  136. for (Entity ent : tile.field_70331_k.func_72910_y()) {
  137. if (((ent instanceof EntityLiving)) && (box.func_72326_a(ent.field_70121_D)) && (!(ent instanceof EntityClientPlayerMP)) && (tile.field_70331_k.field_73012_v.nextBoolean()))
  138. {
  139. float[] col = { 0.0F, 1.0F, 0.0F };
  140.  
  141. if ((ent instanceof IMob)) {
  142. col = new float[] { 1.0F, 0.0F, 0.0F };
  143. }
  144. if ((ent instanceof EntityPlayer)) {
  145. col = new float[] { 1.0F, 1.0F, 1.0F };
  146. }
  147. GL11.glColor4f(col[0], col[1], col[2], 1.0F);
  148. double dx = tile.field_70329_l + offx - ent.field_70165_t;
  149. double dy = tile.field_70330_m - ent.field_70163_u;
  150. double dz = tile.field_70327_n + offz - ent.field_70161_v;
  151.  
  152. GL11.glTranslated(-dx, -dy, -dz);
  153. sph.draw(0.8F, 6, 6);
  154. GL11.glTranslated(dx, dy, dz);
  155. }
  156. }
  157.  
  158. OpenGlHelper.func_77472_b(OpenGlHelper.field_77476_b);
  159. GL11.glEnableClientState(32884);
  160. GL11.glEnableClientState(32885);
  161. GL11.glEnableClientState(32886);
  162. GL11.glEnableClientState(32888);
  163.  
  164. if ((tile.buffid > 0) && (tile.buff != null)) {
  165. ARBVertexBufferObject.glBindBufferARB(34962, tile.buffid);
  166. GL11.glVertexPointer(3, 5126, 48, 0L);
  167. GL11.glNormalPointer(5126, 48, 12L);
  168. GL11.glColorPointer(4, 5126, 48, 24L);
  169. GL11.glTexCoordPointer(2, 5126, 48, 40L);
  170. GL11.glDrawArrays(7, 0, tile.buff.limit() / 12);
  171. ARBVertexBufferObject.glBindBufferARB(34962, 0);
  172. }
  173.  
  174. GL11.glDisableClientState(32888);
  175. GL11.glDisableClientState(32884);
  176. GL11.glDisableClientState(32885);
  177. GL11.glDisableClientState(32886);
  178. OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a);
  179.  
  180. GL11.glEnable(3553);
  181.  
  182. GL11.glPopMatrix();
  183. }
  184. }
  185.  
  186. public void renderBlock(Tessellator tes, int x, int y, int z, boolean[] sides, Random rand)
  187. {
  188. float f = 0.5F;
  189. float f1 = 2.0F / (5 + rand.nextInt(100));
  190.  
  191. tes.func_78369_a(0.5F, 0.5F, 1.0F, 0.6F + f1);
  192. tes.func_78380_c(200);
  193.  
  194. if (sides[0] != 0) {
  195. tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
  196. tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
  197. tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
  198. tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(0.0F, 1.0F, 0.0F);
  199. }
  200. if (sides[1] != 0) {
  201. tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
  202. tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
  203. tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
  204. tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(0.0F, -1.0F, 0.0F);
  205. }
  206. if (sides[2] != 0) {
  207. tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
  208. tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
  209. tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
  210. tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(-1.0F, 0.0F, 0.0F);
  211. }
  212. if (sides[3] != 0) {
  213. tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
  214. tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
  215. tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
  216. tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(1.0F, 0.0F, 0.0F);
  217. }
  218. if (sides[4] != 0) {
  219. tes.func_78377_a(x - f, y - f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
  220. tes.func_78377_a(x - f, y + f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
  221. tes.func_78377_a(x + f, y + f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
  222. tes.func_78377_a(x + f, y - f, z - f); tes.func_78375_b(0.0F, 0.0F, -1.0F);
  223. }
  224. if (sides[5] != 0) {
  225. tes.func_78377_a(x - f, y - f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
  226. tes.func_78377_a(x + f, y - f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
  227. tes.func_78377_a(x + f, y + f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
  228. tes.func_78377_a(x - f, y + f, z + f); tes.func_78375_b(0.0F, 0.0F, 1.0F);
  229. }
  230. }
  231.  
  232. private static FloatBuffer setColorBuffer(double par0, double par2, double par4, double par6)
  233. {
  234. return setColorBuffer((float)par0, (float)par2, (float)par4, (float)par6);
  235. }
  236.  
  237. private static FloatBuffer setColorBuffer(float par0, float par1, float par2, float par3)
  238. {
  239. colorBuffer.clear();
  240. colorBuffer.put(par0).put(par1).put(par2).put(par3);
  241. colorBuffer.flip();
  242. return colorBuffer;
  243. }
  244. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement