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

View file

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

View file

@ -63,10 +63,10 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
/** The size of the gear */ /** The size of the gear */
private float radius = 0.5f; private float radius = 0.5f;
/** The angular velocity, radians per second. */ /** The angular velocity, radians per second. */
private float angularVelocity = 0; private float angularVelocity = 0;
/** The current angle the gear is on. In radians. */ /** The current angle the gear is on. In radians. */
private float angle = 0; private float angle = 0;
@ -99,9 +99,9 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
((PartGear) part).torque = torque; ((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 */ /** 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()) if (player.isSneaking())
{ {
this.torque += 10; this.torque += 10;
this.angularVelocity += 1;
} }
return false; return false;