Advertisement
tahg

Untitled

Oct 6th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package buildermod.client;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.client.Minecraft;
  5. import net.minecraft.client.renderer.RenderBlocks;
  6. import net.minecraft.client.renderer.Tessellator;
  7. import net.minecraft.client.renderer.texture.TextureManager;
  8. import net.minecraft.client.renderer.texture.TextureMap;
  9. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  10. import net.minecraft.tileentity.TileEntity;
  11. import net.minecraft.util.ResourceLocation;
  12.  
  13. import org.lwjgl.opengl.GL11;
  14.  
  15. import buildermod.common.SubWorld;
  16. import buildermod.common.TileEntityPalette;
  17.  
  18. public class TileEntityPaletteRenderer extends TileEntitySpecialRenderer {
  19. private static final ResourceLocation RSC_PALETTE = new ResourceLocation("buildermod:textures/entities/palette.png");
  20. ModelPalette palette = new ModelPalette();
  21. public static SubWorld sw = new SubWorld();
  22.  
  23. public void renderTileEntityAt(TileEntityPalette entity, double x, double y, double z, float f) {
  24. // int dir = entity.getWorldObj().getBlockMetadata(entity.xCoord, entity.yCoord, entity.zCoord) & 3;
  25. bindTexture(RSC_PALETTE);
  26. float rotation = entity.getWorldObj().getWorldTime() % 360;
  27. GL11.glPushMatrix();
  28. GL11.glTranslated(x, y, z);
  29. GL11.glTranslated(.5, .5, .5);
  30. GL11.glRotated(rotation, 0, 1, 0);
  31. GL11.glTranslated(-.5, -.5, -.5);
  32. GL11.glPushMatrix();
  33. GL11.glTranslated(0, 1, 1);
  34. GL11.glScaled(1, -1, -1);
  35. GL11.glColor3f(1, 1, 1);
  36. // GL11.glRotated(90 * (dir + 2), 0, 1, 0);
  37. palette.renderAll();
  38. GL11.glPopMatrix();
  39. GL11.glPushMatrix();
  40. GL11.glTranslated(1.0/16, 3.0/16, 1.0/16);
  41. GL11.glScaled(14.0/64, 14.0/64, 14.0/64);
  42. RenderBlocks rb = RenderHelper.rb;
  43. rb.blockAccess = sw;
  44. TextureManager tm = Minecraft.getMinecraft().getTextureManager();
  45. tm.bindTexture(TextureMap.locationBlocksTexture);
  46. Tessellator.instance.startDrawingQuads();
  47. for (int xx = 0; xx < 4; xx++) {
  48. for (int yy = 0; yy < 4; yy++) {
  49. for (int zz = 0; zz < 4; zz++) {
  50. Block block = sw.getBlock(xx, yy, zz);
  51. rb.renderBlockByRenderType(block, xx, yy, zz);
  52. }
  53. }
  54. }
  55. Tessellator.instance.draw();
  56. GL11.glPopMatrix();
  57. GL11.glPopMatrix();
  58. }
  59.  
  60. @Override
  61. public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f) {
  62. renderTileEntityAt((TileEntityPalette)entity, x, y, z, f);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement