2013-11-03 02:07:55 +01:00
|
|
|
package mekanism.client.render.tileentity;
|
|
|
|
|
|
|
|
import mekanism.client.MekanismClient;
|
|
|
|
import mekanism.client.model.ModelEnergyCube;
|
|
|
|
import mekanism.client.model.ModelEnergyCube.ModelEnergyCore;
|
|
|
|
import mekanism.client.render.MekanismRenderer;
|
2013-11-30 06:28:02 +01:00
|
|
|
import mekanism.common.EnumColor;
|
2013-11-03 02:07:55 +01:00
|
|
|
import mekanism.common.tileentity.TileEntityEnergyCube;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class RenderEnergyCube extends TileEntitySpecialRenderer
|
|
|
|
{
|
|
|
|
private ModelEnergyCube model = new ModelEnergyCube();
|
|
|
|
private ModelEnergyCore core = new ModelEnergyCore();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
|
|
|
{
|
2013-11-03 05:14:54 +01:00
|
|
|
renderAModelAt((TileEntityEnergyCube)tileEntity, x, y, z, partialTick);
|
2013-11-03 02:07:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void renderAModelAt(TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
|
|
|
|
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube" + tileEntity.tier.name + ".png"));
|
|
|
|
|
2013-11-03 17:38:36 +01:00
|
|
|
switch(tileEntity.facing)
|
|
|
|
{
|
2013-11-07 04:37:41 +01:00
|
|
|
case 0:
|
|
|
|
GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(0.0F, 1.0F, -1.0F);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
|
|
|
|
GL11.glTranslatef(0.0F, 1.0F, 1.0F);
|
|
|
|
break;
|
2013-11-03 17:38:36 +01:00
|
|
|
case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break;
|
|
|
|
case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break;
|
|
|
|
case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break;
|
|
|
|
case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break;
|
|
|
|
}
|
|
|
|
|
2013-11-03 02:07:55 +01:00
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
model.render(0.0625F);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png"));
|
|
|
|
|
2013-11-03 05:14:54 +01:00
|
|
|
MekanismRenderer.blendOn();
|
2013-11-03 02:07:55 +01:00
|
|
|
MekanismRenderer.glowOn();
|
|
|
|
|
|
|
|
EnumColor c = tileEntity.tier.color;
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
2013-11-03 02:19:01 +01:00
|
|
|
GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(tileEntity.getEnergy()/tileEntity.getMaxEnergy()));
|
2013-11-03 02:07:55 +01:00
|
|
|
GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3)) / 7, 0);
|
|
|
|
GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 0);
|
|
|
|
GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 1);
|
|
|
|
core.render(0.0625F);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
|
|
|
MekanismRenderer.glowOff();
|
2013-11-03 05:14:54 +01:00
|
|
|
MekanismRenderer.blendOff();
|
2013-11-03 02:07:55 +01:00
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|