Advertisement
tahg

Untitled

Oct 11th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. package buildermod.client;
  2.  
  3. import net.minecraft.client.renderer.RenderHelper;
  4. import net.minecraft.client.renderer.Tessellator;
  5. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  6. import net.minecraft.tileentity.TileEntity;
  7. import net.minecraft.util.ResourceLocation;
  8.  
  9. import org.lwjgl.opengl.GL11;
  10.  
  11. import buildermod.common.TileEntityBuilder;
  12.  
  13. public class TileEntityBuilderRenderer extends TileEntitySpecialRenderer {
  14. private static final ResourceLocation RSC_BUILDER = new ResourceLocation("buildermod:textures/entities/builder2.png");
  15. ModelBuilderPost post = new ModelBuilderPost();
  16. ModelBuilder builder = new ModelBuilder();
  17.  
  18. public void renderTileEntityAt(TileEntityBuilder entity, double x, double y, double z, float f) {
  19. int dir = entity.getWorldObj().getBlockMetadata(entity.xCoord, entity.yCoord, entity.zCoord) & 3;
  20. bindTexture(RSC_BUILDER);
  21. GL11.glPushMatrix();
  22. GL11.glDisable(GL11.GL_CULL_FACE);
  23. GL11.glTranslated(x + .5, y + 1, z + .5);
  24. GL11.glScaled(1, -1, -1);
  25. GL11.glColor3f(1, 1, 1);
  26. GL11.glRotated(90 * (dir + 2), 0, 1, 0);
  27. builder.renderAll();
  28. // GL11.glRotated(-90 * dir, 0, 1, 0);
  29. if (entity.hasWork()) {
  30. int size = entity.getModel().getSize();
  31. if (size <= 0)
  32. return;
  33. // GL11.glEnable(GL11.GL_BLEND);
  34. // OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA,
  35. // GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
  36. Tessellator tess = Tessellator.instance;
  37. RenderHelper.disableStandardItemLighting();
  38. tess.startDrawing(GL11.GL_QUAD_STRIP);
  39. float x1 = -0.563f;
  40. float x2 = size - 0.437f;
  41. float z1 = 0.437f;
  42. float z2 = size + 0.563f;
  43. float[] xx = { x1, x1, x2, x2, x1 };
  44. float[] zz = { z1, z2, z2, z1, z1 };
  45. for (int i = 0; i < 5; i++) {
  46. tess.addVertexWithUV(xx[i], 1, zz[i], (size + .25) * i / 2,
  47. 31.0 / 64);
  48. tess.addVertexWithUV(xx[i], 2.0 / 16, zz[i], (size + .25) * i
  49. / 2, 0);
  50. }
  51. tess.draw();
  52. GL11.glEnable(GL11.GL_CULL_FACE);
  53. GL11.glTranslated((x1 + x2) / 2, 0, (z1 + z2) / 2);
  54. for (int i = 0; i < 4; i++) {
  55. for (int j = 0; j < size; j += 9) {
  56. GL11.glTranslated(-size / 2.0 + j, 0, size / 2.0);
  57. post.renderAll();
  58. GL11.glTranslated(size / 2.0 - j, 0, -size / 2.0);
  59. }
  60. GL11.glRotated(90, 0, 1, 0);
  61. }
  62. // GL11.glRotated(180 - 90 * dir, 0, 1, 0);
  63. // GL11.glTranslated(-.5, .5, .5);
  64. }
  65. GL11.glPopMatrix();
  66. }
  67.  
  68. @Override
  69. public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f) {
  70. renderTileEntityAt((TileEntityBuilder) entity, x, y, z, f);
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement