More NPE protection for alchemy array renderer
This commit is contained in:
parent
86d07610ec
commit
672d710231
|
@ -22,187 +22,190 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer
|
|||
{
|
||||
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
|
||||
AlchemyArray alchemyArray = tileEntityAlchemyArray.getAlchemyArray();
|
||||
|
||||
if (alchemyArray != null)
|
||||
if (tileEntityAlchemyArray != null)
|
||||
{
|
||||
if (alchemyArray instanceof ICustomAlchemyArrayRender)
|
||||
AlchemyArray alchemyArray = tileEntityAlchemyArray.getAlchemyArray();
|
||||
|
||||
if (alchemyArray != null)
|
||||
{
|
||||
((ICustomAlchemyArrayRender) alchemyArray).doCustomRendering(tileEntity, x, y, z, tileEntityAlchemyArray.getSize(), tileEntityAlchemyArray.getOrientation(), tileEntityAlchemyArray.getRotation(), tick);
|
||||
}
|
||||
else
|
||||
{
|
||||
int scale = 1;
|
||||
double xShift = 0.5d, yShift = 0.5d, zShift = 0.5d;
|
||||
float xRotate = 0, yRotate = 0, zRotate = 0;
|
||||
int rotationAngle = 0;
|
||||
|
||||
if (tileEntityAlchemyArray.getSize() == 1)
|
||||
if (alchemyArray instanceof ICustomAlchemyArrayRender)
|
||||
{
|
||||
scale = 1;
|
||||
((ICustomAlchemyArrayRender) alchemyArray).doCustomRendering(tileEntity, x, y, z, tileEntityAlchemyArray.getSize(), tileEntityAlchemyArray.getOrientation(), tileEntityAlchemyArray.getRotation(), tick);
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getSize() == 2)
|
||||
else
|
||||
{
|
||||
scale = 3;
|
||||
int scale = 1;
|
||||
double xShift = 0.5d, yShift = 0.5d, zShift = 0.5d;
|
||||
float xRotate = 0, yRotate = 0, zRotate = 0;
|
||||
int rotationAngle = 0;
|
||||
|
||||
if (tileEntityAlchemyArray.getSize() == 1)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getSize() == 2)
|
||||
{
|
||||
scale = 3;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getSize() == 3)
|
||||
{
|
||||
scale = 5;
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yShift = 0.001d;
|
||||
xRotate = -1;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yShift = 0.999d;
|
||||
xRotate = 1;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
|
||||
zRotate = 1;
|
||||
zShift = 0.999d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = -180;
|
||||
}
|
||||
|
||||
zRotate = -1;
|
||||
zShift = 0.001d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yRotate = 1;
|
||||
xShift = 0.001d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
|
||||
yRotate = -1;
|
||||
xShift = 0.999d;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + xShift, y + yShift, z + zShift);
|
||||
GL11.glScalef(1f * scale, 1f * scale, 1f * scale);
|
||||
GL11.glRotatef(rotationAngle, tileEntityAlchemyArray.getOrientation().offsetX, tileEntityAlchemyArray.getOrientation().offsetY, tileEntityAlchemyArray.getOrientation().offsetZ);
|
||||
GL11.glRotatef(90, xRotate, yRotate, zRotate);
|
||||
RenderUtils.renderQuad(alchemyArray.getTexture());
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getSize() == 3)
|
||||
{
|
||||
scale = 5;
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yShift = 0.001d;
|
||||
xRotate = -1;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yShift = 0.999d;
|
||||
xRotate = 1;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = -180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
|
||||
zRotate = 1;
|
||||
zShift = 0.999d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.WEST)
|
||||
{
|
||||
rotationAngle = -180;
|
||||
}
|
||||
|
||||
zRotate = -1;
|
||||
zShift = 0.001d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
|
||||
yRotate = 1;
|
||||
xShift = 0.001d;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST)
|
||||
{
|
||||
if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP)
|
||||
{
|
||||
rotationAngle = 180;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN)
|
||||
{
|
||||
rotationAngle = 0;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH)
|
||||
{
|
||||
rotationAngle = 90;
|
||||
}
|
||||
else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.SOUTH)
|
||||
{
|
||||
rotationAngle = -90;
|
||||
}
|
||||
|
||||
yRotate = -1;
|
||||
xShift = 0.999d;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + xShift, y + yShift, z + zShift);
|
||||
GL11.glScalef(1f * scale, 1f * scale, 1f * scale);
|
||||
GL11.glRotatef(rotationAngle, tileEntityAlchemyArray.getOrientation().offsetX, tileEntityAlchemyArray.getOrientation().offsetY, tileEntityAlchemyArray.getOrientation().offsetZ);
|
||||
GL11.glRotatef(90, xRotate, yRotate, zRotate);
|
||||
RenderUtils.renderQuad(alchemyArray.getTexture());
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue