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
70
71
72
73
74
75
76
77
78
79
|
package gregtech.common.render;
import static com.github.technus.tectech.rendering.EOH.EOH_RenderingUtils.addRenderedBlockInWorld;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.registry.ClientRegistry;
import gregtech.common.tileentities.render.TileWormhole;
public class GT_WormholeRenderer extends TileEntitySpecialRenderer {
public GT_WormholeRenderer() {
ClientRegistry.bindTileEntitySpecialRenderer(TileWormhole.class, this);
}
private static final double trimPercentage = .95;
private static final double corePercentage = trimPercentage / Math.sqrt(3);
private static void render(Block coreBlock, double rotation) {
GL11.glPushMatrix();
GL11.glRotated(rotation, 2, 1, 0);
GL11.glScaled(-1, -1, -1);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.setColorOpaque_F(1f, 1f, 1f);
addRenderedBlockInWorld(Blocks.quartz_block, 0, 0, 0, 0);
Tessellator.instance.draw();
GL11.glScaled(trimPercentage, trimPercentage, trimPercentage);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.setColorOpaque_F(0.1f, 0.1f, 0.1f);
addRenderedBlockInWorld(Blocks.coal_block, 0, 0, 0, 0);
Tessellator.instance.draw();
GL11.glPopMatrix();
if (coreBlock != null) {
GL11.glPushMatrix();
GL11.glScaled(corePercentage, corePercentage, corePercentage);
GL11.glRotated(rotation, 0, -2, .1);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.setColorOpaque_F(1f, 1f, 1f);
addRenderedBlockInWorld(coreBlock, 0, 0, 0, 0);
Tessellator.instance.draw();
GL11.glPopMatrix();
}
}
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) {
if (tile instanceof TileWormhole wTile) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glScaled(wTile.targetRadius, wTile.targetRadius, wTile.targetRadius);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glDisable(GL11.GL_LIGHTING);
double rotationTimer = wTile.getWorldObj()
.getWorldInfo()
.getWorldTotalTime() + timeSinceLastTick;
this.bindTexture(TextureMap.locationBlocksTexture);
render(wTile.getBlock(), rotationTimer);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
}
|