From 100c70a111e68ae31ad49accd9b2028b031d1295 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Wed, 10 Dec 2014 22:36:05 +0800 Subject: [PATCH] Fixed water turbine not replacing water blocks under it --- .../mech/turbine/TileWaterTurbine.scala | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/scala/resonantinduction/mechanical/mech/turbine/TileWaterTurbine.scala b/src/main/scala/resonantinduction/mechanical/mech/turbine/TileWaterTurbine.scala index dffd72d63..4eb4755f5 100644 --- a/src/main/scala/resonantinduction/mechanical/mech/turbine/TileWaterTurbine.scala +++ b/src/main/scala/resonantinduction/mechanical/mech/turbine/TileWaterTurbine.scala @@ -3,7 +3,7 @@ package resonantinduction.mechanical.mech.turbine import java.util.List import cpw.mods.fml.relauncher.ReflectionHelper -import net.minecraft.block.{Block, BlockLiquid} +import net.minecraft.block.BlockLiquid import net.minecraft.creativetab.CreativeTabs import net.minecraft.init.Blocks import net.minecraft.item.{Item, ItemStack} @@ -64,10 +64,13 @@ class TileWaterTurbine extends TileTurbine if (ticks % 20 == 0) { - val blockIDAbove: Block = worldObj.getBlock(xCoord, yCoord + 1, zCoord) - val metadata: Int = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord) - val isWater: Boolean = blockIDAbove == Blocks.water || blockIDAbove == Blocks.flowing_water - if (isWater && worldObj.isAirBlock(xCoord, yCoord - 1, zCoord) && metadata == 0) + val blockAbove = worldObj.getBlock(xCoord, yCoord + 1, zCoord) + val blockBelow = worldObj.getBlock(xCoord, yCoord - 1, zCoord) + val metadata = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord) + val isWater = blockAbove == Blocks.water || blockAbove == Blocks.flowing_water + val isBelowAvailable = worldObj.isAirBlock(xCoord, yCoord - 1, zCoord) || blockBelow == Blocks.water || blockBelow == Blocks.flowing_water + + if (isWater && metadata == 0 && isBelowAvailable) { powerTicks = 20 worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord) @@ -79,16 +82,17 @@ class TileWaterTurbine extends TileTurbine else { val currentDir: ForgeDirection = getDirection + for (dir <- ForgeDirection.VALID_DIRECTIONS) { if (dir != currentDir && dir != currentDir.getOpposite) { val check: Vector3 = toVector3.add(dir) - val blockID: Block = worldObj.getBlock(check.xi, check.yi, check.zi) + val block = worldObj.getBlock(check.xi, check.yi, check.zi) val metadata: Int = worldObj.getBlockMetadata(check.xi, check.yi, check.zi) - if (blockID == Blocks.water || blockID == Blocks.flowing_water) - { + if (block == Blocks.water || block == Blocks.flowing_water) + { val m = ReflectionHelper.findMethod(classOf[BlockLiquid], null, Array[String]("getFlowVector", "func_72202_i"), classOf[IBlockAccess], Integer.TYPE, Integer.TYPE, Integer.TYPE) val vector = new Vector3(m.invoke(Blocks.water, worldObj, check.xi: Integer, check.yi: Integer, check.zi: Integer).asInstanceOf[Vec3]) val invert = (currentDir.offsetZ > 0 && vector.x < 0) || (currentDir.offsetZ < 0 && vector.x > 0) || (currentDir.offsetX > 0 && vector.z > 0) || (currentDir.offsetX < 0 && vector.z < 0)