Advertisement
Guest User

Untitled

a guest
Sep 30th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. package landcast.common;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.client.renderer.OpenGlHelper;
  5. import net.minecraft.client.renderer.Tessellator;
  6. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.tileentity.TileEntity;
  9. import net.minecraft.util.ResourceLocation;
  10. import net.minecraft.world.World;
  11.  
  12. import org.lwjgl.opengl.GL11;
  13.  
  14.  
  15.  
  16. public class TileEntityBlockTestRender extends TileEntitySpecialRenderer
  17. {
  18.  
  19. private final ModelTest model;
  20.  
  21. protected static final ResourceLocation texture = new ResourceLocation("landcast:textures/blocks/BlockTest.png");
  22.  
  23.  
  24. public TileEntityBlockTestRender()
  25. {
  26. this.model = new ModelTest();
  27. }
  28.  
  29. private void adjustRotatePivotViaMeta(World world, int x, int y, int z)
  30. {
  31. int meta = world.getBlockMetadata(x, y, z);
  32. GL11.glPushMatrix();
  33. GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);
  34. GL11.glPopMatrix();
  35.  
  36. }
  37.  
  38. @Override
  39. public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float scale)
  40. {
  41. this.renderTileEntityAtBlockTest((TileEntityBlockTest)tileentity, x, y, z, scale);
  42.  
  43. }
  44.  
  45.  
  46. public void renderTileEntityAtBlockTest(TileEntityBlockTest tileentity, double x, double y, double z, float scale)
  47. {
  48. GL11.glPushMatrix();
  49. GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
  50. this.bindTexture(texture);
  51. GL11.glPushMatrix();
  52. GL11.glRotatef(180F, 180.0F, 0.0F, 1.0F);
  53. GL11.glRotatef(90F * tileentity.getBlockMetadata(), 0.0F, 1.0F, 0.0F);
  54. this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  55. GL11.glPopMatrix();
  56. GL11.glPopMatrix();
  57.  
  58. }
  59.  
  60. private void adjustLightFixture(World world, int i, int j, int k, Block block)
  61. {
  62. Tessellator tess = Tessellator.instance;
  63. float brightness = block.getBlockBrightness(world, i, j, k);
  64. int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
  65. int modulousModifier = skyLight % 65536;
  66. int divModifier = skyLight / 65536;
  67. tess.setColorOpaque_F(brightness, brightness, brightness);
  68. OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)modulousModifier, divModifier);
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement