| 1 | package net.minecraft.client.renderer.tileentity;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.client.renderer.Tessellator;
|
| 6 | import net.minecraft.client.renderer.WorldRenderer;
|
| 7 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 8 | import net.minecraft.tileentity.TileEntityBeacon;
|
| 9 | import net.minecraft.util.MathHelper;
|
| 10 | import net.minecraft.util.ResourceLocation;
|
| 11 | import org.lwjgl.opengl.GL11;
|
| 12 |
|
| 13 | public class TileEntityBeaconRenderer extends TileEntitySpecialRenderer<TileEntityBeacon>
|
| 14 | {
|
| 15 | private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png");
|
| 16 |
|
| 17 | public void renderTileEntityAt(TileEntityBeacon te, double x, double y, double z, float partialTicks, int destroyStage)
|
| 18 | {
|
| 19 | float f = te.shouldBeamRender();
|
| 20 | GlStateManager.alphaFunc(516, 0.1F);
|
| 21 |
|
| 22 | if (f > 0.0F)
|
| 23 | {
|
| 24 | Tessellator tessellator = Tessellator.getInstance();
|
| 25 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 26 | GlStateManager.disableFog();
|
| 27 | List<TileEntityBeacon.BeamSegment> list = te.getBeamSegments();
|
| 28 | int i = 0;
|
| 29 |
|
| 30 | for (int j = 0; j < list.size(); ++j)
|
| 31 | {
|
| 32 | TileEntityBeacon.BeamSegment tileentitybeacon$beamsegment = (TileEntityBeacon.BeamSegment)list.get(j);
|
| 33 | int k = i + tileentitybeacon$beamsegment.getHeight();
|
| 34 | this.bindTexture(beaconBeam);
|
| 35 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
|
| 36 | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
|
| 37 | GlStateManager.disableLighting();
|
| 38 | GlStateManager.disableCull();
|
| 39 | GlStateManager.disableBlend();
|
| 40 | GlStateManager.depthMask(true);
|
| 41 | GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
|
| 42 | double d0 = (double)te.getWorld().getTotalWorldTime() + (double)partialTicks;
|
| 43 | double d1 = MathHelper.func_181162_h(-d0 * 0.2D - (double)MathHelper.floor_double(-d0 * 0.1D));
|
| 44 | float f1 = tileentitybeacon$beamsegment.getColors()[0];
|
| 45 | float f2 = tileentitybeacon$beamsegment.getColors()[1];
|
| 46 | float f3 = tileentitybeacon$beamsegment.getColors()[2];
|
| 47 | double d2 = d0 * 0.025D * -1.5D;
|
| 48 | double d3 = 0.2D;
|
| 49 | double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D;
|
| 50 | double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D;
|
| 51 | double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D;
|
| 52 | double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D;
|
| 53 | double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D;
|
| 54 | double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D;
|
| 55 | double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D;
|
| 56 | double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D;
|
| 57 | double d12 = 0.0D;
|
| 58 | double d13 = 1.0D;
|
| 59 | double d14 = -1.0D + d1;
|
| 60 | double d15 = (double)((float)tileentitybeacon$beamsegment.getHeight() * f) * 2.5D + d14;
|
| 61 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 62 | worldrenderer.pos(x + d4, y + (double)k, z + d5).tex(1.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 63 | worldrenderer.pos(x + d4, y + (double)i, z + d5).tex(1.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 64 | worldrenderer.pos(x + d6, y + (double)i, z + d7).tex(0.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 65 | worldrenderer.pos(x + d6, y + (double)k, z + d7).tex(0.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 66 | worldrenderer.pos(x + d10, y + (double)k, z + d11).tex(1.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 67 | worldrenderer.pos(x + d10, y + (double)i, z + d11).tex(1.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 68 | worldrenderer.pos(x + d8, y + (double)i, z + d9).tex(0.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 69 | worldrenderer.pos(x + d8, y + (double)k, z + d9).tex(0.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 70 | worldrenderer.pos(x + d6, y + (double)k, z + d7).tex(1.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 71 | worldrenderer.pos(x + d6, y + (double)i, z + d7).tex(1.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 72 | worldrenderer.pos(x + d10, y + (double)i, z + d11).tex(0.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 73 | worldrenderer.pos(x + d10, y + (double)k, z + d11).tex(0.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 74 | worldrenderer.pos(x + d8, y + (double)k, z + d9).tex(1.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 75 | worldrenderer.pos(x + d8, y + (double)i, z + d9).tex(1.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 76 | worldrenderer.pos(x + d4, y + (double)i, z + d5).tex(0.0D, d14).color(f1, f2, f3, 1.0F).endVertex();
|
| 77 | worldrenderer.pos(x + d4, y + (double)k, z + d5).tex(0.0D, d15).color(f1, f2, f3, 1.0F).endVertex();
|
| 78 | tessellator.draw();
|
| 79 | GlStateManager.enableBlend();
|
| 80 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 81 | GlStateManager.depthMask(false);
|
| 82 | d2 = 0.2D;
|
| 83 | d3 = 0.2D;
|
| 84 | d4 = 0.8D;
|
| 85 | d5 = 0.2D;
|
| 86 | d6 = 0.2D;
|
| 87 | d7 = 0.8D;
|
| 88 | d8 = 0.8D;
|
| 89 | d9 = 0.8D;
|
| 90 | d10 = 0.0D;
|
| 91 | d11 = 1.0D;
|
| 92 | d12 = -1.0D + d1;
|
| 93 | d13 = (double)((float)tileentitybeacon$beamsegment.getHeight() * f) + d12;
|
| 94 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 95 | worldrenderer.pos(x + 0.2D, y + (double)k, z + 0.2D).tex(1.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 96 | worldrenderer.pos(x + 0.2D, y + (double)i, z + 0.2D).tex(1.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 97 | worldrenderer.pos(x + 0.8D, y + (double)i, z + 0.2D).tex(0.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 98 | worldrenderer.pos(x + 0.8D, y + (double)k, z + 0.2D).tex(0.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 99 | worldrenderer.pos(x + 0.8D, y + (double)k, z + 0.8D).tex(1.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 100 | worldrenderer.pos(x + 0.8D, y + (double)i, z + 0.8D).tex(1.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 101 | worldrenderer.pos(x + 0.2D, y + (double)i, z + 0.8D).tex(0.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 102 | worldrenderer.pos(x + 0.2D, y + (double)k, z + 0.8D).tex(0.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 103 | worldrenderer.pos(x + 0.8D, y + (double)k, z + 0.2D).tex(1.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 104 | worldrenderer.pos(x + 0.8D, y + (double)i, z + 0.2D).tex(1.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 105 | worldrenderer.pos(x + 0.8D, y + (double)i, z + 0.8D).tex(0.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 106 | worldrenderer.pos(x + 0.8D, y + (double)k, z + 0.8D).tex(0.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 107 | worldrenderer.pos(x + 0.2D, y + (double)k, z + 0.8D).tex(1.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 108 | worldrenderer.pos(x + 0.2D, y + (double)i, z + 0.8D).tex(1.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 109 | worldrenderer.pos(x + 0.2D, y + (double)i, z + 0.2D).tex(0.0D, d12).color(f1, f2, f3, 0.125F).endVertex();
|
| 110 | worldrenderer.pos(x + 0.2D, y + (double)k, z + 0.2D).tex(0.0D, d13).color(f1, f2, f3, 0.125F).endVertex();
|
| 111 | tessellator.draw();
|
| 112 | GlStateManager.enableLighting();
|
| 113 | GlStateManager.enableTexture2D();
|
| 114 | GlStateManager.depthMask(true);
|
| 115 | i = k;
|
| 116 | }
|
| 117 |
|
| 118 | GlStateManager.enableFog();
|
| 119 | }
|
| 120 | }
|
| 121 |
|
| 122 | /**
|
| 123 | * If true the {@link TileEntitySpecialRenderer} will always be rendered while the player is in the render bounding
|
| 124 | * box {@link TileEntity#getRenderBoundingBox()} and his squared distance with the {@link TileEntity} is smaller
|
| 125 | * than {@link TileEntity#getMaxRenderDistanceSquared()}.
|
| 126 | */
|
| 127 | public boolean forceTileEntityRender()
|
| 128 | {
|
| 129 | return true;
|
| 130 | }
|
| 131 | }
|
| 132 |
|