2013-12-01 06:46:15 +01:00
|
|
|
package mekanism.induction.client.render;
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-12-01 06:46:15 +01:00
|
|
|
import mekanism.induction.client.model.ModelInsulation;
|
|
|
|
import mekanism.induction.client.model.ModelWire;
|
|
|
|
import mekanism.induction.common.MekanismInduction;
|
|
|
|
import mekanism.induction.common.tileentity.TileEntityWire;
|
|
|
|
import mekanism.induction.common.wire.EnumWireMaterial;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import universalelectricity.core.vector.Vector3;
|
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class RenderWire extends TileEntitySpecialRenderer
|
|
|
|
{
|
2013-12-02 22:39:43 +01:00
|
|
|
private static final ResourceLocation WIRE_TEXTURE = MekanismUtils.getResource(ResourceType.RENDER, "WireSimple.png");
|
|
|
|
private static final ResourceLocation INSULATION_TEXTURE = MekanismUtils.getResource(ResourceType.RENDER, "InsulationSimple.png");
|
|
|
|
|
2013-12-01 06:46:15 +01:00
|
|
|
public static final ModelWire WIRE_MODEL = new ModelWire();
|
|
|
|
public static final ModelInsulation INSULATION_MODEL = new ModelInsulation();
|
2013-12-02 23:04:41 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
|
|
|
{
|
|
|
|
renderAModelAt((TileEntityWire)tileEntity, x, y, z, partialTick);
|
|
|
|
}
|
2013-12-01 06:46:15 +01:00
|
|
|
|
2013-12-02 23:04:41 +01:00
|
|
|
public void renderAModelAt(TileEntityWire tileEntity, double x, double y, double z, float partialTick)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
2013-12-02 22:39:43 +01:00
|
|
|
if(tileEntity != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
2013-12-02 23:04:41 +01:00
|
|
|
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
2013-12-01 06:46:15 +01:00
|
|
|
GL11.glScalef(1, -1, -1);
|
|
|
|
|
|
|
|
EnumWireMaterial material = tileEntity.getMaterial();
|
2013-12-02 23:04:41 +01:00
|
|
|
|
2013-12-01 06:46:15 +01:00
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(WIRE_TEXTURE);
|
|
|
|
GL11.glColor4d(material.color.x, material.color.y, material.color.z, 1);
|
|
|
|
|
|
|
|
tileEntity.adjacentConnections = null;
|
|
|
|
TileEntity[] adjacentConnections = tileEntity.getAdjacentConnections();
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[0] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderBottom();
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[1] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderTop();
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[2] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderBack();
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[3] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderFront();
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[4] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderLeft();
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[5] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
WIRE_MODEL.renderRight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WIRE_MODEL.renderMiddle();
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(tileEntity.isInsulated)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(INSULATION_TEXTURE);
|
|
|
|
Vector3 insulationColor = MekanismInduction.DYE_COLORS[tileEntity.dyeID];
|
|
|
|
GL11.glColor4d(insulationColor.x, insulationColor.y, insulationColor.z, 1);
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[0] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderBottom(0.0625f);
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[1] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderTop(0.0625f);
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[2] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderBack(0.0625f);
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[3] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderFront(0.0625f);
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[4] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderLeft(0.0625f);
|
|
|
|
}
|
|
|
|
|
2013-12-02 22:39:43 +01:00
|
|
|
if(adjacentConnections[5] != null)
|
2013-12-01 06:46:15 +01:00
|
|
|
{
|
|
|
|
INSULATION_MODEL.renderRight(0.0625f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
INSULATION_MODEL.renderMiddle(0.0625f);
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|