Fixed piston rotation for renderer

This commit is contained in:
Robert S 2014-06-13 19:53:02 -04:00
parent 209dd99820
commit fa376f44a9
1 changed files with 46 additions and 47 deletions

View File

@ -18,62 +18,61 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderMechanicalPiston extends TileEntitySpecialRenderer
{
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");
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");
@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;
@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;
GL11.glRotated(-90, 0, 1, 0);
GL11.glRotated(180, 0, 0, 1);
GL11.glRotated(-90, 0, 1, 0);
GL11.glRotated(180, 0, 0, 1);
if (tile.worldObj != null)
{
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
}
if (tile.worldObj != null)
{
if (tile.getDirection() != ForgeDirection.UP && tile.getDirection() != ForgeDirection.DOWN)
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection().getOpposite());
else
RenderUtility.rotateBlockBasedOnDirection(tile.getDirection());
}
RenderUtility.bind(TEXTURE);
RenderUtility.bind(TEXTURE);
// 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" };
// 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" };
/**
* Render Piston Rotor
*/
GL11.glPushMatrix();
GL11.glRotated(-Math.toDegrees(angle), 0, 0, 1);
MODEL.renderAllExcept(ArrayUtils.addAll(shaftParts, staticParts));
GL11.glPopMatrix();
/** Render Piston Rotor */
GL11.glPushMatrix();
GL11.glRotated(-Math.toDegrees(angle), 0, 0, 1);
MODEL.renderAllExcept(ArrayUtils.addAll(shaftParts, staticParts));
GL11.glPopMatrix();
/**
* Render Piston Shaft
*/
GL11.glPushMatrix();
/** Render Piston Shaft */
GL11.glPushMatrix();
if (tile.worldObj != null)
{
ForgeDirection dir = tile.getDirection();
if (tile.worldObj != null)
{
ForgeDirection dir = tile.getDirection();
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);
}
}
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);
}
}
MODEL.renderOnly(shaftParts);
GL11.glPopMatrix();
MODEL.renderOnly(shaftParts);
GL11.glPopMatrix();
MODEL.renderOnly(staticParts);
GL11.glPopMatrix();
}
MODEL.renderOnly(staticParts);
GL11.glPopMatrix();
}
}