Mekanism-tilera-Edition/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java

75 lines
2.7 KiB
Java
Raw Normal View History

package mekanism.client.render.tileentity;
import mekanism.api.Object3D;
import mekanism.client.model.ModelTransmitter;
import mekanism.common.TransporterStack;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.TransporterUtils;
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;
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;
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-06 05:58:44 +02:00
private ModelTransmitter model = new ModelTransmitter();
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-06 05:58:44 +02:00
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter" + (tileEntity.isActive ? "Active" : "") + ".png"));
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);
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);
GL11.glPopMatrix();
2013-10-22 05:03:54 +02:00
entityItem.age = 0;
entityItem.hoverStart = 0;
entityItem.setPosition(tileEntity.xCoord + 0.5, tileEntity.yCoord + 0.5, tileEntity.zCoord + 0.5);
entityItem.worldObj = tileEntity.worldObj;
for(TransporterStack stack : tileEntity.transit)
{
GL11.glPushMatrix();
entityItem.setEntityItemStack(stack.itemStack);
Object3D offset = new Object3D(0, 0, 0).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
double progress = (double)stack.progress / 100D * 0.5D;
renderer.doRenderItem(entityItem, x + 0.5 + offset.xCoord*progress, y + 0.5 + offset.yCoord*progress - entityItem.yOffset, z + 0.5 + offset.zCoord*progress, 0, 0);
GL11.glPopMatrix();
}
2013-08-06 05:58:44 +02:00
}
}