Guest User

RenderSapphireCrop

a guest
Jul 2nd, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. package sometimesHardcoreSometimes;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.client.Minecraft;
  5. import net.minecraft.client.renderer.OpenGlHelper;
  6. import net.minecraft.client.renderer.Tessellator;
  7. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.tileentity.TileEntity;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraft.world.World;
  12.  
  13. import org.lwjgl.opengl.GL11;
  14.  
  15. public class RenderSapphireCrop extends TileEntitySpecialRenderer
  16. {
  17. private final ModelSapphireCrop model;
  18. int bAmt;
  19.  
  20. public RenderSapphireCrop()
  21. {
  22. this.model = new ModelSapphireCrop();
  23. }
  24.  
  25. private void adjustedRotatePivotViaMeta(World world, int x, int y, int z)
  26. {
  27. int meta = world.getBlockMetadata(x, y, z);
  28.  
  29. GL11.glPushMatrix();
  30. GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);
  31. GL11.glPopMatrix();
  32. }
  33.  
  34. @Override
  35. public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale)
  36. {
  37. GL11.glPushMatrix();
  38. GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
  39.  
  40. bAmt = BlockSapphireCrop.getBerryAmount();
  41.  
  42. ResourceLocation textures;
  43.  
  44. //Handles the texture
  45. switch(bAmt)
  46. {
  47. case 0:
  48. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_0.png"));
  49. break;
  50. case 1:
  51. case 2:
  52. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_1.png"));
  53. break;
  54. case 3:
  55. case 4:
  56. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_2.png"));
  57. break;
  58. case 5:
  59. case 6:
  60. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_3.png"));
  61. break;
  62. case 7:
  63. case 8:
  64. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_4.png"));
  65. break;
  66. case 9:
  67. case 10:
  68. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_5.png"));
  69. break;
  70. case 11:
  71. case 12:
  72. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_6.png"));
  73. break;
  74. case 13:
  75. case 14:
  76. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_7.png"));
  77. break;
  78. default:
  79. textures = (new ResourceLocation(Base.modid + ":textures/tileentity/sapphireCrop/sapphireCrop_0.png"));
  80. break;
  81. }
  82.  
  83. Minecraft.getMinecraft().renderEngine.bindTexture(textures);
  84.  
  85. int meta = tileEntity.getBlockMetadata();
  86. GL11.glPushMatrix();
  87.  
  88. if(meta % 4 == 0) GL11.glRotatef(-180F, 1.0F, 0.0F, 1.0F);
  89. if(meta % 4 == 1) GL11.glRotatef(-180F, -1.0F, 0.0F, 1.0F);
  90. if(meta % 4 == 2) GL11.glRotatef(-180F, 0.0F, 0.0F, 1.0F);
  91. if(meta % 4 == 3) GL11.glRotatef(-180F, 90F, 0.0F, 1.0F);
  92.  
  93. this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  94.  
  95. GL11.glPopMatrix();
  96. GL11.glPopMatrix();
  97. }
  98.  
  99. private void adjustLightFixture(World world, int i, int j, int k, Block block)
  100. {
  101. Tessellator tess = Tessellator.instance;
  102.  
  103. float brightness = block.getBlockBrightness(world, i, j, k);
  104. int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
  105. int modulousModifier = skyLight % 65536;
  106. int divModifier = skyLight / 65536;
  107.  
  108. tess.setColorOpaque_F(brightness, brightness, brightness);
  109. OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)modulousModifier, divModifier);
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment