2014-09-19 04:38:14 +02:00
|
|
|
package com.pahimar.ee3.client.renderer.tileentity;
|
|
|
|
|
2014-10-03 21:55:22 +02:00
|
|
|
import com.pahimar.ee3.api.Glyph;
|
2014-09-24 22:02:45 +02:00
|
|
|
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
|
2014-10-03 21:55:22 +02:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2014-09-19 04:38:14 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-09-25 22:23:45 +02:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2014-09-19 04:38:14 +02:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-10-07 22:20:41 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-09-24 22:02:45 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-09-19 04:38:14 +02:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
|
|
{
|
2014-09-24 22:02:45 +02:00
|
|
|
if (tileEntity instanceof TileEntityAlchemyArray)
|
|
|
|
{
|
2014-10-03 21:55:22 +02:00
|
|
|
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
2014-09-24 22:02:45 +02:00
|
|
|
|
2014-09-25 22:23:45 +02:00
|
|
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
2014-09-24 22:02:45 +02:00
|
|
|
GL11.glPushMatrix();
|
2014-10-03 21:55:22 +02:00
|
|
|
for (Glyph glyph : tileEntityAlchemyArray.getAlchemyArray().getGlyphs())
|
2014-09-24 22:02:45 +02:00
|
|
|
{
|
2014-10-02 06:16:47 +02:00
|
|
|
this.bindTexture(glyph.getTexture());
|
2014-10-07 22:20:41 +02:00
|
|
|
renderSymbol(glyph, x, y, z, tileEntityAlchemyArray.getOrientation());
|
2014-09-24 22:02:45 +02:00
|
|
|
}
|
|
|
|
GL11.glPopMatrix();
|
2014-09-25 22:23:45 +02:00
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
2014-09-24 22:02:45 +02:00
|
|
|
}
|
2014-09-19 04:38:14 +02:00
|
|
|
}
|
2014-09-25 22:23:45 +02:00
|
|
|
|
2014-10-07 22:20:41 +02:00
|
|
|
private void renderSymbol(Glyph glyph, double x, double y, double z, ForgeDirection orientation)
|
2014-09-25 22:23:45 +02:00
|
|
|
{
|
2014-10-07 22:20:41 +02:00
|
|
|
// TODO handle facing variants of glyphs
|
2014-09-25 22:23:45 +02:00
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
|
|
|
tessellator.startDrawingQuads();
|
2014-10-07 22:20:41 +02:00
|
|
|
|
|
|
|
if (orientation == ForgeDirection.DOWN)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0f, 0.5f - (glyph.getSize() / 2f));
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.999d, z + glyph.getSize(), 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.999d, z, 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y + 0.999d, z, 1, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y + 0.999d, z + glyph.getSize(), 1, 0);
|
|
|
|
}
|
|
|
|
else if (orientation == ForgeDirection.UP)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0f, 0.5f - (glyph.getSize() / 2f));
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z + glyph.getSize(), 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z, 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y + 0.001d, z, 1, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y + 0.001d, z + glyph.getSize(), 1, 0);
|
|
|
|
}
|
|
|
|
else if (orientation == ForgeDirection.NORTH)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f), 0f);
|
|
|
|
tessellator.addVertexWithUV(x, y + glyph.getSize(), z + 0.999d, 1, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + glyph.getSize(), z + 0.999d, 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y, z + 0.999d, 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y, z + 0.999d, 1, 1);
|
|
|
|
}
|
|
|
|
else if (orientation == ForgeDirection.SOUTH)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f), 0f);
|
|
|
|
tessellator.addVertexWithUV(x, y + glyph.getSize(), z + 0.001d, 1, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y + glyph.getSize(), z + 0.001d, 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + glyph.getSize(), y, z + 0.001d, 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x, y, z + 0.001d, 1, 1);
|
|
|
|
}
|
|
|
|
else if (orientation == ForgeDirection.WEST)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0f, 0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f));
|
|
|
|
tessellator.addVertexWithUV(x + 0.999d, y + glyph.getSize(), z, 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + 0.999d, y + glyph.getSize(), z + glyph.getSize(), 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x + 0.999d, y, z + glyph.getSize(), 1, 1);
|
|
|
|
tessellator.addVertexWithUV(x + 0.999d, y, z, 1, 0);
|
|
|
|
}
|
|
|
|
else if (orientation == ForgeDirection.EAST)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0f, 0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f));
|
|
|
|
tessellator.addVertexWithUV(x + 0.001d, y + glyph.getSize(), z, 0, 0);
|
|
|
|
tessellator.addVertexWithUV(x + 0.001d, y + glyph.getSize(), z + glyph.getSize(), 0, 1);
|
|
|
|
tessellator.addVertexWithUV(x + 0.001d, y, z + glyph.getSize(), 1, 1);
|
|
|
|
tessellator.addVertexWithUV(x + 0.001d, y, z, 1, 0);
|
|
|
|
}
|
|
|
|
|
2014-09-25 22:23:45 +02:00
|
|
|
tessellator.draw();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2014-09-19 04:38:14 +02:00
|
|
|
}
|