1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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();
}
}
|