Got generator working

This commit is contained in:
Calclavia 2014-01-15 21:39:04 +08:00
parent 11aa32154c
commit b6f2d3c503
4 changed files with 41 additions and 39 deletions

View file

@ -20,6 +20,7 @@ public class TileGenerator extends TileElectrical implements IMechanical
public TileGenerator()
{
energy = new EnergyStorageHandler(10000);
this.ioMap = 728;
}
@Override
@ -41,13 +42,13 @@ public class TileGenerator extends TileElectrical implements IMechanical
private boolean isFunctioning()
{
return this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
return true;
}
@Override
public void setPower(long torque, float speed)
{
this.power = (long) Math.abs(torque * speed);
}
@Override

View file

@ -14,40 +14,40 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderReleaseValve extends TileEntitySpecialRenderer
{
public static ModelReleaseValve valve = new ModelReleaseValve();
private TileEntity[] ents = new TileEntity[6];
public static ModelReleaseValve valve = new ModelReleaseValve();
private TileEntity[] ents = new TileEntity[6];
public static final ResourceLocation VALVE_TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_DIRECTORY + "ReleaseValve.png");
public static final ResourceLocation VALVE_TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "releaseValve.png");
@Override
public void renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f)
{
// Texture file
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if (te instanceof TileReleaseValve)
{
ents = ((TileReleaseValve) te).connected;
}
bindTexture(RenderPipe.TEXTURE);
if (ents[0] != null)
RenderPipe.MODEL_PIPE.renderBottom();
if (ents[1] != null)
RenderPipe.MODEL_PIPE.renderTop();
if (ents[3] != null)
RenderPipe.MODEL_PIPE.renderFront();
if (ents[2] != null)
RenderPipe.MODEL_PIPE.renderBack();
if (ents[5] != null)
RenderPipe.MODEL_PIPE.renderRight();
if (ents[4] != null)
RenderPipe.MODEL_PIPE.renderLeft();
RenderPipe.MODEL_PIPE.renderMiddle();
bindTexture(VALVE_TEXTURE);
if (ents[1] == null)
valve.render();
GL11.glPopMatrix();
@Override
public void renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f)
{
// Texture file
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if (te instanceof TileReleaseValve)
{
ents = ((TileReleaseValve) te).connected;
}
bindTexture(RenderPipe.TEXTURE);
if (ents[0] != null)
RenderPipe.MODEL_PIPE.renderBottom();
if (ents[1] != null)
RenderPipe.MODEL_PIPE.renderTop();
if (ents[3] != null)
RenderPipe.MODEL_PIPE.renderFront();
if (ents[2] != null)
RenderPipe.MODEL_PIPE.renderBack();
if (ents[5] != null)
RenderPipe.MODEL_PIPE.renderRight();
if (ents[4] != null)
RenderPipe.MODEL_PIPE.renderLeft();
RenderPipe.MODEL_PIPE.renderMiddle();
bindTexture(VALVE_TEXTURE);
if (ents[1] == null)
valve.render();
GL11.glPopMatrix();
}
}
}

View file

@ -63,10 +63,10 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
/** The size of the gear */
private float radius = 0.5f;
/** The angular velocity, radians per second. */
private float angularVelocity = 0;
/** The current angle the gear is on. In radians. */
private float angle = 0;
@ -99,9 +99,9 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
((PartGear) part).torque = torque;
}
}
else if(tile instanceof IMechanical)
else if (tile instanceof IMechanical)
{
((IMechanical)tile).setPower(torque, angularVelocity);
((IMechanical) tile).setPower(torque, angularVelocity);
}
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
@ -149,6 +149,7 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
if (player.isSneaking())
{
this.torque += 10;
this.angularVelocity += 1;
}
return false;