Last active
August 29, 2015 14:25
-
-
Save sham1/8406fb4d4581f7e03d5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def findNearestExit(from: EnumFacing): BlockPos = { | |
val possibleDirections: mutable.Set[EnumFacing] = mutable.Set.empty[EnumFacing] | |
for (dir <- EnumFacing.values()){ | |
if (dir != from && hasTileEntityIn(worldObj, pos.offset(dir)) && worldObj.getTileEntity(pos.offset(dir)).isInstanceOf[IFluidHandler]) possibleDirections += dir | |
} | |
if (possibleDirections.isEmpty) return null | |
var destinationBlockPos: BlockPos = null | |
for (possibleDirection <- possibleDirections){ | |
val fluidHandler: IFluidHandler = worldObj.getTileEntity(pos.offset(possibleDirection)).asInstanceOf[IFluidHandler] | |
fluidHandler match { | |
case warpPipe: FCraftWarpPipeTileEntity => destinationBlockPos = warpPipe.findNearestExit(possibleDirection) | |
case _ => destinationBlockPos = worldObj.getTileEntity(pos.offset(possibleDirection)).getPos | |
} | |
} | |
destinationBlockPos | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment