2014-02-26 08:31:00 +01:00
|
|
|
package resonantinduction.mechanical.process.crusher;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
|
|
import net.minecraftforge.client.model.IModelCustom;
|
2014-04-18 12:14:40 +02:00
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2014-05-14 07:32:00 +02:00
|
|
|
|
2014-04-18 12:14:40 +02:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
2014-02-26 08:31:00 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2014-05-14 07:32:00 +02:00
|
|
|
|
|
|
|
import resonant.lib.render.RenderUtility;
|
2014-02-26 08:31:00 +01:00
|
|
|
import resonantinduction.core.Reference;
|
2014-05-14 07:32:00 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-02-26 08:31:00 +01:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class RenderMechanicalPiston extends TileEntitySpecialRenderer
|
|
|
|
{
|
2014-06-14 01:53:02 +02:00
|
|
|
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "piston/mechanicalPiston.tcn");
|
|
|
|
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "piston/mechanicalPiston_iron.png");
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
|
|
|
TileMechanicalPiston tile = (TileMechanicalPiston) tileEntity;
|
2014-04-18 12:14:40 +02:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
GL11.glRotated(-90, 0, 1, 0);
|
|
|
|
GL11.glRotated(180, 0, 0, 1);
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
if (tile.worldObj != null)
|
|
|
|
{
|
|
|
|
if (tile.getDirection() != ForgeDirection.UP && tile.getDirection() != ForgeDirection.DOWN)
|
|
|
|
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection().getOpposite());
|
|
|
|
else
|
|
|
|
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
|
|
|
|
}
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
RenderUtility.bind(TEXTURE);
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
// Angle in radians of the rotor.
|
|
|
|
double angle = tile.mechanicalNode.renderAngle;
|
|
|
|
final String[] staticParts = { "baseRing", "leg1", "leg2", "leg3", "leg4", "connector", "basePlate", "basePlateTop", "connectorBar", "centerPiston" };
|
|
|
|
final String[] shaftParts = { "topPlate", "outerPiston" };
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
/** Render Piston Rotor */
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glRotated(-Math.toDegrees(angle), 0, 0, 1);
|
|
|
|
MODEL.renderAllExcept(ArrayUtils.addAll(shaftParts, staticParts));
|
|
|
|
GL11.glPopMatrix();
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
/** Render Piston Shaft */
|
|
|
|
GL11.glPushMatrix();
|
2014-04-18 12:14:40 +02:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
if (tile.worldObj != null)
|
|
|
|
{
|
|
|
|
ForgeDirection dir = tile.getDirection();
|
2014-04-18 12:14:40 +02:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
if (tile.world().isAirBlock(tile.x() + dir.offsetX, tile.y() + dir.offsetY, tile.z() + dir.offsetZ))
|
|
|
|
{
|
|
|
|
GL11.glTranslated(0, 0, (0.4 * Math.sin(angle)) - 0.5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GL11.glTranslated(0, 0, (0.06 * Math.sin(angle)) - 0.03);
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 12:14:40 +02:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
MODEL.renderOnly(shaftParts);
|
|
|
|
GL11.glPopMatrix();
|
2014-02-26 08:31:00 +01:00
|
|
|
|
2014-06-14 01:53:02 +02:00
|
|
|
MODEL.renderOnly(staticParts);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2014-02-26 08:31:00 +01:00
|
|
|
}
|