2013-08-27 00:57:08 +02:00
|
|
|
package mekanism.client.render.tileentity;
|
2013-08-04 05:02:06 +02:00
|
|
|
|
2013-10-29 23:13:30 +01:00
|
|
|
import mekanism.api.Object3D;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.client.model.ModelTransmitter;
|
2013-10-23 03:13:23 +02:00
|
|
|
import mekanism.client.model.ModelTransmitter.Size;
|
2013-10-24 02:34:33 +02:00
|
|
|
import mekanism.client.model.ModelTransporterBox;
|
2013-10-26 03:34:55 +02:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
2013-10-25 14:51:13 +02:00
|
|
|
import mekanism.common.transporter.TransporterStack;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-10-14 20:25:04 +02:00
|
|
|
import mekanism.common.util.TransporterUtils;
|
2013-10-21 04:47:20 +02:00
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
2013-08-06 05:58:44 +02:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
2013-10-21 04:47:20 +02:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2013-08-06 05:58:44 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-10-14 20:25:04 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-08-06 05:58:44 +02:00
|
|
|
public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
2013-08-04 05:02:06 +02:00
|
|
|
{
|
2013-10-23 03:13:23 +02:00
|
|
|
private ModelTransmitter model = new ModelTransmitter(Size.LARGE);
|
2013-10-24 02:34:33 +02:00
|
|
|
private ModelTransporterBox modelBox = new ModelTransporterBox();
|
2013-08-06 05:58:44 +02:00
|
|
|
|
2013-10-21 04:47:20 +02:00
|
|
|
private EntityItem entityItem = new EntityItem(null);
|
|
|
|
private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
|
|
|
|
|
2013-08-06 05:58:44 +02:00
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
|
|
|
{
|
|
|
|
renderAModelAt((TileEntityLogisticalTransporter)tileEntity, x, y, z, partialTick);
|
|
|
|
}
|
2013-08-04 05:02:06 +02:00
|
|
|
|
2013-08-06 05:58:44 +02:00
|
|
|
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
|
|
|
|
{
|
2013-10-29 23:13:30 +01:00
|
|
|
int meta = Object3D.get(tileEntity).getMetadata(tileEntity.worldObj);
|
|
|
|
|
|
|
|
if(meta == 3)
|
|
|
|
{
|
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
|
|
|
|
}
|
|
|
|
else if(meta == 4)
|
|
|
|
{
|
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RestrictiveTransporter.png"));
|
|
|
|
}
|
2013-11-22 22:18:17 +01:00
|
|
|
else if(meta == 5)
|
|
|
|
{
|
2013-11-23 21:01:18 +01:00
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DiversionTransporter.png"));
|
2013-11-22 22:18:17 +01:00
|
|
|
}
|
2013-10-29 23:13:30 +01:00
|
|
|
|
2013-08-06 05:58:44 +02:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
|
|
|
GL11.glScalef(1.0F, -1F, -1F);
|
|
|
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
|
|
|
2013-10-24 02:34:33 +02:00
|
|
|
if(tileEntity.color != null)
|
|
|
|
{
|
|
|
|
GL11.glColor4f(tileEntity.color.getColor(0), tileEntity.color.getColor(1), tileEntity.color.getColor(2), 1.0F);
|
|
|
|
}
|
|
|
|
|
2013-08-06 05:58:44 +02:00
|
|
|
boolean[] connectable = TransporterUtils.getConnections(tileEntity);
|
|
|
|
|
|
|
|
model.renderCenter(connectable);
|
|
|
|
|
|
|
|
for(int i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
2013-10-22 05:46:24 +02:00
|
|
|
GL11.glPopMatrix();
|
2013-10-21 04:47:20 +02:00
|
|
|
|
2013-10-22 05:03:54 +02:00
|
|
|
entityItem.age = 0;
|
|
|
|
entityItem.hoverStart = 0;
|
|
|
|
|
2013-10-22 05:46:24 +02:00
|
|
|
entityItem.setPosition(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5);
|
|
|
|
entityItem.worldObj = tileEntity.worldObj;
|
|
|
|
|
2013-10-21 04:47:20 +02:00
|
|
|
for(TransporterStack stack : tileEntity.transit)
|
|
|
|
{
|
2013-10-22 05:46:24 +02:00
|
|
|
GL11.glPushMatrix();
|
2013-10-21 04:47:20 +02:00
|
|
|
entityItem.setEntityItemStack(stack.itemStack);
|
|
|
|
|
2013-10-28 19:42:28 +01:00
|
|
|
float[] pos = TransporterUtils.getStackPosition(tileEntity, stack, partialTick*TileEntityLogisticalTransporter.SPEED);
|
2013-10-21 04:47:20 +02:00
|
|
|
|
2013-11-06 23:52:30 +01:00
|
|
|
GL11.glTranslated(x + pos[0], y + pos[1] - entityItem.yOffset, z + pos[2]);
|
|
|
|
GL11.glScalef(0.75F, 0.75F, 0.75F);
|
|
|
|
|
|
|
|
renderer.doRenderItem(entityItem, 0, 0, 0, 0, 0);
|
2013-10-22 05:46:24 +02:00
|
|
|
GL11.glPopMatrix();
|
2013-10-24 02:34:33 +02:00
|
|
|
|
|
|
|
if(stack.color != null)
|
|
|
|
{
|
|
|
|
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png"));
|
|
|
|
GL11.glPushMatrix();
|
2013-10-26 03:34:55 +02:00
|
|
|
MekanismRenderer.glowOn();
|
2013-10-24 02:34:33 +02:00
|
|
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
|
|
GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F);
|
2013-10-28 00:27:33 +01:00
|
|
|
GL11.glTranslatef((float)(x + pos[0]), (float)(y + pos[1] - entityItem.yOffset - (stack.itemStack.itemID < 256 ? 0.1 : 0)), (float)(z + pos[2]));
|
2013-10-24 02:34:33 +02:00
|
|
|
modelBox.render(0.0625F);
|
2013-10-26 03:34:55 +02:00
|
|
|
MekanismRenderer.glowOff();
|
2013-10-24 02:34:33 +02:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2013-10-21 04:47:20 +02:00
|
|
|
}
|
2013-08-06 05:58:44 +02:00
|
|
|
}
|
2013-08-04 05:02:06 +02:00
|
|
|
}
|