| 1 | package net.minecraft.client.renderer.tileentity;
|
| 2 |
|
| 3 | import net.minecraft.client.model.ModelBook;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.entity.Entity;
|
| 6 | import net.minecraft.tileentity.TileEntityEnchantmentTable;
|
| 7 | import net.minecraft.util.MathHelper;
|
| 8 | import net.minecraft.util.ResourceLocation;
|
| 9 |
|
| 10 | public class TileEntityEnchantmentTableRenderer extends TileEntitySpecialRenderer<TileEntityEnchantmentTable>
|
| 11 | {
|
| 12 | /** The texture for the book above the enchantment table. */
|
| 13 | private static final ResourceLocation TEXTURE_BOOK = new ResourceLocation("textures/entity/enchanting_table_book.png");
|
| 14 | private ModelBook field_147541_c = new ModelBook();
|
| 15 |
|
| 16 | public void renderTileEntityAt(TileEntityEnchantmentTable te, double x, double y, double z, float partialTicks, int destroyStage)
|
| 17 | {
|
| 18 | GlStateManager.pushMatrix();
|
| 19 | GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F, (float)z + 0.5F);
|
| 20 | float f = (float)te.tickCount + partialTicks;
|
| 21 | GlStateManager.translate(0.0F, 0.1F + MathHelper.sin(f * 0.1F) * 0.01F, 0.0F);
|
| 22 | float f1;
|
| 23 |
|
| 24 | for (f1 = te.bookRotation - te.bookRotationPrev; f1 >= (float)Math.PI; f1 -= ((float)Math.PI * 2F))
|
| 25 | {
|
| 26 | ;
|
| 27 | }
|
| 28 |
|
| 29 | while (f1 < -(float)Math.PI)
|
| 30 | {
|
| 31 | f1 += ((float)Math.PI * 2F);
|
| 32 | }
|
| 33 |
|
| 34 | float f2 = te.bookRotationPrev + f1 * partialTicks;
|
| 35 | GlStateManager.rotate(-f2 * 180.0F / (float)Math.PI, 0.0F, 1.0F, 0.0F);
|
| 36 | GlStateManager.rotate(80.0F, 0.0F, 0.0F, 1.0F);
|
| 37 | this.bindTexture(TEXTURE_BOOK);
|
| 38 | float f3 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.25F;
|
| 39 | float f4 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.75F;
|
| 40 | f3 = (f3 - (float)MathHelper.truncateDoubleToInt((double)f3)) * 1.6F - 0.3F;
|
| 41 | f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F;
|
| 42 |
|
| 43 | if (f3 < 0.0F)
|
| 44 | {
|
| 45 | f3 = 0.0F;
|
| 46 | }
|
| 47 |
|
| 48 | if (f4 < 0.0F)
|
| 49 | {
|
| 50 | f4 = 0.0F;
|
| 51 | }
|
| 52 |
|
| 53 | if (f3 > 1.0F)
|
| 54 | {
|
| 55 | f3 = 1.0F;
|
| 56 | }
|
| 57 |
|
| 58 | if (f4 > 1.0F)
|
| 59 | {
|
| 60 | f4 = 1.0F;
|
| 61 | }
|
| 62 |
|
| 63 | float f5 = te.bookSpreadPrev + (te.bookSpread - te.bookSpreadPrev) * partialTicks;
|
| 64 | GlStateManager.enableCull();
|
| 65 | this.field_147541_c.render((Entity)null, f, f3, f4, f5, 0.0F, 0.0625F);
|
| 66 | GlStateManager.popMatrix();
|
| 67 | }
|
| 68 | }
|
| 69 |
|