| 1 | package net.minecraft.client.renderer.tileentity;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.minecraft.block.Block;
|
| 5 | import net.minecraft.client.gui.FontRenderer;
|
| 6 | import net.minecraft.client.gui.GuiUtilRenderComponents;
|
| 7 | import net.minecraft.client.model.ModelSign;
|
| 8 | import net.minecraft.client.renderer.GlStateManager;
|
| 9 | import net.minecraft.init.Blocks;
|
| 10 | import net.minecraft.tileentity.TileEntitySign;
|
| 11 | import net.minecraft.util.IChatComponent;
|
| 12 | import net.minecraft.util.ResourceLocation;
|
| 13 | import org.lwjgl.opengl.GL11;
|
| 14 |
|
| 15 | public class TileEntitySignRenderer extends TileEntitySpecialRenderer<TileEntitySign>
|
| 16 | {
|
| 17 | private static final ResourceLocation SIGN_TEXTURE = new ResourceLocation("textures/entity/sign.png");
|
| 18 |
|
| 19 | /** The ModelSign instance for use in this renderer */
|
| 20 | private final ModelSign model = new ModelSign();
|
| 21 |
|
| 22 | public void renderTileEntityAt(TileEntitySign te, double x, double y, double z, float partialTicks, int destroyStage)
|
| 23 | {
|
| 24 | Block block = te.getBlockType();
|
| 25 | GlStateManager.pushMatrix();
|
| 26 | float f = 0.6666667F;
|
| 27 |
|
| 28 | if (block == Blocks.standing_sign)
|
| 29 | {
|
| 30 | GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
|
| 31 | float f1 = (float)(te.getBlockMetadata() * 360) / 16.0F;
|
| 32 | GlStateManager.rotate(-f1, 0.0F, 1.0F, 0.0F);
|
| 33 | this.model.signStick.showModel = true;
|
| 34 | }
|
| 35 | else
|
| 36 | {
|
| 37 | int k = te.getBlockMetadata();
|
| 38 | float f2 = 0.0F;
|
| 39 |
|
| 40 | if (k == 2)
|
| 41 | {
|
| 42 | f2 = 180.0F;
|
| 43 | }
|
| 44 |
|
| 45 | if (k == 4)
|
| 46 | {
|
| 47 | f2 = 90.0F;
|
| 48 | }
|
| 49 |
|
| 50 | if (k == 5)
|
| 51 | {
|
| 52 | f2 = -90.0F;
|
| 53 | }
|
| 54 |
|
| 55 | GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
|
| 56 | GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
|
| 57 | GlStateManager.translate(0.0F, -0.3125F, -0.4375F);
|
| 58 | this.model.signStick.showModel = false;
|
| 59 | }
|
| 60 |
|
| 61 | if (destroyStage >= 0)
|
| 62 | {
|
| 63 | this.bindTexture(DESTROY_STAGES[destroyStage]);
|
| 64 | GlStateManager.matrixMode(5890);
|
| 65 | GlStateManager.pushMatrix();
|
| 66 | GlStateManager.scale(4.0F, 2.0F, 1.0F);
|
| 67 | GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
|
| 68 | GlStateManager.matrixMode(5888);
|
| 69 | }
|
| 70 | else
|
| 71 | {
|
| 72 | this.bindTexture(SIGN_TEXTURE);
|
| 73 | }
|
| 74 |
|
| 75 | GlStateManager.enableRescaleNormal();
|
| 76 | GlStateManager.pushMatrix();
|
| 77 | GlStateManager.scale(f, -f, -f);
|
| 78 | this.model.renderSign();
|
| 79 | GlStateManager.popMatrix();
|
| 80 | FontRenderer fontrenderer = this.getFontRenderer();
|
| 81 | float f3 = 0.015625F * f;
|
| 82 | GlStateManager.translate(0.0F, 0.5F * f, 0.07F * f);
|
| 83 | GlStateManager.scale(f3, -f3, f3);
|
| 84 | GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3);
|
| 85 | GlStateManager.depthMask(false);
|
| 86 | int i = 0;
|
| 87 |
|
| 88 | if (destroyStage < 0)
|
| 89 | {
|
| 90 | for (int j = 0; j < te.signText.length; ++j)
|
| 91 | {
|
| 92 | if (te.signText[j] != null)
|
| 93 | {
|
| 94 | IChatComponent ichatcomponent = te.signText[j];
|
| 95 | List<IChatComponent> list = GuiUtilRenderComponents.splitText(ichatcomponent, 90, fontrenderer, false, true);
|
| 96 | String s = list != null && list.size() > 0 ? ((IChatComponent)list.get(0)).getFormattedText() : "";
|
| 97 |
|
| 98 | if (j == te.lineBeingEdited)
|
| 99 | {
|
| 100 | s = "> " + s + " <";
|
| 101 | fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, i);
|
| 102 | }
|
| 103 | else
|
| 104 | {
|
| 105 | fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, i);
|
| 106 | }
|
| 107 | }
|
| 108 | }
|
| 109 | }
|
| 110 |
|
| 111 | GlStateManager.depthMask(true);
|
| 112 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 113 | GlStateManager.popMatrix();
|
| 114 |
|
| 115 | if (destroyStage >= 0)
|
| 116 | {
|
| 117 | GlStateManager.matrixMode(5890);
|
| 118 | GlStateManager.popMatrix();
|
| 119 | GlStateManager.matrixMode(5888);
|
| 120 | }
|
| 121 | }
|
| 122 | }
|
| 123 |
|