diff options
Diffstat (limited to 'src/main/java/client/renderer/TESR_SECapacitor.java')
-rw-r--r-- | src/main/java/client/renderer/TESR_SECapacitor.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/client/renderer/TESR_SECapacitor.java b/src/main/java/client/renderer/TESR_SECapacitor.java new file mode 100644 index 0000000000..b34e46faff --- /dev/null +++ b/src/main/java/client/renderer/TESR_SECapacitor.java @@ -0,0 +1,69 @@ +package client.renderer; + +import common.tileentities.TE_SpaceElevatorCapacitor; +import kekztech.KekzCore; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class TESR_SECapacitor extends TileEntitySpecialRenderer { + + private static final ResourceLocation capSide = new ResourceLocation(KekzCore.MODID, "textures/blocks/SpaceElevatorCapacitor_side_fullbase.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) { + final Tessellator tessellator = Tessellator.instance; + // Clamp saturation to a minimum of 40% and scale, rounding up + final int sat = (int) Math.ceil( + 255 * Math.max(((TE_SpaceElevatorCapacitor) te).getChargeLevel(), 0.4F) + ); + // Setup vertices + final double fbr_x = x + 1; + final double fbr_z = z + 1; + + final double ftr_y = y + 1; + + final double uv_a_u = 1.0D; + final double uv_a_v = 1.0D; + + final double uv_b_u = 1.0D; + final double uv_b_v = 0.0D; + + final double uv_c_u = 0.0D; + final double uv_c_v = 0.0D; + + final double uv_d_u = 0.0D; + final double uv_d_v = 1.0D; + // Render sides + super.bindTexture(capSide); + + // Prepare Tessellator + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(sat, sat, sat, 255); + tessellator.setBrightness(255); + // (DOWN and UP faces are not rendered as they will not ever be visible in the Space Elevator structure) + // NORTH + tessellator.addVertexWithUV(x, y, z, uv_a_u, uv_a_v); + tessellator.addVertexWithUV(x, ftr_y, z, uv_b_u, uv_b_v); + tessellator.addVertexWithUV(fbr_x, ftr_y, z, uv_c_u, uv_c_v); + tessellator.addVertexWithUV(fbr_x, y, z, uv_d_u, uv_d_v); + // SOUTH + tessellator.addVertexWithUV(fbr_x, y, fbr_z, uv_a_u, uv_a_v); + tessellator.addVertexWithUV(fbr_x, ftr_y, fbr_z, uv_b_u, uv_b_v); + tessellator.addVertexWithUV(x, ftr_y, fbr_z, uv_c_u, uv_c_v); + tessellator.addVertexWithUV(x, y, fbr_z, uv_d_u, uv_d_v); + // WEST + tessellator.addVertexWithUV(x, y, fbr_z, uv_a_u, uv_a_v); + tessellator.addVertexWithUV(x, ftr_y, fbr_z, uv_b_u, uv_b_v); + tessellator.addVertexWithUV(x, ftr_y, z, uv_c_u, uv_c_v); + tessellator.addVertexWithUV(x, y, z, uv_d_u, uv_d_v); + // EAST + tessellator.addVertexWithUV(fbr_x, y, z, uv_a_u, uv_a_v); + tessellator.addVertexWithUV(fbr_x, ftr_y, z, uv_b_u, uv_b_v); + tessellator.addVertexWithUV(fbr_x, ftr_y, fbr_z, uv_c_u, uv_c_v); + tessellator.addVertexWithUV(fbr_x, y, fbr_z, uv_d_u, uv_d_v); + // Draw! + tessellator.draw(); + } +} |