Water turbine now works on all sides

This commit is contained in:
Calclavia 2014-03-18 21:26:18 +08:00
parent fab6b40376
commit a53ab674da
3 changed files with 44 additions and 35 deletions

View file

@ -89,22 +89,24 @@ public class TileWaterTurbine extends TileMechanicalTurbine
else
{
maxPower = 2500;
ForgeDirection currentDir = getDirection();
int checkX = xCoord;
int checkY = yCoord - 1;
int checkZ = zCoord;
int blockID = worldObj.getBlockId(xCoord, checkY, checkZ);
int metadata = worldObj.getBlockMetadata(xCoord, checkY, checkZ);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (dir != currentDir && dir != currentDir.getOpposite())
{
Vector3 check = new Vector3(this).translate(dir);
int blockID = worldObj.getBlockId(check.intX(), check.intY(), check.intZ());
int metadata = worldObj.getBlockMetadata(check.intX(), check.intY(), check.intZ());
if (blockID == Block.waterMoving.blockID || blockID == Block.waterStill.blockID)
{
try
{
Method m = ReflectionHelper.findMethod(BlockFluid.class, null, new String[] { "getFlowVector", "func_72202_i" }, IBlockAccess.class, Integer.TYPE, Integer.TYPE, Integer.TYPE);
Vector3 vector = new Vector3((Vec3) m.invoke(Block.waterMoving, worldObj, xCoord, checkY, checkZ));
ForgeDirection dir = getDirection();
Vector3 vector = new Vector3((Vec3) m.invoke(Block.waterMoving, worldObj, check.intX(), check.intY(), check.intZ()));
if ((dir.offsetZ > 0 && vector.x < 0) || (dir.offsetZ < 0 && vector.x > 0) || (dir.offsetX > 0 && vector.z > 0) || (dir.offsetX < 0 && vector.z < 0))
if ((currentDir.offsetZ > 0 && vector.x < 0) || (currentDir.offsetZ < 0 && vector.x > 0) || (currentDir.offsetX > 0 && vector.z > 0) || (currentDir.offsetX < 0 && vector.z < 0))
torque = -torque;
if (getDirection().offsetX != 0)
@ -118,6 +120,8 @@ public class TileWaterTurbine extends TileMechanicalTurbine
}
}
}
}
}
super.updateEntity();
}

View file

@ -57,7 +57,7 @@ public class RenderMechanicalPiston extends TileEntitySpecialRenderer
*/
GL11.glPushMatrix();
// TODO: Temporary, unless new models come out.
GL11.glTranslated(0, 0, (0.06 * Math.sin(angle - Math.PI)) - 0.01);
GL11.glTranslated(0, 0, (0.06 * Math.sin(angle)) - 0.01);
MODEL.renderOnly("PistonShaft", "PistonFace", "PistonFace2");
GL11.glPopMatrix();

View file

@ -92,6 +92,8 @@ public class TileMechanicalPiston extends TileMechanical implements IRotatable
RecipeResource[] resources = MachineRecipes.INSTANCE.getOutput(ResonantInduction.RecipeType.CRUSHER.name(), blockStack);
if (resources.length > 0)
{
if (!worldObj.isRemote)
{
int breakStatus = (int) (((float) (mechanicalPistonBreakCount - breakCount) / (float) mechanicalPistonBreakCount) * 10f);
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), breakStatus);
@ -113,6 +115,7 @@ public class TileMechanicalPiston extends TileMechanical implements IRotatable
breakCount = mechanicalPistonBreakCount;
}
}
ResonantInduction.proxy.renderBlockParticle(worldObj, blockPos.clone().translate(0.5), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), block.blockID, 1);
breakCount--;
@ -120,8 +123,10 @@ public class TileMechanicalPiston extends TileMechanical implements IRotatable
}
}
breakCount = 0;
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), 10);
breakCount = mechanicalPistonBreakCount;
if (!worldObj.isRemote)
world().destroyBlockInWorldPartially(0, blockPos.intX(), blockPos.intY(), blockPos.intZ(), -1);
return false;
}