Animated the conveyor belts

To do: animate manipulators
This commit is contained in:
Brian Ricketts 2012-12-28 01:44:34 -06:00
parent 790fbb3e9c
commit b55ca97831
4 changed files with 28 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

View file

@ -34,7 +34,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
GL11.glPushMatrix();
GL11.glTranslatef((float) 0.0F, (float) 1.5F, (float) 0.0F);
GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "BeltTexture.png"));
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "belt/frame0.png"));
modelConveyorBelt.render(0.0625F, 0, false, false, false);
GL11.glPopMatrix();
}

View file

@ -26,8 +26,11 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180f, 0f, 0f, 1f);
int frame = tileEntity.getAnimationFrame();
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "BeltTexture.png");
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "belt/frame" + frame + ".png"); //belt/frame0.png through belt/frame13.png
//System.out.println(AssemblyLine.TEXTURE_PATH + "belt/frame" + frame + ".png");
switch (face)
{

View file

@ -29,6 +29,8 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
{
NONE, UP, DOWN
}
public static final int NUM_FRAMES = 13;
/**
* Joules required to run this thing.
@ -37,6 +39,7 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
public final float maxSpeed = 0.1f;
public float wheelRotation = 0;
public int animFrame = 0; //this is from 0 to 15
private SlantType slantType = SlantType.NONE;
public TileEntityConveyorBelt()
@ -113,10 +116,15 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
if (this.isRunning())
{
this.wheelRotation += 2;
this.wheelRotation += 40;
if (this.wheelRotation > 360)
this.wheelRotation = 0;
float wheelRotPct = wheelRotation / 360f;
animFrame = (int) (wheelRotPct * NUM_FRAMES); //sync the animation
if (animFrame < 0) animFrame = 0;
if (animFrame > NUM_FRAMES) animFrame = NUM_FRAMES;
}
}
@ -244,6 +252,20 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
return worldObj.getEntitiesWithinAABB(Entity.class, bounds);
}
public int getAnimationFrame()
{
TileEntity te = null;
te = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
if (te != null)
if (te instanceof TileEntityConveyorBelt)
return ((TileEntityConveyorBelt) te).getAnimationFrame();
te = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
if (te != null)
if (te instanceof TileEntityConveyorBelt)
return ((TileEntityConveyorBelt) te).getAnimationFrame();
return animFrame;
}
/**
* NBT Data