diff options
| author | kekzdealer <kekzdealer@gmail.com> | 2020-06-23 02:17:11 +0200 |
|---|---|---|
| committer | kekzdealer <kekzdealer@gmail.com> | 2020-06-23 02:17:11 +0200 |
| commit | 2178a42eca603aba98ca4e181c2c46597e638597 (patch) | |
| tree | 2093f82aa2a11504ea3413e9ad0ed752f0b22bf8 /src/main/java/client | |
| parent | 8a94750eec21b70a04eca7589c2626341a5eb83f (diff) | |
| download | GT5-Unofficial-2178a42eca603aba98ca4e181c2c46597e638597.tar.gz GT5-Unofficial-2178a42eca603aba98ca4e181c2c46597e638597.tar.bz2 GT5-Unofficial-2178a42eca603aba98ca4e181c2c46597e638597.zip | |
Started to imlements BeamTransmitter
Diffstat (limited to 'src/main/java/client')
| -rw-r--r-- | src/main/java/client/ClientProxy.java | 3 | ||||
| -rw-r--r-- | src/main/java/client/GTTexture.java | 6 | ||||
| -rw-r--r-- | src/main/java/client/renderer/TESR_BeamTransmitter.java | 65 |
3 files changed, 71 insertions, 3 deletions
diff --git a/src/main/java/client/ClientProxy.java b/src/main/java/client/ClientProxy.java index f608861c0d..5ed713f827 100644 --- a/src/main/java/client/ClientProxy.java +++ b/src/main/java/client/ClientProxy.java @@ -1,8 +1,10 @@ package client; +import client.renderer.TESR_BeamTransmitter; import client.renderer.TESR_SECapacitor; import client.renderer.TESR_SETether; import common.CommonProxy; +import common.tileentities.TE_BeamTransmitter; import common.tileentities.TE_SpaceElevatorCapacitor; import common.tileentities.TE_SpaceElevatorTether; import cpw.mods.fml.client.registry.ClientRegistry; @@ -18,6 +20,7 @@ public class ClientProxy extends CommonProxy { // Register TESR ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorTether.class, new TESR_SETether()); ClientRegistry.bindTileEntitySpecialRenderer(TE_SpaceElevatorCapacitor.class, new TESR_SECapacitor()); + ClientRegistry.bindTileEntitySpecialRenderer(TE_BeamTransmitter.class, new TESR_BeamTransmitter()); } @Override diff --git a/src/main/java/client/GTTexture.java b/src/main/java/client/GTTexture.java index a449dc257b..2ede4976fb 100644 --- a/src/main/java/client/GTTexture.java +++ b/src/main/java/client/GTTexture.java @@ -12,9 +12,9 @@ import java.util.HashMap; public class GTTexture implements IIconContainer, Runnable { - public static final GTTexture TFFT_CASING = new GTTexture("textures/blocks/TFFTCasing"); - public static final GTTexture MULTI_HATCH_OFF = new GTTexture("textures/blocks/multi_hatch_off"); - public static final GTTexture MULTI_HATCH_ON = new GTTexture("textures/blocks/multi_hatch_on"); + public static final GTTexture TFFT_CASING = new GTTexture("blocks/TFFTCasing"); + public static final GTTexture MULTI_HATCH_OFF = new GTTexture("blocks/multi_hatch_off"); + public static final GTTexture MULTI_HATCH_ON = new GTTexture("blocks/multi_hatch_on"); private IIcon icon; private final String iconName; diff --git a/src/main/java/client/renderer/TESR_BeamTransmitter.java b/src/main/java/client/renderer/TESR_BeamTransmitter.java new file mode 100644 index 0000000000..3c48dab264 --- /dev/null +++ b/src/main/java/client/renderer/TESR_BeamTransmitter.java @@ -0,0 +1,65 @@ +package client.renderer; + +import common.tileentities.TE_BeamTransmitter; +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.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class TESR_BeamTransmitter extends TileEntitySpecialRenderer { + + private static final ResourceLocation beamTexture = new ResourceLocation(KekzCore.MODID, "textures/effects/Tether_beam.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { + final TE_BeamTransmitter beamTransmitter = (TE_BeamTransmitter) te; + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + // Get Tessellator instance + final Tessellator tessellator = Tessellator.instance; + // Bind beam texture and set texture params + super.bindTexture(beamTexture); + 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 float exactTime = (float)beamTransmitter.getWorldObj().getTotalWorldTime() + partialTick; + final float streamTextureOffset = -exactTime * 0.2F - (float) MathHelper.floor_float(-exactTime * 0.1F); + + final double halfBeamWidth = 0.1D; + final double height = beamTransmitter.getDistanceFromTarget(); + final double uv_x1 = 0.0D; + final double uv_x2 = 1.0D; + final double uv_y1 = -1.0D - streamTextureOffset; // This makes the beam stream upwards if you add a time sensitive number to it + final double uv_y2 = (double)beamTransmitter.getDistanceFromTarget() * (0.5D / (halfBeamWidth * 2)) + uv_y1; + // Construct mesh with texture + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + 0.5, z + 0.5, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5 + halfBeamWidth, y + height, z + 0.5, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + height, z + 0.5, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5 - halfBeamWidth, y + 0.5, z + 0.5, uv_x1, uv_y2); + + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 + halfBeamWidth, uv_x2, uv_y2); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 + halfBeamWidth, uv_x2, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + height, z + 0.5 - halfBeamWidth, uv_x1, uv_y1); + tessellator.addVertexWithUV(x + 0.5, y + 0.5, z + 0.5 - halfBeamWidth, uv_x1, uv_y2); + // Draw! + tessellator.draw(); + + // Reset render flags + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } +} |
