Skip to content

Instantly share code, notes, and snippets.

@sham1
Last active August 29, 2015 14:25
Show Gist options
  • Save sham1/8406fb4d4581f7e03d5b to your computer and use it in GitHub Desktop.
Save sham1/8406fb4d4581f7e03d5b to your computer and use it in GitHub Desktop.
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