diff options
| author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2020-05-22 20:23:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-22 20:23:55 +0800 |
| commit | 56689ec7b67c46c882d49da4742770e3397a4e9f (patch) | |
| tree | 879a3372906ec2c5f2a53a4ac46f7dde860a654f /src/main/java/client/renderer/TESR_SETether.java | |
| parent | bc19f3ab32c9bccbf936bbeffcc8ddad967ffffd (diff) | |
| parent | 306a0822c27c59cdbd0a61698939a2dfc02068d2 (diff) | |
| download | GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.tar.gz GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.tar.bz2 GT5-Unofficial-56689ec7b67c46c882d49da4742770e3397a4e9f.zip | |
Merge pull request #1 from kekzdealer/master
5/22
Diffstat (limited to 'src/main/java/client/renderer/TESR_SETether.java')
| -rw-r--r-- | src/main/java/client/renderer/TESR_SETether.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/main/java/client/renderer/TESR_SETether.java b/src/main/java/client/renderer/TESR_SETether.java new file mode 100644 index 0000000000..2e4fa95cc5 --- /dev/null +++ b/src/main/java/client/renderer/TESR_SETether.java @@ -0,0 +1,76 @@ +package client.renderer; + +import kekztech.KekzCore; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class TESR_SETether extends TileEntitySpecialRenderer { + + private static final ResourceLocation tetherBeamTexture = new ResourceLocation(KekzCore.MODID, "textures/effects/Tether_beam.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { + float beamLengthScale = 1.0F; // [0.0F, 1.0F] -> linear scale from 0 to 256 + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + // Get Tessellator instance + final Tessellator tessellator = Tessellator.instance; + // Bind beam texture and set texture params + super.bindTexture(tetherBeamTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + // Set render flags for inner beam + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + // Prepare Tessellator + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(255, 255, 255, 32); + // Variables stuff II + final double halfBeamWidth = 0.38D; + final double d_rot1 = 0.5D + Math.cos(2.356194490192345D) * halfBeamWidth; // rotates the beam... + final double d_rot2 = 0.5D + Math.sin(2.356194490192345D) * halfBeamWidth; + final double d_rot3 = 0.5D + Math.cos((Math.PI / 4D)) * halfBeamWidth; + final double d_rot4 = 0.5D + Math.sin((Math.PI / 4D)) * halfBeamWidth; + final double d_rot5 = 0.5D + Math.cos(3.9269908169872414D) * halfBeamWidth; + final double d_rot6 = 0.5D + Math.sin(3.9269908169872414D) * halfBeamWidth; + final double d_rot7 = 0.5D + Math.cos(5.497787143782138D) * halfBeamWidth; + final double d_rot8 = 0.5D + Math.sin(5.497787143782138D) * halfBeamWidth; // ...until here + final double height = 256.0F * beamLengthScale; + final double uv_x1 = 0.0D; + final double uv_x2 = 1.0D; + final double uv_y1 = -1.0D; // This makes the beam stream upwards if you add a time sensitive number to it + final double uv_y2 = (double)(256.0F * beamLengthScale) * (0.5D / halfBeamWidth) + uv_y1; + // Construct mesh with texture + tessellator.addVertexWithUV(x + d_rot1, y + height, z + d_rot2, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + d_rot1, y, z + d_rot2, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + d_rot3, y, z + d_rot4, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + d_rot3, y + height, z + d_rot4, uv_x1, uv_y2); + tessellator.addVertexWithUV(x + d_rot7, y + height, z + d_rot8, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + d_rot7, y, z + d_rot8, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + d_rot5, y, z + d_rot6, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + d_rot5, y + height, z + d_rot6, uv_x1, uv_y2); + tessellator.addVertexWithUV(x + d_rot3, y + height, z + d_rot4, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + d_rot3, y, z + d_rot4, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + d_rot7, y, z + d_rot8, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + d_rot7, y + height, z + d_rot8, uv_x1, uv_y2); + tessellator.addVertexWithUV(x + d_rot5, y + height, z + d_rot6, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + d_rot5, y, z + d_rot6, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + d_rot1, y, z + d_rot2, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + d_rot1, y + height, z + d_rot2, uv_x1, uv_y2); + // Draw! + tessellator.draw(); + + // Reset render flags + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } + +} |
